How to combine slash commands, buttons and dialogs for a menu?

1.7k views Asked by At

My Slack app is started with a slash command, which then posts an ephemeral menu message to the user. That menu has some information and three message buttons.

Example:

enter image description here

  • First button allows the user to close the menu
  • Second button allows the user to start an action
  • Third button allows the user to open a dialog for changing options.

After the user submits the dialog I want to update the menu message to reflect the changes made in the dialog.

However, after the user submits the dialog I can no longer to update the message menu by responding to a Slack response as before.

How can I update the menu message with the changes?

1

There are 1 answers

0
Erik Kalkoken On BEST ANSWER

In order to keep the connection with the initial slash command one needs to store the response_url of the last interactive action before opening the dialog.

In this example it will be in the interactive action request initiated after pressing the "Options" button. That response_url allows one to seamlessly continue the conversation that was started with the initial slash command.

The easiest approach for storing the response_url is to put it into the state property of the dialog, which will automatically be echoed back to the app with the dialog submission request.

One needs to be careful not to confuse the response_url from the interactive action with the response_url from the dialog.

Also, the dialog cancel case is automatically handled, since in that case the user can continue working with the initial menu message.