@mastra/core
Version:
78 lines (53 loc) • 2.78 kB
Markdown
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
# Channels
> **Note:** The Agent Builder is part of the Mastra Enterprise Edition. Production deployments require a valid EE license. [Contact sales](https://mastra.ai/contact) for more information.
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**:
```bash
npm install @mastra/slack
```
**pnpm**:
```bash
pnpm add @mastra/slack
```
**Yarn**:
```bash
yarn add @mastra/slack
```
**Bun**:
```bash
bun add @mastra/slack
```
Register `SlackProvider` on `Mastra.channels`:
```typescript
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](https://api.slack.com/apps). The refresh token doesn't expire, but the access tokens it issues rotate every 12 hours and are auto-persisted to `Mastra.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:4111` in local development). Pass `baseUrl` explicitly 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.
## Related
- [Deploying](https://mastra.ai/docs/agent-builder/deploying): Set a public `baseUrl` for production deployments.
- [Configuration](https://mastra.ai/docs/agent-builder/configuration): Wire channel toggles into the Builder UI.