简体   繁体   中英

cant send a Generic Template from messenger api (facebook)

im developing a chatbot whith messenger facebook, i already have the Greeting Text, a menu (no working yet), and a get started button, when i try testing to recive a generic template, it simply does nothing, if i change the response, a simple text, it response that text, but the generic template not, i copy the example from here: https://developers.facebook.com/docs/messenger-platform/thread-settings

i dont know why a cant get the generic template, if i configure to response with an image, buttons, text, all of that is sended, but the template not, this is how i configure the resonse:

$response = '{
  "recipient":{
    "id":"'.$senderId.'"
  },
  "message":{
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"generic",
        "elements":[
           {
            "title":"Sin saber, vivió casi un mes entre muertos",
            "image_url":"https://diario.mx/imagesnotas/2017/01/LOC1307270af08088b_0.jpg",
            "subtitle":"Desde el lunes empezó a hacer oración para el descanso de las almas torturadas y sepultadas, afirma",
            "default_action": {
              "type": "web_url",
              "url": "https://diario.mx/Local/2017-01-05_f62a689b/sin-saber-vivio-casi-un-mes-entre-muertos/",
              "messenger_extensions": true,
              "webview_height_ratio": "tall",
              "fallback_url": "https://diario.mx/"
            } ,
            "buttons":[
              {
                "type":"web_url",
                "url":"https://diario.mx/",
                "title":"Ir a diario.mx"
              },{
                "type":"postback",
                "title":"Start Chatting",
                "payload":"DEVELOPER_DEFINED_PAYLOAD"
              }              
            ]      
          }
        ]
      }
    }
  }
}';

is trigered by a custom payload "masleidas" from quick_replies option

According to the docs subtitle has a character limit of 80 and your example shows 99 characters in subtitle. So I think it's too many characters.

Do you get any error returned from the FB API to your chatbot?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM