Creating a Command Reply
What is a command reply?
A Command Reply is how Workbot responds to the user on Slack after it has received a command and completed the necessary actions. If it's your first time here, you may want to read up on creating a command first.
In practice, you should always pair a command with a command reply (in your recipe), because you want your users to be updated on the success (or failure) of the recipe actions.
If you're here after just completing your first command, great job on getting this far! In this exercise, we'll be using the same recipe as before - creating an issue in Github from Slack using a Workbot command.
Anatomy of a Command reply
The recipe we're working with creates an issue in Gtihub based on inputs provided to Workbot in the command. Here's how they're mapped:
We've used the user input datapills to form the Issue title, Body, and Assignee of the issue. More on this here.
You can set the Organization and Repository of your choice - this is where Workbot will create new Github issues.
As we've mentioned before, we want Workbot to reply to the user after it has finished creating the issue in Github, furnished with some details.
The Slack message above is how we want Workbot's command reply (to the user) to look like after successfully creating the rather unfortunate issue above in Github. Now that we know what we want to do, let's get cracking!
In the recipe, after the "Create issue in Github" action step,
- Add a new step and choose Action.
- Under Application, choose Workbot for Slack
- Under Action, choose Post command reply.
How it should look like at this point:
Now we're ready to start formatting the message!
Message text: Issue Number created The message text is the simplest message that Workbot can reply with in a Slack message. Here we use the Number datapill in the previous step's output datatree.
Next, you should see a list of collapsed fields:
We want to focus on Message attachment for now. The rest of the fields like Buttons and Message menu make your command reply a lot more interactive, but we can keep things simple for now.
Expand the Message Attachments input fields:
Message attachment expanded
There are a lot of fields here, but to achieve our goal for this exercise, we only need to focus on 4 fields:
- Title Link
- Attachment text
- Attachment Color
Command reply explained
Here's what we want to fill up in these 4 fields:
|Title||Name of issue: Title||Here we use the Title datapill from the Command trigger output (in step 2). Back in the ["Creating a command"](/workbot/workbot-commands.md#user-input-fields) guide, we defined **Issue** as a user input field that users can provide in Slack. Now that the issue has been created, Title can be used in subsequent action steps - this is how we're letting users populate Github issue fields from Slack!|
|Title link||URL||Here we take the URL of the created issue. It's yet another output datapill from the issue creation in Github.|
|Just like with Title, we're using the datapills of the created Github issue output.|
|Attachment color||Good||Since we're expecting a positive command reply from Workbot, we set it to Good so that the vertical bar to the left of the message is green.|
When you're confident that you've configured the Message attachment correctly, hit Save.
With that, we're done configuring the command reply! Let's test it out by starting the recipe. You'll also want to sign into both the Github repo that you've connected this recipe to (to check that the issue has indeed been created), as well as the Slack workspace with the installed Workbot (that's connected to this recipe).
Testing the command reply
Before you start, make sure that you're signed in to the Slack workspace where the connected Workbot is installed.
Next, make sure that the recipe has been started. All good? Let's go!
- In Slack, send a DM to Workbot, and say "github create issue"
- Workbot should respond with "Enter issue:"
- Enter the issue title
- Workbot should respond with "Enter description"
- Enter the description of the issue.
- Workbot should respond with "Enter assignee:"
- At this point, Workbot should have all the input he needs from the user to create the issue in Github. You should see the command reply next:
We've come to the end of this guide - you're awesome for making it this far.
You can make your command reply more interactive by including attachment fields fields, images, buttons, and even message menus. Buttons and menu options allow Workbot to pass commands back to a recipe to carry out its actions.
Explore other ways Workbot has automated tasks for our community of users in Community Recipes.