Skip to main content
Connect a LangChain agent to Novu Connect. Return a LangChainAgentConfig from onMessage; Novu invokes the agent and delivers the reply on Slack. The same handler works on other providers after you link them. This guide uses Slack first and assumes an existing Node.js app.
Starting from scratch? See Scaffold with the CLI.

Prerequisites

  • A Novu account
  • Node.js 22+
  • An existing app with LangChain agent logic
  • A Slack workspace where you can install apps
  • An OPENAI_API_KEY or ANTHROPIC_API_KEY (or another LangChain 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 LangChain.
  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.
Alternatively run npx novu connect, choose LangChain and Slack, and skip creating a starter project when prompted. Screenshots: Create a Slack app.
2

Install packages

Add to .env.local:
3

Add the handler

Create app/novu/agents/<your-identifier>.ts. Match agent('...') to the dashboard Identifier.
Export from app/novu/agents/index.ts:
Returning { model, system } is a LangChainAgentConfig. Novu calls createAgent().invoke() and posts the final text. Novu maps ctx.history on this path.On Next.js, add LangChain packages to serverExternalPackages for Turbopack. See Next.js and Turbopack.
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 your LangChain handler in the same thread.

Tool approval

Gate a tool with needsApproval:
See Tool approval and the LangChain reference.

Scaffold with the CLI

Choose LangChain, authenticate the model, connect 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. See Channels overview.
When you return a LangChainAgentConfig, Novu invokes createAgent() with your model, system prompt, and tools, then posts the final text.
LangChain reference: tool approval, custom invoke, and onError.
Turbopack cannot resolve LangChain dynamic provider imports for model strings. Add LangChain packages to serverExternalPackages in next.config.mjs. See Next.js and Turbopack.

Set this up with an AI assistant

Connect my LangChain agent to Slack with Novu

Open in Cursor

Next steps

LangChain reference

Adapter API: tools, approval, custom invoke, and onError.

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.