Yes. Mastra agents connect to Chat SDK through Mastra's channels feature, which lets a single agent respond to messages on Slack, Discord, Telegram, and other platforms without custom webhook code. You configure a Chat SDK adapter on the agent, point the platform at a generated webhook URL, and the agent handles mentions, direct messages, and thread replies through its normal pipeline. This gives you Mastra's memory, tools, and workflows combined with Chat SDK's multi-platform messaging layer.
Copy link to headingOverview
Mastra and Chat SDK integrate through Mastra channels, a feature added in @mastra/core@1.22.0 that accepts Chat SDK adapters directly on the Agent constructor. Chat SDK provides the messaging layer (platform adapters, webhooks, streaming, interactive cards) while Mastra provides the agent layer (instructions, memory, tools, workflows). Together they let one agent hold conversations across Slack, Discord, Telegram, and other platforms with a few lines of configuration. The sections below cover how the integration works, when to use channels versus Chat SDK directly, and what to configure for serverless deployment on Vercel.
Copy link to headingWhat are Chat SDK and Mastra?
Chat SDK is a unified TypeScript SDK for building chatbots across messaging platforms, including Slack, Microsoft Teams, Google Chat, Discord, Telegram, GitHub, Linear, and WhatsApp Business Cloud. Each platform has an adapter (published under the @chat-adapter/ npm scope) that handles webhook verification, message parsing, and API calls, so your bot logic stays platform-agnostic.
Mastra is an open-source TypeScript framework for building AI agents, built on top of the AI SDK. It provides agent primitives, memory, tool calling, workflows, and RAG pipelines.
The two solve different problems: Chat SDK handles where your bot talks, and Mastra handles how your agent thinks. Mastra's channels feature connects them.
Copy link to headingHow Mastra channels work with Chat SDK
Mastra channels, added in @mastra/core@1.22.0, accept Chat SDK adapters directly on the Agent constructor. When a user sends a message on a connected platform, the agent receives it, processes it through the standard agent pipeline (memory, tools, model), and streams the response back to the conversation.
Configure a channel by passing an adapter to the channels property:
import { Agent } from '@mastra/core/agent'import { createSlackAdapter } from '@chat-adapter/slack'
export const supportAgent = new Agent({ id: 'support-agent', name: 'Support Agent', instructions: 'You are a helpful support assistant.', model: 'openai/gpt-5.5', channels: { adapters: { slack: createSlackAdapter(), }, },})Register the agent in your Mastra instance with storage, so channel state persists across restarts:
import { Mastra } from '@mastra/core'import { LibSQLStore } from '@mastra/libsql'import { supportAgent } from './agents/support-agent'
export const mastra = new Mastra({ agents: { supportAgent }, storage: new LibSQLStore({ url: process.env.DATABASE_URL, }),})Each adapter reads its credentials from environment variables by default, for example SLACK_BOT_TOKEN for Slack. Mastra then generates a webhook route for each platform:
/api/agents/{agentId}/channels/{platform}/webhookFor the agent above, the Slack webhook lives at /api/agents/support-agent/channels/slack/webhook. Point the platform's event subscription or interactions URL at this path, and the connection is complete.
Copy link to headingWhat you get out of the box
Because the integration runs through Mastra's agent pipeline, several behaviors work without extra code:
Thread context: on the first mention in a channel thread, Mastra fetches the last 10 messages from the platform so the agent understands the conversation. After responding, the agent subscribes to the thread and uses Mastra's memory for full history.
Tool approval: tools marked with
requireApproval: truerender as interactive cards with Approve and Deny buttons on the platform. The tool only executes after a user approves it.Multi-user awareness: in group conversations, Mastra prefixes each message with the sender's name and platform ID so the agent can distinguish between speakers.
Multimodal content: with
inlineMediaandinlineLinksconfigured, users can share images, video, audio, and links that the agent processes natively when the model supports them.
Copy link to headingWhen to use channels versus Chat SDK directly
Use Mastra channels when your bot is an AI agent. The agent's instructions, tools, memory, and model handle the conversation, and channels handle delivery. This covers support assistants, internal Q&A bots, and any bot where the response comes from an LLM.
Use Chat SDK directly when you need fine-grained control over messaging behavior: custom slash commands, modals, ephemeral messages, scheduled posts, or bots where most responses are deterministic rather than model-generated. Chat SDK's Chat class gives you event handlers like onNewMention() and onSubscribedMessage(), and you can still call a Mastra agent from inside those handlers when a response needs the model. Chat SDK also ships createChatTools, which exposes messaging operations (post, react, DM, edit, delete) as AI SDK tools with built-in approval gates, so an agent can act inside your workspace as part of a larger toolset.
The approaches compose: channels are the fast path for agent-first bots, and direct Chat SDK usage is the flexible path for messaging-first apps that include an agent.
Copy link to headingDeploying to Vercel
On serverless platforms, each request runs in a short-lived instance, and channels need two things to work reliably.
First, keep the function alive while the agent responds. A channel webhook returns a 200 response immediately, then the agent runs in the background to post its reply. Vercel freezes the function as soon as the response is sent, which would kill the run. Pass waitUntil from @vercel/functions so the instance stays alive until the run finishes:
import { waitUntil } from '@vercel/functions'
export const agent = new Agent({ // ... channels: { adapters: { slack: createSlackAdapter(), }, waitUntil, },})Second, coordinate instances with a shared pub/sub. Each channel run acquires a lease on its thread so a single run owns the conversation. The default in-memory pub/sub can't cross instance boundaries, so a follow-up message landing on a different instance would start a duplicate run. Configure RedisStreamsPubSub from @mastra/redis-streams on the Mastra instance; Vercel's one-click Redis integration and Upstash Redis both work.
Copy link to headingLimitations
Channels require
@mastra/core@1.22.0or later.Platform setup (credentials, event subscriptions, permissions) still follows each Chat SDK adapter's documentation.
During local development, platform webhooks need a public URL. Use a tunnel such as ngrok or cloudflared to expose
localhost:4111.On Vercel and AWS Lambda,
waitUntilis required. Cloudflare Workers and Netlify Functions are detected automatically from the request context.