You can now run a multi-player harness from Slack, iMessage, WhatsApp, and Discord using Mastra Agent Controller chat channels. Every configured chat adapter acts as an interface, enabling multi-user prompting to drive a single session.
Each Agent Controller session coordinates the modes, models, storage, tool approvals, and subagents. Connected channels forward incoming messages to the session, while server- or client-side subscribers can passively observe or actively participate in conversations.
Before chat channels, Agent Controller sessions were single-user. Each session lived in a TUI or a UI that couldn't be shared. Now you can enable multi-user interactions on the chat platforms your team already use.
Get started
Install the Slack adapter:
npm install @chat-adapter/slack@mastra/core@1.54.0 or later, added in PR #19289.Add createSlackAdapter() to your AgentController channels options. Setting toolDisplay: "card" renders approve and deny buttons in the Slack UI:
import { AgentController } from "@mastra/core/agent-controller";
import { createSlackAdapter } from "@chat-adapter/slack";
export const incidentController = new AgentController({
id: "incident-controller",
// ...
channels: {
adapters: {
slack: {
adapter: createSlackAdapter(),
toolDisplay: "card"
}
},
resolveResourceId: () => {
return "incident-demo";
}
}
});Subscribe to a session
Connect using the Mastra Client SDK. Pass the controller id and resourceId to subscribe to the session's event stream:
import { MastraClient } from "@mastra/client-js";
const client = new MastraClient({ baseUrl: "http://localhost:4111" });
const session = client.getAgentController("incident-controller").session("incident-demo");
await session.create();
const subscription = await session.subscribe({
onEvent: (event) => {
if (event.type === "message_update") {
/* ... */
}
if (event.type === "tool_approval_required") {
/* ... */
}
}
});Send messages from a client
Use sendMessage() to post messages to the subscribed session:
await session.sendMessage("OK. Sally said we're good to roll back.");For more information and full configuration options, see:
