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_KEYorANTHROPIC_API_KEY(or another LangChain 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 LangChain.
- 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 LangChain and Slack, and skip creating a starter project when prompted. Screenshots: Create a Slack app.2
3
Add the handler
Createapp/novu/agents/<your-identifier>.ts. Match agent('...') to the dashboard Identifier.- OpenAI
- Claude
app/novu/agents/index.ts:{ 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
5
Run locally and message Slack
Tool approval
Gate a tool withneedsApproval:
Scaffold with the CLI
npm run dev:novu.
For an existing codebase, use Connect an existing app instead.
FAQ
Which channels work with a LangChain agent?
Which channels work with a LangChain agent?
Slack, Microsoft Teams, WhatsApp, Telegram, and email. See Channels overview.
Does Novu run LangChain for me?
Does Novu run LangChain for me?
When you return a
LangChainAgentConfig, Novu invokes createAgent() with your model, system prompt, and tools, then posts the final text.Where is the adapter API documented?
Where is the adapter API documented?
LangChain reference: tool approval, custom invoke, and
onError.I get "Cannot find module as expression is too dynamic"
I get "Cannot find module as expression is too dynamic"
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
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.