This blog is the third part in a four-part series on how to use a Slack bot to extract LaunchDarkly data. If you haven’t already, check out part one and part two of the series before pursuing the steps in this demo.
For this part of the demo, a Slack account with admin permission is required. In this case, we will use a workspace named ignamiguel.
Before we get started, create a free Slack workspace
Creating a Slack application
1. Create a new Slack app and name it Slack Automation bot
2. Select the slash commands feature.
3. Create a new slash command as the image below.
In the Request URL field set the public URL from the Using Flow Designer > step 5.
4. Save it.
5. Install the Slack Automation bot app into the workspace.
6. After installing, go to Slack and in any channel write /demo. We will get the API response like the image below.
Note that this will only be visible to your user.
7. Done! We are now able to get LD information with a slash command.
Specifying a user key
Now we want to pass a specific user to our slash command.
1. Try writing /demo user-one and hit enter.
2. Go to flow designer, open the HTTP Listener card and go to the output tab. You should see the slash command body.
The body has application/x-www-form-urlencoded mime type. In the next section, we will convert that into a JSON so it is easy to manipulate.
3. Add a Transform card after the HTTP Listener. Go to the script tab and copy this code:
4. Run the application again.
5. Go back to Slack and hit /demo user-one again.
6. In flow designer, open the Transform card, go to output tab and you should see the body transformed into JSON.
7. Check the text property containing the user-one value.
8. Open the Launch Darkly REST API connector, and update the User Key field so it can now get the value from payload.text.
9. Run the application, go back to Slack and try these commands:
The value of “_value” should vary from True to False depending if the user has the show-new-navbar feature enabled or disabled.
Slack has a great tool, which is the message builder web page, where you can preview how a message will be displayed in real-time while you make adjustments to it.
Check out the Slack message builder on Slack’s documentation website. This concludes part three of the demo. Be on the lookout for part four of this series, where I will demonstrate how to create flow designer custom types to easily manipulate data.