# LangChain adapter for Novu Connect

> Connect a LangChain or LangGraph agent to Slack, Microsoft Teams, WhatsApp, Telegram, and email, with mapped conversation history and in-channel tool approval on the adapter-managed path.


Canonical: https://website-new-git-getting-started-flow-experiment-novuhq.vercel.app/changelog/langchain-adapter-for-novu-connect/

Markdown: https://website-new-git-getting-started-flow-experiment-novuhq.vercel.app/changelog/langchain-adapter-for-novu-connect.md

Last updated: 2026-08-20T13:35:00.000Z

Connect a LangChain or LangGraph agent to Slack, Microsoft Teams, WhatsApp, Telegram, and email, with mapped conversation history and in-channel tool approval on the adapter-managed path.

Published: 2026-08-20T13:35:00.000Z

Categories: Agent Communication, New Feature, Langchain AI SDK

The LangChain adapter is now available through `@novu/framework/langchain`. It gives teams already using LangChain or LangGraph a direct path to Novu Connect without rebuilding their agent for each communication channel.

Your agent or graph continues to run in your application. Novu Connect handles inbound channel events, conversation context, and delivery of the response back to the user.

**For OpenAI:**

```bash
npm install @novu/framework langchain @langchain/core @langchain/openai
```

**For Anthropic:**

```bash
npm install @novu/framework langchain @langchain/core @langchain/anthropic
```

> [!NOTE] Good to know
>
> This is not limited to just OpenAI and Anthropic, you can use other LangChain provider keys.

## **Return a config or invoke your own agent**

The adapter supports two handoff patterns based on how much of your LangChain setup you want it to manage.

When you return a `LangChainAgentConfig` from `onMessage`, the adapter calls `createAgent().invoke()` in your application, maps `ctx.history`, and delivers the final assistant response:

```typescript
import { agent } from '@novu/framework/langchain';

export const supportBot = agent('support-bot', {
  onMessage: async (_message, ctx) => ({
    model: 'openai:gpt-4o',
    system: 'You are a helpful support agent.',
  }),
});
```

If you already invoke a LangChain agent or LangGraph graph yourself, use `toLangChainMessages(ctx.history)`, run your existing `invoke()` call, and return `{ messages }`. Novu delivers the final assistant message. Tool approval is not managed by the adapter on this bring-your-own invocation path.

## **Ask for approval in the channel**

On the config path, `needsApproval` lets you gate sensitive tools without building a separate approval flow for every channel. When the model calls a gated tool, Novu posts an Approve / Deny card and pauses the turn. After the user responds, the adapter replays the approval cycle from conversation history and continues the agent run.

```typescript
import { tool } from '@langchain/core/tools';
import { agent } from '@novu/framework/langchain';
import { z } from 'zod';

const issueRefund = tool(
  async ({ orderId }) => ({ orderId, status: 'refunded' }),
  {
    name: 'issueRefund',
    description: 'Issue a refund for an order',
    schema: z.object({ orderId: z.string() }),
  },
);

export const supportBot = agent('support-bot', {
  onMessage: async () => ({
    model: 'openai:gpt-4o',
    system: 'You are a helpful support agent.',
    tools: [issueRefund],
    needsApproval: (toolCall) => toolCall.name === 'issueRefund',
  }),
});
```

This approval flow does not require a separate LangGraph checkpointer. The conversation history holds the information the adapter needs to resume the turn.

Get started with `npx novu connect --runtime langchain`, then follow the [LangChain quickstart](<https://docs.novu.co/agents/get-started/langchain>). See the [LangChain reference](<https://docs.novu.co/agents/custom-code-agent/frameworks/langchain>) for config returns, custom invocation, approval gating, Next.js setup, and error handling.
