Skip to content

fix(automations): Run Slack channel automations on bot posts that have no user - #3213

Merged
dcramer merged 6 commits into
mainfrom
fix/slack-bot-id-channel-automations
Nov 12, 2026
Merged

dcramer merged 6 commits into
mainfrom
fix/slack-bot-id-channel-automations

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Some app integrations, such as HackerOne, post bot_message events that have a bot_id and no user. Since #1936, isSlackWorkspaceMember returns false for these events, so the webhook drops them before channel-message automations can match. Because of this, #2197's match.user_id cannot name these bots. A channel-message automation filtered on HackerOne's bot ID has had zero runs.

This change adds a narrow path for these posts. Per review, it uses a workspace + bot check, not an allowlist.

  • Channel scope: slackChannelScope reads the signed envelope once. A workspace channel needs is_ext_shared_channel: false, context_team_id equal to team_id, and no context_enterprise_id (callback fields). Any other envelope is unknown and drops the post. An Enterprise Grid install drops these posts too.
  • Bot check: slackWorkspaceBotId sits next to isSlackWorkspaceMember and uses the same cache TTLs:
    • If the event has bot_profile, its id must match bot_id, its team_id must be this workspace, and it must not be deleted. No lookup.
    • Otherwise, bots.info must return the bot, not deleted. If the bot has a user_id, users.info must return a bot user in this workspace that is not deleted.
    • A classic integration has no bot user, so it is accepted on the channel scope alone. Production spans suggest HackerOne (B09LC7U21UG) is this case.
  • Automations only: these posts never start a Turn. A post that mentions Junior runs nothing, the same as a mention from a person.
  • Exact opt-in: only automations that name the bot ID in match.user_id run. The Event gets a typed author ({ kind: "bot", botId }), so the summary no longer guesses the kind from the ID's format. Member posts and bot posts share one ingest helper.

Link previews read the same channel scope and skip only external. Their behavior does not change.

slack.message.ingress now records app.slack.context_team_id and app.slack.context_enterprise_id, so a dropped bot post can be traced to its envelope.

#2034 is still open. This PR answers it only for channel-message automations and leaves Workflow mentions as they are.

via @markatsentry, @dcramer.

--

View Session [Sentry]

…e no user

App integrations such as HackerOne post bot_message events with a bot_id
and no user. The workspace member check drops them before channel-message
automations can match, so match.user_id cannot name these bots.

Accept these posts only in channels that Slack marks as not shared with
another organization, and send them only to channel-message automations
that name the bot ID. They never start a Turn.

Refs #2034

Co-Authored-By: Mark Collao <[email protected]>
@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 12, 2026 5:49pm UTC

Request Review

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

15 screenshot changes — 15 changed · 0 added · 0 removed

Review screenshots in Frameshift

Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automation Skill Editor · Desktop
Automation Skill Editor · Desktop
Changed
Automation Skill Editor · Mobile
Automation Skill Editor · Mobile
Changed
Automations Runs Filters · Desktop
Automations Runs Filters · Desktop
Changed
Conversation Attachment Zoom · Desktop
Conversation Attachment Zoom · Desktop
Changed
Conversation Attachment Zoom · Mobile
Conversation Attachment Zoom · Mobile
Changed
Show 9 more changed screenshots
Conversation Captured Memories Popover · Desktop
Conversation Captured Memories Popover · Desktop
Changed
Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Object Links · Desktop
Conversation Object Links · Desktop
Changed
Conversation Question Stepper · Desktop
Conversation Question Stepper · Desktop
Changed
Conversation Question Stepper Light · Desktop
Conversation Question Stepper Light · Desktop
Changed
Conversation Share Details · Desktop
Conversation Share Details · Desktop
Changed
Push Notifications Tip · Desktop
Push Notifications Tip · Desktop
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

@markatsentry
markatsentry marked this pull request as ready for review November 11, 2026 21:35
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 11, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Share the mention check between Turn routing and workspace bot posts, so
a bot post that mentions Junior only in a section block also runs no
channel-message automation.
Read the channel scope once from the signed envelope: a workspace channel
needs is_ext_shared_channel false, context_team_id equal to team_id, and no
context_enterprise_id. Link previews and bot posts both use it.

