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
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: