Payload仅供您参考,以便当用户点击按钮时,您会在webhook中收到有效负载。然后您可以发回任何您想要的消息。 例如,您可以将按钮设置为:
[{"type": "postback", "title": "What can Chatbots do", "payload": "payload_1", }, { "type": "postback", "title": "The Future", "payload": "payload_2", }]
在您的webhook中,您可以使用以下命令发回消息:
if (event.postback) { var text = JSON.stringify(event.postback.payload) if(text === "\"payload_1\""){ sendTextMessage(sender, "One day Chatbots will control the Internet of Things! You will be able to control your homes temperature with a text") } else if (text === "\"payload_2\""){ sendTextMessage(sender, "Chatbots are fun! One day your BFF might be a Chatbot") } }