Skip to content
Novu logoNovu

Get your AI agent on WhatsApp, two-way, without the Business API grind

Connect an existing AI agent to WhatsApp for two-way customer conversations without building and maintaining the webhook, context, and reply-delivery layer yourself.

One agent connected to WhatsApp through Novu Connect
Author:Victor Yakubu
Victor Yakubu

If you’ve built an AI agent, you’ll soon discover that building it is only part of the work. You still need to bring the agent to the messaging platforms your users already use and make sure it works as expected on each one.

Novu Connect handles that communication layer. It lets you connect one agent to multiple messaging platforms without rebuilding the agent for every channel. In this tutorial, we’ll show you how to bring your agent to WhatsApp for two-way customer conversations.

Key takeaways

Keep the agent you already built.

Your model, prompts, tools, and business logic stay unchanged. Novu Connect adds the communication path to WhatsApp.

Let Novu handle the communication layer.

Novu receives WhatsApp events, normalizes them, restores the conversation context, and delivers the agent’s replies to the same conversation.

Connect WhatsApp your way.

Use Facebook login to authorize credentials and register the webhook automatically, or enter your Meta credentials manually.

Use WhatsApp-native interactions.

Support typing indicators, threaded replies, quick-reply buttons, emoji reactions, message edits, and in-channel tool approvals

Keep Meta’s requirements in mind.

You still need a WhatsApp Business account and a registered business number, and Meta’s messaging fees still apply. Novu removes the integration work—not the platform requirements.

What it takes to bring an AI agent to WhatsApp

  1. 1

    Handle WhatsApp-specific complexity

    WhatsApp messages arrive as platform-specific payloads. To make them useful to your agent, you need to identify the right user and conversation, translate the payload, manage credentials, and support channel-specific behaviors such as typing indicators and emoji reactions.

  2. 2

    Let Novu Connect handle the communication layer

    Novu Connect handles this integration layer, allowing the same agent to work across the messaging platforms your users already use. In this tutorial, you’ll connect an existing agent to WhatsApp without rebuilding its model, tools, or business logic.

What it takes to put an AI agent on WhatsApp

A WhatsApp AI agent needs a communication layer between the WhatsApp Business Platform and the code that runs its model, prompts, tools, and business logic.

The message path looks like this:

  1. A user sends a message to your WhatsApp Business number.
  2. WhatsApp sends an event to a registered webhook.
  3. The communication layer validates and normalizes the event.
  4. The correct conversation and its history are loaded.
  5. Your agent receives the current message and conversation context.
  6. Your agent returns a reply or requests approval to call a tool.
  7. The reply is translated and delivered to the same WhatsApp conversation.

Novu Connect provides the ACI, Agent Communication Infrastructure, bridge in this path. It receives channel events, normalizes them, preserves conversation context, and delivers responses.

Your application still owns the agent's model, instructions, tools, and decisions.

WhatsApp request and reply flow through Novu Connect to a developer-owned agent

What Novu handles and what you configure

The WhatsApp Business Platform remains the underlying channel. Novu removes the integration work around connecting that channel to your agent.

ResponsibilityOwner
WhatsApp Business account and platform complianceYou
WhatsApp Business credentialsYou provide or authorize access
Webhook registrationNovu when you use Log in with Facebook
Inbound webhook ingestionNovu
Provider event normalizationNovu
Conversation history and routingNovu
Model, instructions, and toolsYour application
Agent response generationYour runtime
WhatsApp reply deliveryNovu

Prerequisites

You need the following accounts and tools to complete the tutorial.

  • A Novu account.
  • Node.js 22 or later.
  • An OpenAI API key or another model-provider key supported by the Vercel AI SDK
  • A Meta account with access to a WhatsApp Business account
  • A phone number you can use with the WhatsApp Business Platform

Build an order-support agent that works in the terminal

