generateText() from onMessage; Novu delivers the reply on Slack. After you add other providers, the same handler serves Teams, WhatsApp, Telegram, and email.
This guide uses Slack first and assumes an existing Node.js app. Examples use OpenAI or Anthropic via the AI SDK.
Starting from scratch? See Scaffold with the CLI.
Prerequisites
- A Novu account
- Node.js 22+
- An existing app (Next.js, Express, Hono, or similar)
- A Slack workspace where you can install apps
- An
OPENAI_API_KEYorANTHROPIC_API_KEY(or another AI SDK provider key)
Connect an existing app
1
Create the agent and connect Slack
In the Novu dashboard:- Go to Agents → Create agent.
- Under Custom code, pick AI SDK.
- Set Agent name and Identifier (your code must use the same identifier).
- Select Slack, generate a Slack App Configuration Token, paste it, and finish the install / Allow flow.
npx novu connect, choose AI SDK and Slack, and skip creating a starter project when prompted.2
Install packages
- OpenAI
- Claude
.env.local (or your app env file):NOVU_SECRET_KEY from API Keys in the dashboard.3
Add the handler
Createapp/novu/agents/<your-identifier>.ts (or the equivalent path). Match agent('...') to the dashboard Identifier.- OpenAI
- Claude
toModelMessages(ctx.history) already includes the current inbound message. Returning generateText(...) delivers the reply. Do not call ctx.reply() on this path.4
Add the bridge route
For Next.js, createapp/api/novu/route.ts:5
Run locally and message Slack
npm run dev:novu if that script exists. Keep the process running.DM or @mention the bot in Slack. The reply should come from your model in the same thread.If nothing comes back:- Confirm the tunnel process is still running.
- Confirm the agent identifier in code matches the dashboard.
- Confirm your model API key is set.
- Confirm Slack install completed and you are messaging the correct bot.
Tool approval
Gate a tool so the turn pauses for Approve / Deny in Slack:Scaffold with the CLI
If you do not have an app yet:npm run dev:novu.
For an existing codebase, use Connect an existing app instead.
FAQ
Which channels work with an AI SDK agent?
Which channels work with an AI SDK agent?
Slack, Microsoft Teams, WhatsApp, Telegram, and email. One handler covers all of them after you link providers. See Channels overview.
Does Novu run my AI SDK code?
Does Novu run my AI SDK code?
No. Your app serves the bridge endpoint. Novu forwards the inbound event and conversation context, then delivers whatever the handler returns.
How do I pass conversation history to the model?
How do I pass conversation history to the model?
Use
toModelMessages(ctx.history). Do not append the inbound message again. The current message is already included.Where is the adapter API documented?
Where is the adapter API documented?
AI SDK reference: return types, tools, MCP, streaming edits, and
onError.Set this up with an AI assistant
Connect my Vercel AI SDK agent to Slack with Novu
Next steps
AI SDK reference
Adapter API: tools, approval, MCP, and onError.
Slack
Slack capabilities and setup links.
Going to production
Deploy the bridge and disable local tunneling.
Connect LangChain
Same flow with @novu/framework/langchain.