Example: 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: The URL is in format https://[ip address of RI VU]:[TCP Port number of https of RestfulInterfaces]/RI/cmi/messages. You can find the values for the RI placeholders in the Restful Interfaces module in System Configurator ( ). The example JSON code below includes the definition proxy: no because it uses a local RI.
- 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 can only use basic authentication. Make sure your service account has permission for Messaging for the queue used.
- 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", "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" }, "proxy": "no" } }
This example code is for outbound conversations:
{ "request": { "authentication": { "type": "basic" }, "method": "POST", "proxy": "no", "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" } } }