You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Slack adapter: expose the installation a delivery was resolved through to handlers #1058
With an installationProvider, the adapter resolves an installation for each delivery (from authorizations[0].team_id / team_id, or the enterprise id for org-wide installs) and keeps it, with its bot token, in the adapter's own per-delivery store: the protected readonly requestContext: AsyncLocalStorage<{ token, installationId, teamId, enterpriseId, isEnterpriseInstall, botUserId, ... }> field on SlackAdapter. Handlers (onNewMention, onSubscribedMessage, onAction, ...) cannot read it.
A multi-workspace app usually needs exactly that inside a handler: which installation (tenant) this message came through, and that installation's bot token for its own Slack Web API calls. The alternatives available to handlers are wrong or costly:
message.raw.team is the sender's team. In a Slack Connect channel it is another company's workspace, not the one the app is installed in.
Looking the installation up again by team id means another getInstallation round trip per message, and still needs the right team id first.
Ask: a public way for a handler to get the current delivery's installation (id and bot token), for example a getter on the adapter.
Related: #874 (the suggestedPrompts resolver missing teamId on one path), the same gap in a different place.
Workaround today
Subclass SlackAdapter and add a public getter over that field (this.requestContext.getStore()), then reach the adapter through thread.adapter in handlers. It depends on a protected field and its shape, so a test has to guard it against adapter upgrades.
Activity