通用模板和列表模板不起作用

The generic template and list template didn't work

我正在关注 facebook messenger develop QuickStart 创建一个 Node.js 项目,我改进了它以快速回复工作。然后当我尝试了Generic Template和List Template,但是没有用。

如下源码,当我输入作品"generic"或"list"时,信使会回复我模板信使。但是什么也没有发生。

 } else if (received_message.text === 'generic') {
  console.log('generic in');
  response = {
      "attachment":{
        "type":"template",
        "payload":{
       "template_type":"generic",
       "elements":[
          {
         "title":"Welcome!",
         "image_url":"http://webapplication120181023051009.azurewebsites.net/colorcar1.jpg",
         "subtitle":"We have the right hat for everyone.",
         "default_action": {
           "type": "web_url",
           "url": "https://www.taobao.com/",
           "messenger_extensions": false,
           "webview_height_ratio": "tall",
           "fallback_url": "https://www.taobao.com/"
        },
        "buttons":[
          {
         "type":"web_url",
         "url":"https://www.taobao.com/",
         "title":"View Website"
          },{
         "type":"postback",
         "title":"Start Chatting",
         "payload":"DEVELOPER_DEFINED_PAYLOAD"
          }              
        ]      
         }
       ]
        }
      }
     }
          
  // Sends the response message
  callSendAPI(sender_psid, response);  
  
  
  // Sends response messages via the Send API
function callSendAPI(sender_psid, response) {
  // Construct the message body
  let request_body = {
    "recipient": {
      "id": sender_psid
    },
    "message": response
  }
  
  console.log('PAGE_ACCESS_TOKEN:');
  console.log(PAGE_ACCESS_TOKEN);
  console.log('request body:');
  console.log(request_body);
  
  // Send the HTTP request to the Messenger Platform
  request({
    "uri": "https://graph.facebook.com/v2.6/me/messages?access_token=" + PAGE_ACCESS_TOKEN,
    "qs": { "access_token": PAGE_ACCESS_TOKEN },
    "method": "POST",
    "json": request_body
  }, (err, res, body) => {
    if (!err) {
      console.log('message sent!')
    } else {
      console.error("Unable to send message:" + err);
    }
  }); 
}

抱歉,我忘了将 url 添加到白名单中。