title: How to respond to a selected button in Facebook Messenger
body: <p>I'm trying to program my bot in Facebook Messenger to respond with a text after a user selects a button. I've read that it's possible by handling the payload of a postback type of button, but I can't seem to get it to work</p>
  
  <pre><code>app.post('/webhook/', function (req, res) {
   let messaging_events = req.body.entry[0].messaging
   for (let i = 0; i &lt; messaging_events.length; i++) {
      let event = req.body.entry[0].messaging[i]
      let sender = event.sender.id
      if (event.message &amp;&amp; event.message.text) {
          let text = event.message.text
          if (text === 'poorita') {
              sendPooritaMessage(sender)
              sendTextMessage(sender, "Here are some restaurants near you: ")
              continue
          } else if (text === 'budget') {
              sendBudgetMessage(sender)
              continue
          } else if (text === 'bot') {
              sendBotMessage(sender)
              continue
          } else if (text === 'hungry na me') {
              sendHelloMessage(sender)
              continue
          } else if (text === 'location') {
              sendLocationMessage(sender)
              continue
          }
          sendTextMessage(sender, "Text received :), echo: " + text.substring(0, 200))
      } else if (event.postback &amp;&amp; event.postback.payload) {
          let payload = event.postback.payload
          if (payload === 'payload_1') {
              sendTextMessage(send, "It worked!")
              continue
          }
      }
  }
  res.sendStatus(200)})
  
  function sendBotMessage(sender) {
  let messageData = {
      "attachment": {
          "type": "template",
          "payload": {
              "template_type": "button",
              "text": "Regular or special?",
              "buttons": [
              {
                  "type": "postback",
                  "payload": "payload_1",
                  "title": "Regular"
              },
              {
                  "type": "web_url",
                  "title": "Special",
                  "url": "https://www.messenger.com"
              }]
          }
      }
  }
  request({
      url: 'https://graph.facebook.com/v2.6/me/messages',
      qs: {access_token:token},
      method: 'POST',
      json: {
          recipient: {id:sender},
          message: messageData,
      }
  }, function(error, response, body){
      if (error) {
          console.log('Error sending message: ', error)
      } else if (response.body.error) {
          console.log('Error: ', response.body.error)
      }
  })}
  </code></pre>
  
  <p>I'm trying create an output like this
  <a href="http://i.stack.imgur.com/IhBTa.png" rel="nofollow">enter image description here</a></p>