Send a customer a satisfaction (CSAT) survey

In this example, we'll send a customer a satisfaction survey after a WhatsApp conversation is over.

You can also use this example to send feedback after a conversation is over or has been abandoned.

Note:

This example uses the /cmi/messages resource to send a template message. Make sure you use a WhatsApp approved template in the message.

For this integration, you'll need to configure the following:

  • Events: To send the survey after a conversation is over, select Ended.
  • Endpoint URL:

    Public address of your Contact Management Interface (CMI) messages resource

  • Conversation Direction: You can use this example for both inbound and outbound conversations. You'll find examples below for both directions.
  • Queues: As this example is for WhatsApp, you should use WhatsApp queues.
  • Authentications: In this example, you must use:
    • basic authentication credentials

      Make sure your service account has permission for Messaging for the queue used.

    • the API key of your restful interfaces
  • JSON for configuration: See the example code blocks below. Note the following:
    • "address": "{contact.source}" and "address": "{contact.destination}" will refer to the customer's phone number in this WhatsApp example
    • value formatting is used in message!js (JSON string) and language_code!sl (lowercase string)
    • "source": "{contact.destination}" refers to the original queue address.
    • Language is only relevant if your WhatsApp message template exists for different languages.
    • In the outbound example, replace [whatsapp-queue-address] with the address of the WhatsApp queue you're using in the integration.

    This example code is for inbound conversations:

    {
      "request": {
        "authentication": {
          "type": "basic"
        },
        "method": "POST",
        "headers": {
          "x-api-key": "{authentications.api-key}"
        },
        "body": {
          "destinations": {
            "destination": [
              {
                "address": "{contact.source}"
              }
            ]
          },
          "message!js": {
            "type": "template",
            "template_id": "csat_survey",
            "template_body": "Dear Customer, we would greatly appreciate if You could spare a couple of minutes to...",
            "language_code!sl": "{contact.language}"
          },
          "source": "{contact.destination}",
          "subType": "{contact.channel_sub_type}",
          "contentType": "template"
        }
      }
    }

    This example code is for outbound conversations:

    {
      "request": {
        "authentication": {
          "type": "basic"
        },
        "method": "POST",
        "headers": {
          "x-api-key": "{authentications.api-key}"
        },
        "body": {
          "destinations": {
            "destination": [
              {
                "address": "{contact.destination}"
              }
            ]
          },
          "message!js": {
            "type": "template",
            "template_id": "csat_survey",
            "template_body": "Dear Customer, we would greatly appreciate if You could spare a couple of minutes to...",
            "language_code!sl": "{contact.language}"
          },
          "source": "[whatsapp-queue-address]",
          "subType": "{contact.channel_sub_type}",
          "contentType": "template"
        }
      }
    }