Tutorials
Send an interactive product message with WhatsApp API
Send an interactive product message with WhatsApp API

Send an interactive product message with WhatsApp API

Copy as markdown

|

View as Markdown

As an outcome of this guide, you will get an interactive WhatsApp message delivered to your handset. You'll also use a webhook to catch the reply and simulate user interaction. For ease of replicating the scenario, we have used a free online webhook tool, HookRelay (opens in a new tab). You may replace HookRelay with your own hook server if you need to process your events programmatically.

Scenario overview

The WhatsApp sender sends a message with a product image and a description, which are loaded from their existing Meta catalog. The recipient can then click on the image and choose between two options, either message the sender about the product or add the product to the cart. The card then is sent back to the business in the same WhatsApp interaction. The business determines the next steps, whether it's a delivery or payment integration, which is out of scope for this guide. The end user's reply will be intercepted by a webhook so that the WhatsApp sender can view the reply and react accordingly.

WhatsApp message with an interactive product showing user interaction

Prerequisites

Limitations

With WhatsApp, you can only send a message to your customer if they have contacted you first. This opens a 24-hour window for two-way communication. Otherwise, use a template message (opens in a new tab).

Summary of the steps

  • Buy or configure an existing WhatsApp number capable of receiving incoming traffic.
  • Set up a webhook.
  • Add webhook details to the number you've purchased or configured.
  • Send an interactive WhatsApp message with a product. The webhook will catch the response.

Buy a number

To buy a number, you'll need to log into your Infobip account (opens in a new tab).

Note

Skip this section, if using the Infobip test sender or an existing number.

  1. Expand the Channels and Numbers icon on the left-hand side menu, and select Channels.
  2. Select WhatsApp and click Register Sender.
  3. From the Register a WhatsApp sender screen, select the option you wish to choose for sender registration.
  4. Set up your number preferences, like a country, number type, etc.

You're all set for now. Once a webhook is configured, you'll come back to the number config to add its URL.

Set up a webhook

For the purpose of this guide, we will use a simple online webhook tool, HookRelay (opens in a new tab). This section will show you how to create an account and configure the webhook with HookRelay.

Step 1. Sign in with git credentials

Sign into HookRelay (opens in a new tab) with your GitHub or GitLab credentials.

Step 2. Create a webhook

To create an inbound webhook, from your dashboard, click the New Hook button on the top right. That will take you to the configuration screen where all you need providing is a descriptive name for your webhook, e.g. Infobip WhatsApp List Response.

Once you click the Create hook button, you'll be able to view and copy its URL that you will need to add to your WhatsApp sender.

Add webhook URL to a WhatsApp sender

Head back to your Infobip account (opens in a new tab) and access your WhatsApp sender configuration page (Channels and Numbers > WhatsApp).

  1. Select Senders and click the kebab (three-dot) menu on the WhatsApp sender's tile to select Edit configuration.
  2. Under Keywords add a new one or edit the existing default one.
  3. Under the Forwarding action section, select Forward to HTTP and add the webhook's URL to the URL field.
  4. Click Save.

That's about it for the webhook configuration. Let's now move to creating a WhatsApp message with an interactive list.

Send a WhatsApp product message

Use the Send WhatsApp interactive product message (opens in a new tab) endpoint to interact with your users.

Key points:

  • The to field must include a number in the international format, e.g. 447415774332.
  • If using a free trial account, the phone number you use must be the same phone number you've registered on signup.
  • If you just want to test out the solution, use the catalogId and productRetailerId provided in the code sample below.
curl -L -g 'https://{baseUrl}/whatsapp/1/message/interactive/product' \
-H 'Authorization: {authorization}' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
  "from": "441134960000",
  "to": "447415774332",
  "messageId": "a28dd97c-1ffb-4fcf-99f1-0b557ed381da",
  "content": {
    "action": {
      "catalogId": "1634406623431551",
      "productRetailerId": "tennis-12345"
    },
    "body": {
      "text": "Dear Customer, we thought you may be interested."
    },
    "footer": {
      "text": "Summer Sale is on!"
    }
  }

Send multiple products in one message

If you want to send multiple products in one message, use the Send WhatsApp interactive multi-product message (opens in a new tab) endpoint.

Add multiple recipients and multiple messages

If you want to send multiple messages to multiple recipients in one request, use a WhatsApp template message (opens in a new tab).

Track message delivery

Once you send the request, you should receive a WhatsApp message on the handset you've specified in the to field and see a 200 OK response.

json
{
  "to": "441134960001",
  "messageCount": 1,
  "messageId": "a28dd97c-1ffb-4fcf-99f1-0b557ed381da",
  "status": {
    "groupId": 1,
    "groupName": "PENDING",
    "id": 7,
    "name": "PENDING_ENROUTE",
    "description": "Message sent to next instance"
  }
}

The response informs you that the message has successfully been queued within the Infobip platform and will be then sent to Meta depending on the throughput.

If you want to know whether it's been delivered to the recipient, use the Delivery Report (opens in a new tab) feature.

Troubleshoot and analyze your message

For troubleshooting and analytics, use the auto-generated messageId to view the message and its details.

Catch the answer

Once a user interacts with your message, your webhook that's listening to that event will catch the reply. The message object will tell you what happened. In this case, the user has selected the product, checked it out, and sent the basket back as a reply.

json
{
  "results": [
    {
      "from": "447415774332",
      "to": "447860099299",
      "integrationType": "WHATSAPP",
      "receivedAt": "2022-09-05T08:27:43.211+0000",
      "messageId": "ABEGRHQVd0QyAhCBxs0yCyJSa8s4pXro5xeI",
      "pairedMessageId": null,
      "callbackData": null,
      "message": {
        "catalogId": "1634406623431551",
        "productItems": [
          {
            "currency": "USD",
            "itemPrice": 2,
            "productRetailerId": "tennis-12345",
            "quantity": 1
          }
        ],
        "type": "ORDER"
      },
      "contact": {
        "name": "Joanna Suau"
      },
      "price": {
        "pricePerMessage": 0.0,
        "currency": "EUR"
      }
    }
  ],
  "messageCount": 1,
  "pendingMessageCount": 0
}

Need assistance

Explore Infobip Tutorials

Encountering issues

Contact our support

What's new? Check out

Release Notes

Unsure about a term? See

Glossary
Service status

Copyright @ 2006-2026 Infobip ltd.

Service Terms & ConditionsPrivacy policyTerms of use