Channels
Channels let Builder-created agents reach users outside the Mastra server. Register a channel provider on Mastra.channels and the Builder exposes the channel as an integration option for every agent.
Slack is currently the only supported channel.
Quickstart
Install the Slack provider:
- npm
- pnpm
- Yarn
- Bun
npm install @mastra/slackpnpm add @mastra/slackyarn add @mastra/slackbun add @mastra/slackRegister SlackProvider on Mastra.channels:
src/mastra/index.ts
import { Mastra } from '@mastra/core/mastra'
import { MastraEditor } from '@mastra/editor'
import { createBuilderAgent } from '@mastra/editor/ee'
import { SlackProvider } from '@mastra/slack'
export const mastra = new Mastra({
storage,
channels: {
slack: new SlackProvider({
refreshToken: process.env.SLACK_APP_CONFIG_REFRESH_TOKEN,
baseUrl: process.env.SLACK_BASE_URL,
}),
},
agents: { builderAgent: createBuilderAgent() },
editor: new MastraEditor({
builder: { enabled: true },
}),
})The Slack provider handles app creation, OAuth, slash commands, and message routing for every Builder-created agent that opts in.
Configuration
SlackProvider requires one environment variable and accepts one optional override:
SLACK_APP_CONFIG_REFRESH_TOKEN(required): The refresh token from your Slack app configuration tokens, available under Your App Configuration Tokens on api.slack.com/apps. The refresh token doesn't expire, but the access tokens it issues rotate every 12 hours and are auto-persisted toMastra.storage.baseUrl(optional): The public URL Slack should send events and OAuth callbacks to. Defaults to the running Mastra server's host and port (for example,http://localhost:4111in local development). PassbaseUrlexplicitly when the public URL differs from the server's resolved address: typically a tunnel for local development (cloudflared tunnel --url http://localhost:4111) or a deployed URL in production.
Storage requirement
SlackProvider requires a persistent storage backend on the Mastra instance. Without storage, rotated tokens and app installations are lost on restart.