本文為您介紹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 消息
文檔內容是否對您有幫助?