Start with a useful agent that works without Novu or WhatsApp. For this example, the demo answers return-policy questions and looks up the status of a sample order.

  1. 1

    Create the project

    Create a new project and install the required packages:

    mkdir whatsapp-order-agent
    cd whatsapp-order-agent
    npm init -y
    npm install ai @ai-sdk/openai zod
    npm install --save-dev tsx typescript @types/node
  2. 2

    Configure the project

    Update the package.json file to use ES modules, add a command for starting the terminal chat, and provide the model API key.

    {
      "type": "module",
      "scripts": {
        "chat": "tsx --env-file=.env cli.ts"
      }
    }

    Create a .env file and add your model-provider key:

  3. 3

    Add the order-support agent

    Keep the agent logic independent of WhatsApp and Novu so you can run it from any interface. Create support-agent.ts with the agent's instructions, order lookup tool, and model call:

    import { openai } from "@ai-sdk/openai";
    import { generateText, stepCountIs, tool, type ModelMessage,} from "ai";
    import { z } from "zod";
    
    const orders = {
      "NV-1042": {
        status: "Shipped",
        expectedDelivery: "Friday",
      },
      "NV-1043": {
        status: "Processing",
        expectedDelivery: "Next Tuesday",
      },
      "NV-1044": {
        status: "Delivered",
        expectedDelivery: "Delivered on Monday",
      },
      "NV-1045": {
        status: "Out for delivery",
        expectedDelivery: "Today",
      },
      "NV-1046": {
        status: "Cancelled",
        expectedDelivery: "N/A",
      },
      "NV-1047": {
        status: "Delayed",
        expectedDelivery: "Next Monday",
      },
      "NV-1048": {
        status: "Shipped",
        expectedDelivery: "Wednesday",
      },
    } as const;
    
    export function generateOrderSupportResponse(messages: ModelMessage[]) {
      return generateText({
        model: openai("gpt-4o"),
        system: `
          You are an order-support agent.
          Keep replies concise.
          Use getOrderStatus when a user provides an order ID.
          If an order does not exist, ask the user to check the ID.
          The return window is 30 days after delivery.
        `,
        messages,
        stopWhen: stepCountIs(5),
        tools: {
          getOrderStatus: tool({
            description: "Look up the current status of an order",
            inputSchema: z.object({
              orderId: z.string().describe("The order ID, such as NV-1042"),
            }),
            execute: async ({ orderId }) => {
              const order = orders[orderId as keyof typeof orders];
              if (!order) {
                return { found: false, orderId };
              }
              return { found: true, orderId, ...order };
            },
          }),
        },
      });
    }
  4. 4

    Add the terminal interface

    Next, create cli.ts. This gives the agent a small terminal interface and keeps the conversation history between turns:

    import { stdin as input, stdout as output } from "node:process";
    import { createInterface } from "node:readline/promises";
    import type { ModelMessage } from "ai";
    import { generateOrderSupportResponse } from "./support-agent.js";
    
    const terminal = createInterface({ input, output });
    const messages: ModelMessage[] = [];
    
    console.log("Order support agent");
    console.log("Try: Where is order NV-1042?");
    console.log("Type exit to stop.\n");
    
    while (true) {
      const prompt = await terminal.question("You: ");
    
      if (prompt.trim().toLowerCase() === "exit") {
        break;
      }
    
      messages.push({ role: "user", content: prompt });
    
      const result = await generateOrderSupportResponse(messages);
    
      console.log(`Agent: ${result.text}\n`);
      messages.push(...result.response.messages);
    }
    
    terminal.close();
  5. 5

    Test the agent in the terminal

    The terminal test proves that the model, instructions, tool, and conversation history work before a messaging provider enters the path.

    Start the agent:

    npm run chat

    Ask for the sample order:

    You: Where is order NV-1042?
    Agent: Order NV-1042 has shipped and is expected to arrive Friday.

    Then test a follow-up question:

    You: Can I return it after it arrives?
    Agent: Yes. You can return it within 30 days after delivery.

    Try an unknown order ID as well:

    You: Where is order NV-9999?

    The agent should ask you to check the order ID instead of inventing an order status. If the terminal agent does not respond, confirm that OPENAI_API_KEY is available and that your model account can make API requests.

    Order-support agent running in the terminal and answering order questions

    At this point, the business agent works. It does not depend on Novu, and it is not tied to WhatsApp. The next step gives that existing agent a WhatsApp communication path.

