0
"type": "postback",
"title": "What can Chatbots do",
"payload": "One day Chatbots will control the Internet of Things! You will be able to control your homes temperature with a text",
 }, {
 "type": "postback",
 "title": "The Future",
 "payload": "Chatbots are fun! One day your BFF might be a Chatbot",
  }],

When for example, a user clicks 'The Future' the app sends a message to user in the form of

Postback received: {"payload":"Chatbots are fun! One day your BFF might be a Chatbot"}

How can I change it so that It just sends that in message form?

user3776662
  • 199
  • 1
  • 10

1 Answers1

0

Payload is just for your reference such that when a user clicks on a button, you receive the payload in your webhook. Then you can send back any message you wish. For e.g., you can have the buttons as:

[{"type": "postback",
    "title": "What can Chatbots do",
    "payload": "payload_1",
    }, 
    {
    "type": "postback",
    "title": "The Future",
    "payload": "payload_2",
    }]

And in your webhook you can send back the messages using:

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")
}
}
Anupam Mohanty
  • 460
  • 1
  • 6
  • 11