Verify the bot next to the member check. A bot_profile must name this
workspace. Without one, bots.info must return a live bot, and its bot user,
when it has one, must belong to this workspace. Pass a typed author to the
channel-message Event, and share one ingest helper with member posts.

Co-Authored-By: David Cramer <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 88fdb51. Configure here.

@dcramer

dcramer commented Nov 11, 2026

Copy link
Copy Markdown
Member

if we know about grid, can we just efault grid to a safe mode of operating?

…nel-automations

# Conflicts:
#	packages/junior/tests/integration/slack/channel-message-automations.test.ts
…fe mode

On Enterprise Grid, Slack sets context_enterprise_id on every event, so
bot posts with no user never ran channel-message automations. Read a Grid
channel in this workspace as the enterprise scope. There, accept a bot post
only when Slack names this workspace as the bot's, in bot_profile or through
the bot user of bots.info. A classic integration with no bot user runs
nothing, because another workspace of the org could post in an org-shared
channel.
@sentry-junior

sentry-junior Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Yes. Done in 5abf3a4.

  • slackChannelScope returns a new enterprise scope when context_enterprise_id matches the envelope's enterprise_id, context_team_id === team_id, and the channel is not externally shared. An enterprise ID that does not match still gives unknown.
  • In the enterprise scope, a bot post runs automations only when Slack names this workspace as the bot's workspace. That comes from bot_profile.team_id, or from the bot user that bots.info returns. A classic integration with no bot user runs nothing on Grid, because a bot from another workspace in the org could post in an org-shared channel. Outside Grid, classic integrations still work as before.
  • The bots.info cache now stores bot_user / classic / none in place of a boolean, so one cached entry works for both scopes.
  • Tests: a Grid bot post with a bot_profile from this workspace runs. A Grid classic integration does not run, and neither does a mismatched enterprise ID. The new Grid case fails without the change.

A correction to my earlier reply: link previews only reject external, so the Grid rule never affected them.

I also merged main to fix the conflict in channel-message-automations.test.ts (#3212 added text, and both sides are kept). The Slack integration and component tests, typecheck, and lint pass.

@dcramer

dcramer commented Nov 12, 2026

Copy link
Copy Markdown
Member

Do one more pass here. Is any of this code that can be standardized elsewhere? Want to make sure we're not duplicating access checks or other behavior.

A bot user from bots.info now goes through the same cached users.info
membership check as any other author, so the team and deleted rules live
in one place. The bot cache stores only what bots.info says about the bot.
Move lookupSlackBot next to lookupSlackUserProfile, and the text and block
mention check next to textMentionsBot.
@sentry-junior

sentry-junior Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

I made one more pass for duplication. The fixes are in f36d306.

Consolidated

  • Membership check. The bot path had its own copy of the users.info check: same team, not deleted, its own cache key. Now a bot user from bots.info goes through the same cached check that isSlackWorkspaceMember uses (slack:membership:<team>:<user>). The team and deleted rules are in one place, and a person or bot user is looked up once. The bot cache (slack:bot:<team>:<bot>) now stores only what bots.info returns: bot_user + user ID, classic, or none. I dropped the extra is_bot check. bots.info already says this is the bot's user.
  • lookupSlackBot moved to chat/slack/users.ts, next to lookupSlackUserProfile, with the same withSlackRetries / SlackActionError handling.
  • eventMentionsBot (text + section blocks) moved to ingress/bot-mention.ts, next to textMentionsBot. Turn routing and the bot path both use it.

Checked, nothing to share

  • slackChannelScope is the only reader of is_ext_shared_channel / context_* besides telemetry. Link previews and bot posts both use it.
  • checkSlackChannelReadAccess (conversations.info) is a different check: whether a channel is public or readable, not who can post in it. So I did not merge the two.
  • ingestChannelMessage is already the one ingest path for posts from people and from bots.
  • Telemetry keeps its own ID regexes, the same way the other fields in slack-message-telemetry.ts do.

Typecheck and lint pass, and so do the Slack integration, component and unit tests (284 files).

@dcramer
dcramer merged commit 2e5c86a into main Nov 12, 2026
45 checks passed
@dcramer
dcramer deleted the fix/slack-bot-id-channel-automations branch November 12, 2026 18:07

This branch was successfully deployed

1 active deployment
Preview – junior-docs — f36d3069 Deployed Nov 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants