Skip to main content
Connect a Vercel AI SDK agent to Novu Connect. Return 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_KEY or ANTHROPIC_API_KEY (or another AI SDK provider key)

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 AI SDK.
  3. Set Agent name and Identifier (your code must use the same identifier).
  4. Select Slack, generate a Slack App Configuration Token, paste it, and finish the install / Allow flow.
The token is used once to create the Slack app. Novu does not store it. Screenshots: Create a Slack app.Alternatively run npx novu connect, choose AI SDK and Slack, and skip creating a starter project when prompted.
2

Install packages

Add to .env.local (or your app env file):
Copy NOVU_SECRET_KEY from API Keys in the dashboard.
3

Add the handler

Create app/novu/agents/<your-identifier>.ts (or the equivalent path). Match agent('...') to the dashboard Identifier.
Export it from your agents index:
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, create app/api/novu/route.ts:
For Express, Hono, and other servers, see Connecting your app.
5

Run locally and message Slack

Or 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:
See Tool approval and the AI SDK reference.

Scaffold with the CLI

If you do not have an app yet:
Choose AI SDK, name the agent, authenticate the model, choose Slack, and accept the starter project. Then run npm run dev:novu. For an existing codebase, use Connect an existing app instead.

FAQ

Slack, Microsoft Teams, WhatsApp, Telegram, and email. One handler covers all of them after you link providers. See Channels overview.
No. Your app serves the bridge endpoint. Novu forwards the inbound event and conversation context, then delivers whatever the handler returns.
Use toModelMessages(ctx.history). Do not append the inbound message again. The current message is already included.
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

Open in Cursor

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.