slack
A Slack channel.
Pass it as host({channels: {slack: slack({...})}}). Requests are verified with the signing secret; a message becomes a run of agent, and its reply is posted in the same conversation. Secrets are resolved on the host at ready().
Import from @threads/slack (TypeScript) or threads.slack (Python).
function slack(options: {
agent: string;
signingSecret: Secret;
botToken: Secret;
botUserId?: string;
tenant?: string | ((teamId: string) => string | undefined);
now?: () => number;
fetch?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
}): ChannelAdapterParameters
agentstringrequiredThe key of host({agents}) this channel routes to. invalid_config: the channel's agent must be a key of host({ agents }).
signingSecret / signing_secretSecretrequiredThe Slack app's signing secret, which verifies every request. Unset at ready() is missing_secret. See Secret.
botToken / bot_tokenSecretrequiredThe bot token (xoxb-...) replies are posted with. Unset at ready() is missing_secret. See Secret.
botUserId / bot_user_idstringThe bot's own user id: its messages are ignored. Omitted: messages Slack marks as from a bot are ignored, which covers the bot's own.
tenantstring | ((teamId: string) => string | undefined)TypeScript only. The tenant for a workspace, or a function mapping a team id to one (undefined refuses that workspace). Omitted: slack:<team_id>. In Python each channel is slack:<team_id>.
tenant(teamId)stringrequiredTypeScript only. The Slack team (workspace) id the request came from.
now() => numberTypeScript only. Seam: the clock the request timestamp is checked against, in milliseconds (tests). Omitted: Date.now.
fetch(input: string | URL | Request, init?: RequestInit) => Promise<Response>TypeScript only. Seam: the fetch replies are sent through (tests); the run's fence wraps it either way. Omitted: the process's fetch.
apistrdefault https://slack.com/apiPython only. Seam: the Slack Web API base URL (tests point it at a fake).
transporthttpx.AsyncBaseTransportPython only. Seam: the httpx transport replies are sent through (tests); the run's fence wraps it either way. Omitted: httpx's default.
Returns
Throws ConfigError with one of these codes: invalid_config, missing_secret.