Your agents can now use generative UI cards in Slack. Turn on generativeUI and the agent gets a render_card tool that posts rich, native cards to the thread.
Agents in Slack usually reply using long blocks of plain text or markdown, making it difficult to see how numbers compare or change over time. With generative UI, the agent decides how to present the data, using fields for key facts, tables for rows of data, charts for metrics or trends, images, and link buttons that open related pages.
You've always been able to post UI cards in Slack by predefining them in code, but before generative UI, each card's structure was fixed in advance. Now, with generative UI, the agent creates the card on the fly, choosing the most suitable UI element for each response.
To render Slack-native UI elements, agents call the render_card tool, passing in an object that meets the json-render spec. Mastra can then post responses to the thread using Slack's Block Kit elements.
Get started
Install @json-render/chat:
npm install @json-render/chat@mastra/core@1.83.0 or later, added in PR #29820.This example uses Mastra Connect to manage the Slack connection on Mastra platform. Add @json-render/chat to bundler.dynamicPackages and set generativeUI: true on the Slack provider:
import { Mastra } from "@mastra/core/mastra";
import { channels } from "@mastra/connect";
import { deployAgent } from "./agents/deploy-agent";
export const mastra = new Mastra({
agents: { deployAgent },
bundler: {
dynamicPackages: ["@json-render/chat"]
},
channels: await channels({
providers: {
slack: {
providerOptions: { generativeUI: true }
}
}
})
});Optionally, name the components you want the agent to use in the agent's instructions:
import { Agent } from "@mastra/core/agent";
import { Memory } from "@mastra/memory";
export const deployAgent = new Agent({
id: "deploy-agent",
name: "Deploy Agent",
instructions: `You report on deploys for the mastra-website project.
Answer every deploy question with one render_card card that includes:
- a title and subtitle
- fields for the key facts
- a table
- a chart
- an image
- link buttons
`,
model: "mastra/anthropic/claude-opus-5.5",
memory: new Memory()
});For more information and full configuration options, see:
Generative UI is still experimental — the API may change between releases.
