本文为您介绍WhatsApp消息模板Payload参数的使用说明。
Payload说明
Payload与WhatsApp消息模板中的使用按钮触发消息有关。
假如消息模板中包含两个quick_reply按钮,在发送消息时给payload传入[payload1,payload2],当用户点击按钮1时,Chat App会将payload1返回,可通过返回的参数值获知用户点击的是哪个按钮。
参数说明
名称 | 类型 | 必填 | 描述 | 示例值 |
Payload | array | 否 | 按钮的触发消息。 | [payloadtext1,payloadtext2,payloadtext3] |
Payload | string | 否 | 模板中按钮的触发消息。 | payloadtext1,payloadtext2,payloadtext3 |
代码示例
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();
返回示例
{
"Context":{"from":"****","id":"****"},
"Type":"REPLY",
"Message":"{\"payload\":\"payload1\",\"text\":\"****\"}",
"CustSpaceId":"***",
"From":"***",
"To":"***",
"Timestamp":****,
"WabaId":"***",
"MessageId":"****",
"Name":"***"
}
相关文档
SendChatappMassMessage - 批量发送 Chat App 消息