Connect the working agent to Novu and WhatsApp

Run the Novu CLI inside the project that contains the working agent. The command specifies both the AI SDK runtime and WhatsApp channel, so the CLI can guide you through the complete connection flow.

npx novu connect --channel whatsapp --runtime ai-sdk

The CLI will ask you to connect your Novu account, create the agent in Novu, and connect its WhatsApp channel. For WhatsApp, you can log in with Facebook or provide the credentials manually. The next section covers both options.

Connect your WhatsApp Business account

The CLI takes you to the WhatsApp connection step during setup. You can connect your WhatsApp Business account through Facebook or enter its credentials manually.

  1. 1

    Option 1: Log in with Facebook

    The Facebook login flow is the recommended path because Novu can save the credentials you authorize and register the webhook automatically.

    1. Open your agent in the Novu dashboard.
    2. Click WhatsApp to add it as a channel.
    3. Click Log in with Facebook.
    4. Select the business portfolio and WhatsApp Business account you want to share.
    5. Review the requested access and complete the authorization flow.

    After authorization, Novu stores the shared credentials and registers the webhook that receives inbound WhatsApp messages. You do not need to copy API fields or configure the webhook yourself.

    Novu dashboard showing the WhatsApp channel and Log in with Facebook setup
  2. 2

    Option 2: Enter your credentials manually

    You can configure the provider manually if you prefer to copy the credentials from Meta into Novu.

    Create a Meta app

    First, create the app that will provide access to your WhatsApp Business account.

    1. Open the Meta App Dashboard and click Create App.
    2. Select the Connect with customers through WhatsApp use case.
    3. Select an existing business portfolio or create one.

    Add the API credentials to Novu

    Next, collect the required values from the app and add them to the provider configuration.

    1. In the Meta app's left sidebar, open Use cases.
    2. Find Connect with customers through WhatsApp and click Customize.
    3. Open API Setup from the inner menu.
    4. Copy the contents of the API Setup page and then paste them into the Novu configuration sidebar. Novu uses the page contents to fill the supported fields automatically.
    5. Open App settings > Basic, copy the App secret, and paste it into Novu manually.

    Novu needs these values:

    CredentialWhere to find it
    Access tokenClick Generate access token on the API Setup page
    Phone Number IDUnder the selected phone number on the API Setup page
    WhatsApp Business Account IDDirectly above the Phone Number ID
    App secretApp settings > Basic

    Save the provider after Novu fills the fields and you add the app secret.

    Meta WhatsApp API credentials mapped to the Novu provider configuration

Complete the project setup and start the local bridge

After you connect WhatsApp, the CLI runs the project setup and tells you what is needed to connect your code to Novu Connect.

You can complete the suggested changes yourself. You can also copy the prompt provided by Novu, paste it into your coding agent, and let the coding agent complete the setup in your project.

Review the generated changes before continuing. Your original agent behavior should remain the same. Novu adds the communication path that passes WhatsApp messages and conversation context to the agent and returns its replies.

When setup is complete, start the local bridge using the command provided by the CLI. For this project, run:

npx novu dev --port 4000

Keep the process running, then open WhatsApp and message the connected business number. The terminal interface remains available when you want to test the underlying agent without going through WhatsApp.

Send a WhatsApp message to the agent

With the provider connected and the local bridge running, send a message to the WhatsApp Business number.

Start with the same order lookup you tested earlier:

Where is order NV-1042?

