Slack bots2 minutes to read

Add Slack buttons and modals to a hosted Bolt bot

Wire a Block Kit button to a Bolt modal. Enable interactivity, match action and callback IDs, and test acknowledgments from Slack.

Give the button a stable action ID

Start with the hosted slash command test and enable Interactivity in the app’s Slack settings. For Socket Mode, interactions arrive over the existing connection. In HTTP mode, register the correct interactivity Request URL for the Bolt receiver.

Reply to the command with a Block Kit message containing a button. Give the button an action_id such as open_issue_form. Register an action handler for that exact ID. Test that a click reaches the handler and record its action ID without logging the interaction payload.

Open the modal during the interaction

Acknowledge the button interaction promptly. Call views.open using the interaction’s trigger_id before it expires. Slack trigger IDs are short-lived, so make this call before any slow ticket lookup or database operation. Give the modal its own callback_id and register a view submission handler for that ID.

For a submission, validate the fields and acknowledge using Bolt’s view submission options. Show field-specific errors for invalid data and save accepted records under the proper workspace. Opening modals with Bolt for JavaScript.

Test one complete interaction in a private channel

  1. Deploy the updated worker and stop local test copies of the same Slack app.
  2. Invoke the command, click the button and submit a known test value. Confirm the expected response and stored result.
  3. If the button appears but the modal stays closed, check interactivity settings, action ID, and the time before views.open. If submission fails, check the callback ID and response to that submission.

When the form creates a ticket or performs another external action, make the action safe to retry. For a modal submission, use a stable operation key from your own form state rather than assuming a Slack Events API ID will be present.