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

Config

slack.config({
  tokens: {
    TEAM_ID: "xoxb-your-bot-token",
  },
});
OptionDescription
tokensA map of team ID to bot token (xoxb-...). At least one entry is required.
teamsOptional metadata per team: app ID, bot user ID, granted scopes, and display name.
endpointOptional custom Slack API base URL.

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}`);
  }
}