Skip to main content
Use slack.config(...) to register one or more Slack workspaces.

Config

slack.config({
  tokens: {
    TEAM_ID: "xoxb-your-bot-token",
  },
});
OptionDescriptionEnv fallback
tokensA map of team ID to bot token (xoxb-...). At least one entry is required.— (record, code-only)
teamsOptional metadata per team: app ID, bot user ID, granted scopes, and display name.— (record, code-only)
endpointOptional custom Slack API base URL.SPECTRUM_SLACK_ENDPOINT
endpoint falls back to SPECTRUM_SLACK_ENDPOINT when omitted (an explicit value wins). tokens and teams are maps, so they stay in code — for a fully environment-driven setup, use cloud mode (an empty slack.config({})) with projectId/projectSecret.

Example

import { Spectrum } from "spectrum-ts";
import { slack } from "spectrum-ts/providers/slack";

const app = await Spectrum({
  projectId: process.env.PROJECT_ID!,
  projectSecret: process.env.PROJECT_SECRET!,
  providers: [
    slack.config({
      tokens: { TEAM_ID: process.env.SLACK_BOT_TOKEN! },
    }),
  ],
});

for await (const [space, message] of app.messages) {
  if (message.content.type === "text") {
    await space.send(`Echo: ${message.content.text}`);
  }
}