growth

WhatsApp Commerce Automation: How AI Chatbots Close Sales & Collect UPI

Build an automated WhatsApp commerce bot using official Meta Cloud APIs, AI sales agents, dynamic UPI checkout links, and instant webhook fulfillment.

GS Gaurav Sharma Fintech Architect & Systems Engineer 2 min read
WhatsApp Commerce Automation: How AI Chatbots Close Sales & Collect UPI guide
whatsapp commerce chatbot source code ai sales agent whatsapp api automated order taking bot whatsapp payment link conversational commerce

With over 500 million active users in India, WhatsApp is no longer just a private messaging app; it has evolved into India’s primary digital marketplace. E-commerce merchants, local retailers, and service providers who replace passive web forms with conversational AI agents on WhatsApp achieve 3x higher checkout conversion rates and near-instant payment collection.

By pairing an intelligent LLM-driven conversational agent with automated dynamic UPI generation, businesses can operate an autonomous sales desk that answers product questions, takes orders, and verifies incoming payments around the clock.


The Conversational Commerce Shift

Traditional web checkouts introduce significant friction for mobile shoppers:

  • Remembering website passwords or awaiting SMS OTPs.
  • Cumbersome mobile checkout forms requiring 12+ input fields.
  • 70% cart abandonment rates on standard mobile web browsers.

Conversational checkout reverses this model:

Customer sends message ("I want to buy the black leather laptop bag")
      |
      v
AI Bot clarifies specifications (color, size, delivery address)
      |
      v
Bot generates Dynamic UPI Payment Link (Pre-filled with ₹2,499.00 and Order Ref)
      |
      v
Customer taps link -> Authorizes PIN in GPay/PhonePe
      |
      v
Payment Webhook fires -> Bot instantly sends Invoice PDF & Delivery Tracking

AI Agent Architecture for WhatsApp

The commerce automation engine connects three primary layers: Meta’s Cloud API for message routing, an LLM orchestrator (such as LangChain or custom Function Calling), and a direct UPI payment switch.

+--------------------------------------------------------------------------+
|                          WhatsApp Cloud API                              |
+------------------------------------+-------------------------------------+
                                     |
                          Incoming Customer Message
                                     v
+--------------------------------------------------------------------------+
|                     FastAPI / Express Webhook Switch                     |
+------------------------------------+-------------------------------------+
                                     |
                                     v
+--------------------------------------------------------------------------+
|               AI Agent (Claude / GPT-4o / DeepSeek Engine)               |
| - State Management (Conversation History in Redis)                       |
| - Tool Calling: [SearchInventory], [CalculateTotal], [CreateUPIOrder]    |
+------------------------------------+-------------------------------------+
                                     |
                                     v
+--------------------------------------------------------------------------+
|                 VyaparGateway Core Payment Engine                        |
| - Generates Dynamic UPI Intent Link: upi://pay?pa=...&am=2499&tr=ORD_991 |
+--------------------------------------------------------------------------+

Dynamic Catalog and Context Handling

The AI agent maintains a persistent conversation memory in Redis keyed by the customer’s phone number (wa_id). When a buyer asks: “Do you have this in size 10, and can you deliver to Pune?”, the agent queries the inventory catalog and postal code logistics API before generating the final payment prompt.


Instead of directing the customer to a generic storefront checkout, the bot creates a single-use transaction reference embedded inside an interactive WhatsApp CTA button:

{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "919876543210",
  "type": "interactive",
  "interactive": {
    "type": "cta_url",
    "header": {
      "type": "text",
      "text": "Order Confirmation #ORD_8819"
    },
    "body": {
      "text": "Your order for 1x Leather Laptop Bag is ready. Total: ₹2,499.00 (Free Shipping). Tap below to pay via GPay, PhonePe, or Paytm."
    },
    "action": {
      "name": "cta_url",
      "parameters": {
        "display_text": "Pay ₹2,499 via UPI",
        "url": "https://api.yourdomain.com/pay/ORD_8819"
      }
    }
  }
}

Instant Webhook Confirmation and Fulfillment

When the customer taps the link and authorizes the transfer, the payment gateway receives the direct bank settlement notification and forwards an internal event to the WhatsApp dispatch engine:

// webhookHandler.js - Handling UPI settlement and triggering WhatsApp bot
export async function handlePaymentSettledWebhook(req, res) {
  const { orderId, amount, utr, status, customerPhone } = req.body;

  if (status === 'SUCCESS') {
    // 1. Mark order as paid in database
    await db.orders.update({ where: { id: orderId }, data: { status: 'PAID', utr } });

    // 2. Dispatch automated WhatsApp receipt message
    await sendWhatsAppMessage(customerPhone, {
      type: "text",
      text: `Payment of ₹${amount} received successfully! (Bank UTR: ${utr}). Your order #${orderId} is confirmed and will ship within 24 hours.`
    });

    return res.status(200).json({ received: true });
  }

  res.status(400).send('Ignored');
}

Code Sample: WhatsApp Webhook Handler

Deploying conversational sales bots eliminates lost checkout sessions, captures high-intent customers when their interest is highest, and routes 100% of transaction settlements directly into the merchant’s bank account with zero payment gateway intermediaries.

Direct answers

Frequently asked questions

How does an AI WhatsApp bot collect payment without taking customers to an external browser?
The bot dispatches interactive native WhatsApp payment messages or generates a dynamic UPI Intent link. When tapped on Android or iOS mobile devices, it triggers the customer's native UPI app directly, completing checkout within seconds.
Are AI conversational bots compliant with Meta's Commerce Policy for transactions?
Yes. As long as transactions comply with standard prohibited goods regulations, Meta Cloud API explicitly supports interactive list messages, product catalogs, and outbound order status updates with end-to-end encryption.
How does the bot verify that the customer actually paid before releasing digital goods?
The bot relies on real-time server-to-server bank webhooks. Once the bank registers the UTR matching the specific order transaction reference, the webhook triggers the fulfillment agent to dispatch tracking numbers or download links automatically.

Build your payment flow

Explore the API and browser-only merchant tools.

Create UPI checkout orders, verify signed events, or test the free calculators and generators without exposing credentials.