Skip to content
Novu logoNovu

Changelog

Latest updates and improvements in the langchain ai sdk category.

Follow us on X

All changelog posts

  • 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.

    Langchain adapter for Novu Connect

    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:

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

    For Anthropic:

    npm install @novu/framework langchain @langchain/core @langchain/anthropic
    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:

    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.

    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. See the LangChain reference for config returns, custom invocation, approval gating, Next.js setup, and error handling.