All Products
Search
Document Center

Chat App Message Service:Usage notes on the Payload parameter

Last Updated:Aug 21, 2024

This topic describes how to use the Payload parameter of a WhatsApp message template.

Description of the Payload parameter

Payload is related to using a button to trigger a message in a WhatsApp message template.

Assume that the message template contains two quick_reply buttons and [payload1,payload2] is passed to the payload when the message is sent. When the user clicks button 1, Chat App returns payload1. The returned parameter value indicates which button the user clicked.

Description

Element

Type

Required

Description

Example

Payload

array

No

The payload of the button.

[payloadtext1,payloadtext2,payloadtext3]

Payload

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":"***"
}

References

SendChatappMassMessage -Batch Send Chat App Messages

SendChatappMessage -Send Chat App Messages

Configure message receipts