29 April 2026 AI, Automation, WhatsApp API, Customer Support

Practical AI Chatbots on WhatsApp: Automating Repetitive Customer Inquiries

Building WhatsApp AI Customer Support Chatbots with Meta Cloud API - Safal Bhurtel Nepal

For businesses operating in Nepal, WhatsApp is not just a messaging utility; it is the primary commercial channel where customers ask about product stock, pricing, store locations, and warranty terms. However, retail teams spend hours every day answering the exact same repetitive questions: "Delivery charge kati ho?", "Butwal ma store kata cha?", or "eSewa bata pay garna milcha?". Deploying an intelligent AI chatbot directly on WhatsApp automates over 80% of customer support around the clock.

Strategic Executive Summary

  • Core Insight: Modern Large Language Models (LLMs) understand Romanized Nepali (e.g. "Mero parcel kahile aipugcha?" ), standard Devanagari, and English effortlessly when primed with a structured system prompt.
  • Production Quality: Battle-tested engineering techniques designed specifically for Nepal's network infrastructure and business environment.
  • Direct Implementation: Copy-paste ready code architectures with security safeguards against race conditions, data corruption, and unauthorized access.
Table of Contents
  1. 1. Meta Cloud API Webhook Architecture
  2. 2. Processing Inbound Messages and Connecting to AI
  3. 3. Engineering the System Prompt for Nepali Retail
  4. 4. Human Handover Protocol

1. Meta Cloud API Webhook Architecture

The Meta Cloud API transmits incoming WhatsApp messages via asynchronous HTTP POST webhooks to your server. First, verify the webhook registration endpoint:

Webhook Verification PHP 8.3
<?php
// Webhook Verification (webhook.php)
$verify_token = "SAFAL_WHATSAPP_TOKEN_SECRET_987";

if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    if (isset($_GET['hub_mode']) && $_GET['hub_mode'] === 'subscribe' &&
        isset($_GET['hub_verify_token']) && $_GET['hub_verify_token'] === $verify_token) {
        echo $_GET['hub_challenge'];
        exit;
    }
    http_response_code(403);
    exit;
}

2. Processing Inbound Messages and Connecting to AI

When a customer sends a message, extract the phone number and message body, query the LLM API with your company knowledge base, and dispatch the answer:

input PHP 8.3
<?php
$input = file_get_contents('php://input');
$payload = json_decode($input, true);

if (isset($payload['entry'][0]['changes'][0]['value']['messages'][0])) {
    $messageData = $payload['entry'][0]['changes'][0]['value']['messages'][0];
    $from = $messageData['from']; // Customer phone number
    $text = $messageData['text']['body'] ?? '';

    if (!empty($text)) {
        // Query LLM with Company Context
        $aiResponse = queryAiAssistant($text);

        // Send reply back via Meta Cloud API
        sendWhatsAppReply($from, $aiResponse);
    }
}
http_response_code(200);

3. Engineering the System Prompt for Nepali Retail

The secret to high-accuracy responses lies in providing crisp grounding data:

snippet.php PHP 8.3
System Prompt:
You are the official digital assistant for Safal Store in Butwal, Nepal.
Knowledge Base:
- Store Location: Kalikanagar, Ward 11, Butwal (Near Horizon Chowk).
- Delivery: Same day in Butwal (NPR 50). 2-3 days outside valley (NPR 150). Free delivery on orders over NPR 3,000.
- Payment Methods: Cash on Delivery, eSewa, Khalti, Fonepay QR.
- Language Instruction: Reply warmly in the same language the customer uses (Romanized Nepali, Devanagari, or English). Keep answers concise under 3 sentences.

4. Human Handover Protocol

A great automated system knows when to step aside. If the AI detects phrases like "complain", "faulty item", "talk to manager", or "urgent", it flags the conversation in your CRM and notifies a human agent via WhatsApp or SMS, ensuring customers never feel trapped in an endless bot loop.

Safal Bhurtel

Safal Bhurtel

Full-Stack Web Developer • Butwal, Nepal

Safal Bhurtel has 6+ years of specialized web engineering experience developing custom PHP/MySQL web applications, high-converting WordPress/WooCommerce websites, API payment integrations (eSewa, Khalti, Fonepay), and speed-optimized digital solutions across Nepal.