按钮postback messenger bot未在heroku

时间:2018-04-02 09:39:12

标签: javascript node.js facebook messenger facebook-messenger-bot

我有点挣扎,我把按钮的有效负载如下......但它没有传输到服务器,

消息对象

        let message = {
          "attachment":{
          "type" : "template",
          "payload" : {
              "template_type" : "generic",
              "elements" : [
              {
                "title" :  "title",
                "buttons": [{
                              "type": "postback",
                              "title": "wishlist",
                              "payload": "wishlist"
                          },
                  ],
                },
               ],
            }
          }
      }

和发送功能

function sendMessage(recipientId, message) {
  request({
   url: "https://graph.facebook.com/v2.6/me/messages",
   qs: {access_token: process.env.PAGE_ACCESS_TOKEN},
   method: "POST",
   sender_action :"typing_on",
   json: {
     recipient: {id: recipientId},
     message: message,
   }
}, function(error, response, body) {
     if (error) {
       console.log("Error sending message: " + response.error);
  }
 });
} 

1 个答案:

答案 0 :(得分:0)

您无法在同一请求中发送sender_action和消息,因此收件人永远不会收到您的消息。