Skip to content

Slack: handle message.channels and message.groups events#31701

Merged
steipete merged 2 commits intoopenclaw:mainfrom
liuxiaopai-ai:fix/slack-typed-message-events-31674
Mar 2, 2026
Merged

Slack: handle message.channels and message.groups events#31701
steipete merged 2 commits intoopenclaw:mainfrom
liuxiaopai-ai:fix/slack-typed-message-events-31674

Conversation

@liuxiaopai-ai
Copy link

Summary

Testing

  • pnpm test src/slack/monitor/events/messages.test.ts
  • pnpm exec oxlint src/slack/monitor/events/messages.ts src/slack/monitor/events/messages.test.ts

Closes #31674

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

This PR addresses an issue where Slack channel and group messages were not being processed when Slack dispatched them using typed event names (message.channels and message.groups) instead of the generic message event. The fix cleanly refactors the existing message handler logic into a shared handleIncomingMessageEvent function and registers explicit handlers for both typed event types, ensuring all three event delivery styles route through the same processing pipeline.

Key changes:

  • Extracted message handling logic into handleIncomingMessageEvent to avoid code duplication
  • Registered explicit handlers for message.channels and message.groups events alongside the existing message handler
  • Added regression test coverage verifying both typed handlers are registered and forward events correctly
  • Updated CHANGELOG with fix entry for [Bug]: Slack connector needs message.channels handler for channel visibility #31674

Technical notes:

  • The typed handlers use SlackEventMiddlewareArgs without a type parameter since message.channels and message.groups aren't predefined event types in the Bolt TypeScript definitions
  • All message subtypes (message_changed, message_deleted, thread_broadcast) are handled consistently across all three event types through the shared function
  • The refactoring maintains backward compatibility while adding support for Slack's alternate event dispatch mechanism

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are straightforward and additive - registering additional event handlers without modifying existing behavior. The refactoring cleanly extracts shared logic to avoid duplication, test coverage validates the new handlers work correctly, and the implementation properly routes all event types through the same well-tested processing pipeline. No logical errors, security issues, or edge cases were found.
  • No files require special attention

