Build A Chat Bot
This guide walks you through setting up a basic WhatsApp chatbot using Lipachat APIs. It assumes you’ve already joined the sandbox or connected your own WhatsApp Business number.
🪝 Step 1: Set Up Your Webhook
Navigate to the Lipachat Dashboard → Settings → Webhook
Set the Webhook URL to point to your server endpoint that will handle incoming messages.
Example:
https://yourdomain.com/webhookWhen a customer sends a message on WhatsApp, Lipachat will send a POST request to your webhook with the message payload.
📩 Step 2: Handle Incoming Message
Example payload:
{
"messageId": "c94ced08-5f40-46b7-a88d-7d4fbe113fe9",
"from": "CUSTOMER_PHONE_NUMBER",
"to": "WHATSAPP_NUMBER",
"profileName": "CUSTOMER_NAME",
"type": "TEXT",
"text": "Text Content"
}Your backend logic should parse this payload and determine the appropriate response (e.g., predefined replies or bot logic).
📤 Step 3: Respond with a Message
Once your bot determines a reply, call the Send Message API to respond.
Text reply example:
curl --location 'https://gateway.lipachat.com/api/v1/whatsapp/message/text' \
--header 'apiKey: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"message": "Hello world",
"messageId": "e66fc7b8-680f-4887-8dc8-ee062d65b54f",
"to": "254XXXXXXX",
"from": "254110090747"
}'🖼 Optional: Respond with Media
Use the Send Media API to reply with images, PDFs, audio, or video.
Media reply example:
curl --location 'https://gateway.lipachat.com/api/v1/whatsapp/media' \
--header 'apiKey: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"messageId": "5d3f62c3-eb8f-4150-8941-bdceb0f429bb",
"to": "254XXXXX",
"from": "254110090747",
"mediaType": "IMAGE",
"mediaUrl": "https://picsum.photos/id/237/200/300",
"caption": ""
}'Summary: End-to-End Flow
The customer sends a message via WhatsApp
Lipachat delivers the message to your Webhook
Your chatbot processes the message
Your system calls
Send MessageorSend MediaAPIThe customer receives the bot reply on WhatsApp
Last updated