Updating bot messages
So you’re an expert at posting messages to your users using Workbot – perhaps too good. Now your bots are spamming your users with long, prettyfied messages with all the bells & whistles supported by Slack’s interactive message framework.
Or maybe, your impatient users are spamming your buttons (or message menu options) before (or even after) a response is given to them.
Or perhaps you just want to allow your users to decide whether or not they want to see that wall-of-text your Workbot just returned from your Jira Confluence database.
Well, good news! Workbot allows you to update your messages – and there are 3 good reasons you may want to do so:
- You want to remove buttons or message menus after users have clicked or made their selection (to prevent spam!)
- You want to reduce clutter in your bot conversations by ‘re-using’ the same message
- You want to allow users to ‘expand’ or ‘collapse’ large message blocks
How it works
You can use Workbot’s Post message action to update existing bot messages. Each message posted in Slack comes with a Message ID in the Message to update field, displayed in the output of Workbot triggers & actions.
You can find this field in the ‘Advanced’ section of the Post message action.
You can find the Message ID datapills in the output of a Post message / Post command reply action, or a Post command trigger.
Wait… if Message ID corresponds to a Slack message, how can a Post command trigger have one?
Good question. Normally, the Post command trigger won’t have a Message ID (since there’s no message to update yet). However, if the trigger is invoked from a bot command of a message (e.g. a button or menu option click), the trigger’s Message ID will point to the message containing that button or menu option.
Using Message to update
When you’ve specified a Message ID, the original message will be replaced with the new message in this new Post message action, along with any interactive components (like buttons or message menus) it may have.
Removing buttons & message menus
You can replace buttons or message menus by having an ‘unmapped’ button in the updating Post message action.
An ‘unmapped’ button is one where the Submit button command does not match any command triggers of any Workbot recipes in your Workato account. This exploits the fact that ‘unmapped’ buttons are not displayed in a post message.
Can you update a message whose Message ID datapill sits in another recipe?
Yes you can! You’ll need to pass its message ID to the recipe that’s updating the message. In general, name-value pairs (up to 5 of them) can be passed on to other recipes by using the Command input values field.
There are 4 ways in which a message ID can be passed onto another recipe:
- Command input values in buttons (via a post command reply / post message action),
- Command input values in menu options (via a post command reply / post message action),
- Callback ID (via a post dialog action),
- Message ID of a post command trigger (as mentioned earlier, this corresponds to the message containing the button, menu option or dialog that triggers it)
The recipe that’s receiving the name-value pair must also have the fields defined in its command input fields.
You usually want to do this if you want to update messages (posted by a separate recipe) that has no buttons or message menus. Messages with no buttons or menus can’t pass their message IDs to a post command trigger – hence the need to pass it using the 4 methods shown above.
See it in action
There’s nothing like a good old example to showcase the powers of bot message updating. Check out this Jira Confluence – Workbot use case which showcases the power of updating bot messages!