This topic describes the usage notes on the Payload parameter of a WhatsApp message template.
Description of the Payload parameter
A payload is returned when the related button in the WhatsApp message template is tapped.
For example, when you send messages based on a WhatsApp message template that contains two quick reply buttons, you set the Payload parameter to Payload 1 for Button 1 and Payload 2 for Button 2. As a result, Payload 1 is returned after Button 1 is tapped by customers. You can determine which button is tapped based on the returned payload.
Parameters
Parameter | Type | Required | Description | Example |
Payload | array | No | The payload of the button. | |
string | No | The payload of the button in the message template. | payloadtext1,payloadtext2,payloadtext3 |
Sample code
SendChatappMessageRequest sendChatappMessageRequest = new SendChatappMessageRequest();
sendChatappMessageRequest.setChannelType("whatsapp");
sendChatappMessageRequest.setFrom("****");
sendChatappMessageRequest.setTo("****");
sendChatappMessageRequest.setCustSpaceId("******");
sendChatappMessageRequest.setType(SendType.TEMPLATE.getName());
sendChatappMessageRequest.setLanguage("**");
sendChatappMessageRequest.setTemplateCode("*****");
Map<String, String> templateParams = new HashMap<>();
templateParams.put("variable1", "pre_auto1");
templateParams.put("variable2", "pre_auto2");
sendChatappMessageRequest.setTemplateParams(templateParams);
List<String> payload = new ArrayList<>();
payload.add("payload1");
payload.add("payload2");
sendChatappMessageRequest.setPayload(payload);
SendChatappMessageResponse sendChatappMessageResponse = ChatAppClient.instance().sendChatappMessage(sendChatappMessageRequest);
SendChatappMessageResponseBody body = sendChatappMessageResponse.getBody();
Sample response
{
"Context":{"from":"****","id":"****"},
"Type":"REPLY",
"Message":"{\"payload\":\"payload1\",\"text\":\"****\"}",
"CustSpaceId":"***",
"From":"***",
"To":"***",
"Timestamp":****,
"WabaId":"***",
"MessageId":"****",
"Name":"***"
}