The complete round trip is now:

  1. WhatsApp sends the inbound event to the webhook registered by Novu.
  2. Novu normalizes the event and resolves the user and conversation.
  3. Novu sends the current conversation history to orderSupportAgent.
  4. The agent calls getOrderStatus and returns its response.
  5. Novu delivers the answer to the same WhatsApp conversation.

The user should receive a response similar to:

Order NV-1042 has shipped and is expected to arrive Friday.

Open Agent Conversations in the Novu dashboard to inspect the conversation and confirm that the messages belong to the same session.

WhatsApp conversation with an order-support agent replying to an order-status request

Use WhatsApp-native agent interactions

A useful WhatsApp agent needs more than plain request and response text. We translate supported agent interactions into channel-native behavior.

On WhatsApp, Novu Connect currently supports:

  • Full conversation context
  • Threaded replies within the session window
  • A typing indicator while the agent works
  • Quick-reply buttons, with up to three buttons per message
  • Emoji reactions
  • Message edits
  • Tool approval through quick-reply buttons
  • Short authorization links for MCP server connections
  • Conversation resolution

For example, you can require approval before an agent calls a sensitive tool. Novu presents Approve and Deny as quick-reply buttons in WhatsApp, then resumes the agent turn after the user responds. See the WhatsApp channel reference for the current capability matrix.

Give your existing agent a WhatsApp presence

Keep your agent’s model, prompts, tools, and business logic. Novu Connect handles the WhatsApp communication layer.

Connect to WhatsApp

Frequently asked questions

Can I connect an AI agent to WhatsApp?

Yes. You have two routes. You can build directly on the WhatsApp Business API, which means registering a business phone number, passing Meta's app review, and writing your own webhook handler to receive and send messages. Or you can put an agent you already built behind a delivery layer like Novu Connect, which receives inbound WhatsApp messages, routes them to your agent, and sends the replies back on the same thread. Either way, people message a normal WhatsApp number and your agent answers.

Do I need the WhatsApp Business API to run an AI agent on WhatsApp?

Yes. WhatsApp requires a WhatsApp Business account and a registered business phone number to go live, and that requirement comes from Meta. No tool waives it. What a delivery layer like Novu Connect removes is building the webhook and two-way plumbing yourself, so you complete Meta's account setup once and skip the integration work.

How do I get approved for the WhatsApp Business API?

You register a business phone number, submit your app to Meta for review to get production credentials, generate a permanent access token, and, for outbound template messages, get a message template approved. The review wait is Meta's and varies. A delivery layer like Novu Connect guides you through the handoff, but the approval itself sits with Meta.

How much does the WhatsApp Business API cost?

Meta charges its own messaging fees for WhatsApp, billed per message under the pricing model Meta moved to in 2025, with rates that vary by country and message category. Those fees are Meta's and apply no matter how you connect your agent. A delivery layer like Novu Connect is separate from Meta's messaging charges. Check Meta's current WhatsApp pricing for exact rates, since they change.

How do I build a WhatsApp AI agent?

Bring the agent you already have, whether that is a Claude Managed Agent, an AI SDK or LangChain agent, or custom code. With Novu Connect you run npx novu@latest connect, choose WhatsApp, and finish the setup in the dashboard by linking your WhatsApp Business account. Connect then carries the two-way conversation, so you do not write a webhook handler or manage threads and session state yourself. Once your WhatsApp Business account is set up, connecting the agent takes minutes.

Is a WhatsApp AI agent different from a WhatsApp chatbot?

Yes. A traditional WhatsApp chatbot follows scripted menus and keyword triggers. A WhatsApp AI agent reasons about each message, keeps context across turns, and holds a real two-way conversation, so it can resolve open-ended requests instead of routing them through a fixed tree.

Read More

You’re five minutes away from your first Novu-backed notification

Create a free account, send your first notification, all before your coffee gets cold... no credit card required.