Skip to content

fix(types): add context_team_id and context_enterprise_id to EnvelopedEvent (closes #2773)#2976

Open
tsushanth wants to merge 2 commits into
slackapi:mainfrom
tsushanth:fix/enveloped-event-context-team-id
Open

fix(types): add context_team_id and context_enterprise_id to EnvelopedEvent (closes #2773)#2976
tsushanth wants to merge 2 commits into
slackapi:mainfrom
tsushanth:fix/enveloped-event-context-team-id

Conversation

@tsushanth

Copy link
Copy Markdown

Summary

Closes #2773. Adds the two Enterprise Grid / Slack Connect context fields that Slack's Events API delivers on the envelope but the type didn't surface.

In Slack Connect channels and Enterprise Grid org-wide apps, body.team_id can identify a workspace different from the one the bot is installed in. Slack solves this by also sending context_team_id (and its enterprise counterpart context_enterprise_id), which always identify the workspace where the bot is actually running. Reporter (@FreQll) hit this when messages from Slack Connect channels were being routed to the wrong inbox.

Before this PR, accessing those fields on body required @ts-expect-error or an unsafe cast because the EnvelopedEvent interface only declared team_id / enterprise_id. The StringIndexed index signature on the interface meant the access would silently return any, defeating type safety.

What changed

  • src/types/events/index.ts — added context_team_id?: string and context_enterprise_id?: string to EnvelopedEvent, with JSDoc pointing at the Enterprise Grid docs so the next reader doesn't have to guess when these are sent.
  • test/types/event.test-d.ts — tsd assertions on body.context_team_id / body.context_enterprise_id so the fields are exercised as string | undefined and can't silently regress into any via the StringIndexed fallback. The test fails on the unpatched source with `Parameter type string | undefined is not identical to argument type any` for both new assertions.

Notes

  • Type-only addition; no runtime change, no behavior change for existing callers.
  • Both fields are optional — they're absent on classic single-workspace event deliveries and present on cross-workspace / org-wide ones, per Slack's docs.
  • `npm test` (build + Biome + tsd + mocha + coverage) passes locally.

Requirements

…dEvent (closes slackapi#2773)

Slack's Events API delivers `context_team_id` and `context_enterprise_id`
on the envelope for Slack Connect channels and Enterprise Grid org-wide
apps, where `team_id` may refer to a workspace different from the one
the bot is installed in. Without these fields on the `EnvelopedEvent`
type, downstream code that routes by workspace had to reach for
`@ts-expect-error` or unsafe casts (issue slackapi#2773).

Adds both fields as optional `string` with JSDoc pointing at the
Enterprise Grid docs, and a tsd regression test on `body.context_team_id`
/ `body.context_enterprise_id` so the field shapes can't silently
regress to `any` via the `StringIndexed` index signature.

No runtime change; pure type surface addition.
@tsushanth tsushanth requested a review from a team as a code owner June 15, 2026 18:19
@salesforce-cla

Copy link
Copy Markdown

Thanks for the contribution! Before we can merge this, we need @tsushanth to sign the Salesforce Inc. Contributor License Agreement.

@changeset-bot

changeset-bot Bot commented Jun 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 65a00ce

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@slack/bolt Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add context_team_id and context_enterprise_id to EnvelopedEvent type definition

1 participant