Last reviewed commit: 4d5ebc2

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d5ebc225a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +105 to +108
ctx.app.event("message.channels", async ({ event, body }: SlackEventMiddlewareArgs) => {
await handleIncomingMessageEvent({ event, body });
});
ctx.app.event("message.groups", async ({ event, body }: SlackEventMiddlewareArgs) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Register typed DM message events too

This patch only adds listeners for message.channels and message.groups, but the same typed-dispatch mode also uses message.im and message.mpim for DM/MPIM subscriptions (which are still listed in our Slack setup docs). In workspaces where Bolt routes by these typed names, DM and group-DM messages will continue to bypass handleIncomingMessageEvent, so inbound Slack conversations can still be dropped even after this fix.

Useful? React with 👍 / 👎.

@steipete steipete merged commit 0630650 into openclaw:main Mar 2, 2026
23 of 25 checks passed
@steipete
Copy link
Contributor

steipete commented Mar 2, 2026

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test (test suite currently has 2 unrelated failures in src/process/exec.test.ts)
  • Land commit: 5efb970
  • Merge commit: 0630650

Thanks @liuxiaopai-ai!

steipete added a commit to liuxiaopai-ai/openclaw that referenced this pull request Mar 2, 2026
eveiljuice pushed a commit to eveiljuice/openclaw-II that referenced this pull request Mar 2, 2026
Linux2010 pushed a commit to Linux2010/openclaw that referenced this pull request Mar 2, 2026
mahopan added a commit to mahopan/openclaw that referenced this pull request Mar 2, 2026
…h Bolt 4.6

Bolt 4.6 rejects app.event() calls with event names starting with
"message." (e.g. "message.channels", "message.groups"), throwing
AppInitializationError on startup. These handlers were added in openclaw#31701
based on the incorrect assumption that Slack dispatches typed event
names to Bolt. In reality, Slack always delivers events with
type:"message" regardless of the Event Subscription name; the
channel_type field distinguishes the source.

The generic app.event("message") handler already receives all channel,
group, IM, and MPIM messages. The additional typed handlers were
unreachable even if Bolt allowed them, since no event payload ever
carries type:"message.channels".

This preserves the handleIncomingMessageEvent refactor from openclaw#31701
(extracting the handler into a named function) while removing only
the broken registrations.

Fixes the Slack provider crash loop affecting all accounts on
@slack/bolt >= 4.6.0.

Closes openclaw#31674 (original issue was not caused by missing handlers)
mahopan added a commit to mahopan/openclaw that referenced this pull request Mar 2, 2026
…h Bolt 4.6

Bolt 4.6 rejects app.event() calls with event names starting with
"message." (e.g. "message.channels", "message.groups"), throwing
AppInitializationError on startup. These handlers were added in openclaw#31701
based on the incorrect assumption that Slack dispatches typed event
names to Bolt. In reality, Slack always delivers events with
type:"message" regardless of the Event Subscription name; the
channel_type field distinguishes the source.

The generic app.event("message") handler already receives all channel,
group, IM, and MPIM messages. The additional typed handlers were
unreachable even if Bolt allowed them, since no event payload ever
carries type:"message.channels".

This preserves the handleIncomingMessageEvent refactor from openclaw#31701
(extracting the handler into a named function) while removing only
the broken registrations.

Fixes the Slack provider crash loop affecting all accounts on
@slack/bolt >= 4.6.0.

Closes openclaw#31674 (original issue was not caused by missing handlers)
steipete pushed a commit to mahopan/openclaw that referenced this pull request Mar 2, 2026
…h Bolt 4.6

Bolt 4.6 rejects app.event() calls with event names starting with
"message." (e.g. "message.channels", "message.groups"), throwing
AppInitializationError on startup. These handlers were added in openclaw#31701
based on the incorrect assumption that Slack dispatches typed event
names to Bolt. In reality, Slack always delivers events with
type:"message" regardless of the Event Subscription name; the
channel_type field distinguishes the source.

The generic app.event("message") handler already receives all channel,
group, IM, and MPIM messages. The additional typed handlers were
unreachable even if Bolt allowed them, since no event payload ever
carries type:"message.channels".

This preserves the handleIncomingMessageEvent refactor from openclaw#31701
(extracting the handler into a named function) while removing only
the broken registrations.

Fixes the Slack provider crash loop affecting all accounts on
@slack/bolt >= 4.6.0.

Closes openclaw#31674 (original issue was not caused by missing handlers)
steipete added a commit that referenced this pull request Mar 2, 2026
…h Bolt 4.6 (#32033)

* fix(slack): remove message.channels/message.groups handlers that crash Bolt 4.6

Bolt 4.6 rejects app.event() calls with event names starting with
"message." (e.g. "message.channels", "message.groups"), throwing
AppInitializationError on startup. These handlers were added in #31701
based on the incorrect assumption that Slack dispatches typed event
names to Bolt. In reality, Slack always delivers events with
type:"message" regardless of the Event Subscription name; the
channel_type field distinguishes the source.

The generic app.event("message") handler already receives all channel,
group, IM, and MPIM messages. The additional typed handlers were
unreachable even if Bolt allowed them, since no event payload ever
carries type:"message.channels".

This preserves the handleIncomingMessageEvent refactor from #31701
(extracting the handler into a named function) while removing only
the broken registrations.

Fixes the Slack provider crash loop affecting all accounts on
@slack/bolt >= 4.6.0.

Closes #31674 (original issue was not caused by missing handlers)

* fix: document Slack Bolt 4.6 startup handler fix (#32033) (thanks @mahopan)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
execute008 pushed a commit to execute008/openclaw that referenced this pull request Mar 2, 2026
execute008 pushed a commit to execute008/openclaw that referenced this pull request Mar 2, 2026
…h Bolt 4.6 (openclaw#32033)

* fix(slack): remove message.channels/message.groups handlers that crash Bolt 4.6

Bolt 4.6 rejects app.event() calls with event names starting with
"message." (e.g. "message.channels", "message.groups"), throwing
AppInitializationError on startup. These handlers were added in openclaw#31701
based on the incorrect assumption that Slack dispatches typed event
names to Bolt. In reality, Slack always delivers events with
type:"message" regardless of the Event Subscription name; the
channel_type field distinguishes the source.

The generic app.event("message") handler already receives all channel,
group, IM, and MPIM messages. The additional typed handlers were
unreachable even if Bolt allowed them, since no event payload ever
carries type:"message.channels".

This preserves the handleIncomingMessageEvent refactor from openclaw#31701
(extracting the handler into a named function) while removing only
the broken registrations.

Fixes the Slack provider crash loop affecting all accounts on
@slack/bolt >= 4.6.0.

Closes openclaw#31674 (original issue was not caused by missing handlers)

* fix: document Slack Bolt 4.6 startup handler fix (openclaw#32033) (thanks @mahopan)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
dawi369 pushed a commit to dawi369/davis that referenced this pull request Mar 3, 2026
dawi369 pushed a commit to dawi369/davis that referenced this pull request Mar 3, 2026
…h Bolt 4.6 (openclaw#32033)

* fix(slack): remove message.channels/message.groups handlers that crash Bolt 4.6

Bolt 4.6 rejects app.event() calls with event names starting with
"message." (e.g. "message.channels", "message.groups"), throwing
AppInitializationError on startup. These handlers were added in openclaw#31701
based on the incorrect assumption that Slack dispatches typed event
names to Bolt. In reality, Slack always delivers events with
type:"message" regardless of the Event Subscription name; the
channel_type field distinguishes the source.

The generic app.event("message") handler already receives all channel,
group, IM, and MPIM messages. The additional typed handlers were
unreachable even if Bolt allowed them, since no event payload ever
carries type:"message.channels".

This preserves the handleIncomingMessageEvent refactor from openclaw#31701
(extracting the handler into a named function) while removing only
the broken registrations.

Fixes the Slack provider crash loop affecting all accounts on
@slack/bolt >= 4.6.0.

Closes openclaw#31674 (original issue was not caused by missing handlers)

* fix: document Slack Bolt 4.6 startup handler fix (openclaw#32033) (thanks @mahopan)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
dawi369 pushed a commit to dawi369/davis that referenced this pull request Mar 3, 2026
dawi369 pushed a commit to dawi369/davis that referenced this pull request Mar 3, 2026
…h Bolt 4.6 (openclaw#32033)

* fix(slack): remove message.channels/message.groups handlers that crash Bolt 4.6

Bolt 4.6 rejects app.event() calls with event names starting with
"message." (e.g. "message.channels", "message.groups"), throwing
AppInitializationError on startup. These handlers were added in openclaw#31701
based on the incorrect assumption that Slack dispatches typed event
names to Bolt. In reality, Slack always delivers events with
type:"message" regardless of the Event Subscription name; the
channel_type field distinguishes the source.

The generic app.event("message") handler already receives all channel,
group, IM, and MPIM messages. The additional typed handlers were
unreachable even if Bolt allowed them, since no event payload ever
carries type:"message.channels".

This preserves the handleIncomingMessageEvent refactor from openclaw#31701
(extracting the handler into a named function) while removing only
the broken registrations.

Fixes the Slack provider crash loop affecting all accounts on
@slack/bolt >= 4.6.0.

Closes openclaw#31674 (original issue was not caused by missing handlers)

* fix: document Slack Bolt 4.6 startup handler fix (openclaw#32033) (thanks @mahopan)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
OWALabuy pushed a commit to kcinzgg/openclaw that referenced this pull request Mar 4, 2026
OWALabuy pushed a commit to kcinzgg/openclaw that referenced this pull request Mar 4, 2026
…h Bolt 4.6 (openclaw#32033)

* fix(slack): remove message.channels/message.groups handlers that crash Bolt 4.6

Bolt 4.6 rejects app.event() calls with event names starting with
"message." (e.g. "message.channels", "message.groups"), throwing
AppInitializationError on startup. These handlers were added in openclaw#31701
based on the incorrect assumption that Slack dispatches typed event
names to Bolt. In reality, Slack always delivers events with
type:"message" regardless of the Event Subscription name; the
channel_type field distinguishes the source.

The generic app.event("message") handler already receives all channel,
group, IM, and MPIM messages. The additional typed handlers were
unreachable even if Bolt allowed them, since no event payload ever
carries type:"message.channels".

This preserves the handleIncomingMessageEvent refactor from openclaw#31701
(extracting the handler into a named function) while removing only
the broken registrations.

Fixes the Slack provider crash loop affecting all accounts on
@slack/bolt >= 4.6.0.

Closes openclaw#31674 (original issue was not caused by missing handlers)

* fix: document Slack Bolt 4.6 startup handler fix (openclaw#32033) (thanks @mahopan)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…h Bolt 4.6 (openclaw#32033)

* fix(slack): remove message.channels/message.groups handlers that crash Bolt 4.6

Bolt 4.6 rejects app.event() calls with event names starting with
"message." (e.g. "message.channels", "message.groups"), throwing
AppInitializationError on startup. These handlers were added in openclaw#31701
based on the incorrect assumption that Slack dispatches typed event
names to Bolt. In reality, Slack always delivers events with
type:"message" regardless of the Event Subscription name; the
channel_type field distinguishes the source.

The generic app.event("message") handler already receives all channel,
group, IM, and MPIM messages. The additional typed handlers were
unreachable even if Bolt allowed them, since no event payload ever
carries type:"message.channels".

This preserves the handleIncomingMessageEvent refactor from openclaw#31701
(extracting the handler into a named function) while removing only
the broken registrations.

Fixes the Slack provider crash loop affecting all accounts on
@slack/bolt >= 4.6.0.

Closes openclaw#31674 (original issue was not caused by missing handlers)

* fix: document Slack Bolt 4.6 startup handler fix (openclaw#32033) (thanks @mahopan)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Slack connector needs message.channels handler for channel visibility

2 participants