Documentation
¶
Overview ¶
This example shows how to handle both Events API and Interactions API using HTTP endpoints. It listens for messages (Events API), replies with a button (Block Kit), and handles the button click (Interactions API).
This is also a migration guide for users of slackevents.ParseActionEvent, which is deprecated because it cannot parse block_actions payloads. The correct approach is to use slack.InteractionCallback directly:
// Before (broken for block_actions): action, err := slackevents.ParseActionEvent(payload, slackevents.OptionNoVerifyToken()) // After (handles all interaction types): var ic slack.InteractionCallback err := json.Unmarshal([]byte(payload), &ic) // Use ic.ActionCallback.BlockActions for block actions // Use ic.ActionCallback.AttachmentActions for legacy attachment actions
Note: block_actions are delivered to your Interactivity Request URL, not your Events API Request URL. These are two separate endpoints in your Slack app configuration.
Setup:
- export SLACK_BOT_TOKEN=xoxb-...
- export SLACK_SIGNING_SECRET=...
- go run ./examples/parse_action_event
- Expose port 3000 with ngrok: ngrok http 3000
- In your Slack app config: - Events API Request URL: https://<ngrok>/events - Interactivity Request URL: https://<ngrok>/interactions - Subscribe to bot events: message.channels (so the bot can post) - Bot scopes: chat:write, channels:read
- Invite the bot to a channel, then send any message — the bot will reply with a message containing a block action button.
- Click the button and watch the logs.
Click to show internal directories.
Click to hide internal directories.