Skip to content

Add context_team_id and context_enterprise_id to EnvelopedEvent type definition #2773

@FreQll

Description

@FreQll

Problem

We have a Slack bot that is installed across multiple customer workspaces. Recently, we noticed that some messages were being routed to the wrong inbox in our application. We determine which inbox a message belongs to based on the Slack settings teamId.
After investigation, we discovered that in Slack Connect scenarios (where our bot is available through a channel that appears as an external connection), the team_id field can return a different workspace's ID than where our bot is installed. The context_team_id field correctly identifies the workspace where the bot is running, but this field is not available in the EnvelopedEvent type definition.

The EnvelopedEvent type definition is missing the context_team_id and context_enterprise_id fields that Slack's Events API sends in webhook payloads.
These fields are documented at https://api.slack.com/enterprise/org-wide-apps#context-team-id and are essential for correctly identifying the workspace where an event originated, particularly in Slack Connect scenarios where team_id may refer to a different workspace than where the bot is installed.

Current behavior:

Accessing body.context_team_id requires type assertions or @ts-expect-error comments because the field isn't defined in the type.

Expected behavior:

context_team_id and context_enterprise_id should be typed as optional fields on EnvelopedEvent.


Suggested fix:

Add to the EnvelopedEvent type context_team_id:

// Add to the EnvelopedEvent type
context_team_id?: string,
context_enterprise_id?: string

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypeScript-specificauto-triage-skipPrevent this issue from being closed due to lack of activitybugM-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions