Lipachat Docs
  • Lipachat Docs
  • Getting Started
    • Getting Started with Lipachat
  • API
    • Sending Messages
    • Sending Media
    • Sending Buttons
    • Sending Interactive Lists
    • Templates
      • Creating a Template
      • Updating a Template
      • Listing Message Templates
      • Sending Message Templates
    • Whatsapp Flows
      • Creating a flow
      • Updating a flow
      • Get flow preview
      • Publish a flow
      • Send a flow
      • List all flows
    • Webhooks
  • Reference
    • Sandbox
  • Go Live
  • Guides
    • Build A Chat Bot
  • CRM Workflow
Powered by GitBook
On this page
  1. API

Sending Interactive Lists

PreviousSending ButtonsNextTemplates

Last updated 10 days ago

Important Note: To receive messages from this API, you must create a sandbox session by sending the join code provided after signing up.

Whatsapp offers an API to send lists.

POST /list

Headers

Name
Value

Content-Type

application/json

apiKey

Body

Name
Type
Description

messageId

string

A unique identifier for the message. This will be used to track the message status and for deduplication purposes.

message

string

The message being sent.

from

string

Sandbox number +254110090747 or your own WABA phone number.

to

string

Receiver phone number. It should start with a country code.

buttons[0].sectionTitle

string

buttons[0].sectionItems[0].id

string

Unique identifier of button in your app. eg 1 or YES_BTN

buttons[0].sectionItems[0].title

string

Text to be displayed to user.

buttons[0].sectionItems[0].description

string

Optional description

"buttons" field is a list or array that accepts any number of items. Same case to "sectionItems" field.

curl --location 'https://gateway.lipachat.com/api/v1/whatsapp/interactive/list' \
--header 'apiKey: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
  "headerText": "Welcome to Lipachat",
  "body": "Please choose a product you would like below",
  "buttonText": "Click Here",
  "buttons": [
    {
      "sectionTitle": "Airtime",
      "sectionItems": [
        {
          "id": "SAFARICOM_AIRTIME",
          "title": "Safaricom",
          "description": "mpesa network"
        },
        {
          "id": "AIRTEL_AIRTIME",
          "title": "Airtel",
          "description": "airtel money"
        }
      ]
    },
    {
      "sectionTitle": "Bill Payment",
      "sectionItems": [
        {
          "id": "KPLC",
          "title": "KPLC",
          "description": "electricity"
        },
        {
          "id": "NAIROBI_WATER",
          "title": "Nairobi Water",
          "description": "county gov water"
        }
      ]
    }
  ],
  "messageId": "ca739107-4b0d-4581-acb1-4c4af70555de",
  "to": "2547XXXX",
  "from": "254110090747"
}'
// Create an instance of OkHttpClient
OkHttpClient client = new OkHttpClient().newBuilder()
    .build();

// Define the media type for the request
MediaType mediaType = MediaType.parse("application/json");

// Create the request body with the necessary JSON payload using a text block
RequestBody body = RequestBody.create(mediaType, """
{
  "headerText": "Welcome to Lipachat",
  "body": "Please choose a product you would like below",
  "buttonText": "Click Here",
  "buttons": [
    {
      "sectionTitle": "Airtime",
      "sectionItems": [
        {
          "id": "SAFARICOM_AIRTIME",
          "title": "Safaricom",
          "description": "mpesa network"
        },
        {
          "id": "AIRTEL_AIRTIME",
          "title": "Airtel",
          "description": "airtel money"
        }
      ]
    },
    {
      "sectionTitle": "Bill Payment",
      "sectionItems": [
        {
          "id": "KPLC",
          "title": "KPLC",
          "description": "electricity"
        },
        {
          "id": "NAIROBI_WATER",
          "title": "Nairobi Water",
          "description": "county gov water"
        }
      ]
    }
  ],
  "messageId": "ca739107-4b0d-4581-acb1-4c4af70555de",
  "to": "254XXXXX",
  "from": "254110090747"
}
""");

// Build the request with the required headers
Request request = new Request.Builder()
    .url("https://gateway.lipachat.com/api/v1/whatsapp/interactive/list")
    .method("POST", body)
    .addHeader("apiKey", "YOUR_API_KEY")
    .addHeader("Content-Type", "application/json")
    .build();

// Execute the request and get the response
Response response = client.newCall(request).execute();


const axios = require('axios');
let data = JSON.stringify({
  "headerText": "Welcome to Lipachat",
  "body": "Please choose a product you would like below",
  "buttonText": "Click Here",
  "buttons": [
    {
      "sectionTitle": "Airtime",
      "sectionItems": [
        {
          "id": "SAFARICOM_AIRTIME",
          "title": "Safaricom",
          "description": "mpesa network"
        },
        {
          "id": "AIRTEL_AIRTIME",
          "title": "Airtel",
          "description": "airtel money"
        }
      ]
    },
    {
      "sectionTitle": "Bill Payment",
      "sectionItems": [
        {
          "id": "KPLC",
          "title": "KPLC",
          "description": "electricity"
        },
        {
          "id": "NAIROBI_WATER",
          "title": "Nairobi Water",
          "description": "county gov water"
        }
      ]
    }
  ],
  "messageId": "ca739107-4b0d-4581-acb1-4c4af70555de",
  "to": "254XXXXX",
  "from": "254110090747"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://gateway.lipachat.com/api/v1/whatsapp/interactive/list',
  headers: { 
    'apiKey': 'YOUR_API_KEY', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

Response

{
      "timestamp": "2023-08-06T01:27:56.825898971",
      "data": {
            "messageId": "7addc006-07db-4fae-aac5-b285903b41d4",
            "waId": "wamid.HBgMMjU0NzE3NzQ2NTY1FQIAEnRgSRjJGRkMzNkQ0QUVENTIxQ0NBAA==",
            "status": "SENT",
            "statusDesc": "Message sent successfully"
      },
      "status": "success",
      "message": "",
      "errors": null
}
{
      "timestamp": "2023-08-06T17:50:35.701+00:00",
      "status": 400,
      "error": "Bad Request",
      "path": "/api/v1/whatsapp/message/text"
}
{
      "timestamp": "2023-08-06T20:49:48.455464058",
      "data": null,
      "status": "success",
      "message": "Invalid credentials",
      "errors": null
}

Get apiKey from App portal settings tab

https://app.lipachat.com/app/settings
https://gateway.lipachat.com/api/v1/whatsapp/interactive