Receive Responses From Customers

After receiving Multi or Single product messages, users can: ask for more information about a product, add products to a shopping cart, and place an order. The best way to track a customer’s response to a message is by checking the webhooks alerts received for a specific message.

After sending a message, you get a message status notification webhook mentioning the status of that message. A sample webhook for successfully sent business-initiated conversation looks like this:

{
  "object": "whatsapp_business_account",
  "entry": [{
    "id": "WHATSAPP_BUSINESS_ACCOUNT_ID",
    "changes": [{
    "value": {
    "messaging_product": "whatsapp",
    "metadata": {
      "display_phone_number": "PHONE_NUMBER",
      "phone_number_id": "PHONE_NUMBER_ID"
      },
    "statuses": [{
      "id": "wamid.ID",
      "recipient_id": "PHONE_NUMBER",
      "status": "sent",
      "timestamp": "TIMESTAMP",
      "conversation": {
        "id": "CONVERSATION_ID",
        "expiration_timestamp": TIMESTAMP,
        "origin": {
          "type": "business_initated"
          }
        },
      "pricing": {
        "pricing_model": "CBP",
        "billable": true,
        "category": "business_initated"
        }
      }] 
    },
    "field": "messages"
    }]
 }]
}

Save that message ID to track how customers are receiving that message.

Asking For Information

Whenever a customer receives a Multi or Single Product Message, they can ask for more information about that specific product. There are two ways customers can use to ask for information:

  • Text message: The customer sends a text message asking for more information after receiving a product.
  • Clicking Message Business: The customer goes to a product's Product Detail Page (PDP) and clicks on the Message Business button.

Once the customer sends a question, the business gets an inbound message webhook notification. These notifications include a messages object with the following components:

ComponentDescription

type

For this use case, type will be set to text.

text

The question and/or comments raised by the customer.

context

Information about the product being mentioned by the customer. You can see a product’s unique identifier as well as their catalog ID.

The webhook will look like this:

{
  "object": "whatsapp_business_account",
  "entry": [
    {
      "id": "ID",
      "changes": [
        {
          "value": {
              "messaging_product": "whatsapp",
              "metadata": {
                   "display_phone_number": "PHONE_NUMBER",
                   "phone_number_id": "PHONE_NUMBER_ID",
              },
              "contacts": [
                {
                  "profile": {
                    "name": "NAME"
                  },
                  "wa_id": "PHONE_NUMBER_ID"
                }
              ],
              "messages": [
                {
                  "from": "PHONE_NUMBER",
                  "id": "wamid.ID",
                  "text": {
                    "body": "MESSAGE_TEXT"
                  },
                  "context": {
                    "from": "PHONE_NUMBER",
                    "id": "wamid.ID",
                    "referred_product": {
                      "catalog_id": "CATALOG_ID",
                      "product_retailer_id": "PRODUCT_ID"
                    }
                  },
                  "timestamp": "TIMESTAMP",
                  "type": "text"
                }
              ]
          },
          "field": "messages"
        }
      ]
    }
  ]
}

Use the webhook information to respond to the customer's query.

Placing an Order

Once customers have added a product to their shopping cart, they can send that cart to the business to complete the order. A business knows they have received an order by keeping up with their webhook notifications.

These notifications are of the order type and they include a messages object with the following components:

ComponentDescription

type

For this use case, type will be set to order.

order

Information about the products added to the customer’s shopping cart. The order object contains the catalog ID and an array called product_item, inside which you can find the list of products added to cart.

The webhook will look like this:

{
  "object": "whatsapp_business_account",
  "entry": [
    {
      "id": "8856996819413533",
      "changes": [
        {
          "value": {
              "messaging_product": "whatsapp",
              "metadata": {
                   "display_phone_number": "16505553333",
                   "phone_number_id": "phone-number-id",
              },
              "contacts": [
                {
                  "profile": {
                    "name": "Kerry Fisher"
                  },
                  "wa_id": "16315551234"
                }
              ],
              "messages": [
                {
                  "from": "16315551234",
                  "id": "wamid.ABGGFlCGg0cvAgo6cHbBhfK5760V",
                  "order": {
                    "catalog_id": "the-catalog_id",
                    "product_items": [
                      {
                        "product_retailer_id":"the-product-SKU-identifier",
                        "quantity":"number-of-item",
                        "item_price":"unitary-price-of-item",
                        "currency":"price-currency"
                      },
                      ...
                    ],
                    "text":"text-message-sent-along-with-the-order"
                  },
                  "context": {
                    "from": "16315551234",
                    "id": "wamid.gBGGFlaCGg0xcvAdgmZ9plHrf2Mh-o"
                  },
                  "timestamp": "1603069091",
                  "type": "order"
                }
              ]
          },
          "field": "messages"
        }
      ]
    }
  ]
}

Use the webhook information to prepare the customer's order.