parse_action_event

command
v0.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: BSD-2-Clause Imports: 8 Imported by: 0

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:

  1. export SLACK_BOT_TOKEN=xoxb-...
  2. export SLACK_SIGNING_SECRET=...
  3. go run ./examples/parse_action_event
  4. Expose port 3000 with ngrok: ngrok http 3000
  5. 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
  6. Invite the bot to a channel, then send any message — the bot will reply with a message containing a block action button.
  7. Click the button and watch the logs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL