Skip to main content
Connect a Mastra agent to Novu Connect via @novu/framework. Call generate() in onMessage and return the text. Novu delivers the reply on Slack. The same handler works on other providers after you link them. There is no @novu/framework/mastra adapter yet. Use the base Framework package and return text from onMessage (or call ctx.reply()).
Starting from scratch? See Scaffold with the CLI.

Prerequisites

  • A Novu account
  • Node.js 22+
  • An existing app with a Mastra agent
  • A Slack workspace where you can install apps
  • An OPENAI_API_KEY (or another model key Mastra supports)

Connect an existing app

1

Create the agent and connect Slack

In the Novu dashboard:
  1. Go to AgentsCreate agent.
  2. Under Custom code, pick Custom code (Mastra uses the base Framework path).
  3. Set Agent name and Identifier.
  4. Select Slack, generate a Slack App Configuration Token, paste it, and finish the install / Allow flow.
Alternatively run npx novu connect, choose Custom code and Slack, and skip creating a starter project when prompted.
2

Install packages

Add to .env.local:
3

Add the Mastra agent and Novu handler

Match agent('...') to the dashboard Identifier. Export the Novu agent from your agents index.
4

Add the bridge route

For Express, Hono, and other servers, see Connecting your app.
5

Run locally and message Slack

DM or @mention the bot in Slack. The reply should come from Mastra in the same thread.

Tool approval

For sensitive tools, use ctx.toolApproval.request() from Tool approval so the turn pauses for Approve / Deny before execution.

Scaffold with the CLI

Choose Custom code, connect Slack, accept the starter project, install @mastra/core, and replace the demo handler with the code above. For an existing codebase, use Connect an existing app instead.

FAQ

Slack, Microsoft Teams, WhatsApp, Telegram, and email. See Channels overview.
Not yet. Use @novu/framework and return text from onMessage. AI SDK and LangChain have dedicated adapters if you prefer those stacks.
Other frameworks for patterns without a dedicated adapter.

Set this up with an AI assistant

Connect my Mastra agent to Slack with Novu

Open in Cursor

Next steps

Other frameworks

Framework patterns without a dedicated adapter.

Slack

Slack capabilities and setup links.

Going to production

Deploy the bridge and disable local tunneling.

Connect AI SDK

Same flow with @novu/framework/ai-sdk.