← Back to library

Slack 按钮点击无回流:为 block_actions 建立可执行路由链路

问题/场景:Slack Block Kit 按钮能显示但点击后代理收不到事件,审批流停在“可见不可用”。前置条件:已启用 Slack Socket Mode,且机器人具备消息与交互权限。实施步骤:在插件层接收 `block_actions`→提取 `action_id/value/channel/user`→转成 session 消息或 system event→按按钮动作分支处理。关键配置:交互 payload 路由与会话映射。验证:点击按钮后 1 个会话周期内产生可追踪动作。风险:未做幂等会导致按钮重复触发。

GITHUBDiscovered 2026-02-19Author jakejeffery
Prerequisites
  • Slack app has interactivity enabled and Socket Mode already connected to OpenClaw gateway.
  • A session mapping strategy exists (channel/user to target session).
Steps
  1. Send a test Block Kit message with at least two buttons containing stable `action_id` values.
  2. In Slack plugin action handler, parse `block_actions` payload and extract action metadata + actor context.
  3. Route click event into the right session as normalized text/event (e.g. `[button:post_draft] value=target-channel`).
  4. Add idempotency key per click (`message_ts + action_id + user`) to avoid duplicate execution.
  5. Record audit logs for decision actions (post/edit/discard) and keep rollback path for destructive operations.
Commands
openclaw gateway status
openclaw gateway restart
openclaw status
Verify

Button click appears as actionable event in target session and triggers the expected branch exactly once.

Caveats
  • Event schema may evolve with Slack SDK updates; validate payload keys before parsing(需验证).
  • Do not route privileged buttons directly to destructive actions without confirmation gate.
Source attribution

This tip is aggregated from community/public sources and preserved with attribution.

Open original source ↗
Visit original post