Sending a button response to fb messenger via api.ai

别来无恙 提交于 2020-12-16 08:05:20

问题


I have started playing with diaglofFlow a.k.a api.ai with fb messenger integration.

I defined an intent which current returns 3 responses. 2 text responses and 1 custom payload.

the 2 text responses comes just fine but the custom payload which is suppose to return a button is not.

the custom payload looks like

{
  "recipient": {
    "id": "1234"
  },
  "message": {
    "attachment": {
      "type": "template",
      "payload": {
        "template_type": "button",
        "text": "What do you want to do next?",
        "buttons": [
          {
            "type": "web_url",
            "url": "https://www.messenger.com",
            "title": "Visit Messenger"
          }
        ]
      }
    }
  }
}

Also, please note that the recipient id is something i am not sure how it should be provided. the fb documentation says it should be number of the recipient. I do not know how i am going to get that?


回答1:


actually this works

{
 "facebook": {
   "attachment": {
   "type": "template",
   "payload": {
     "template_type": "button",
     "text": "What do you want to do next?",
     "buttons": [
      {
        "type": "web_url",
        "url": "https://www.messenger.com",
        "title": "Visit Messenger"
      }
     ]
   }
 }
}
}



回答2:


recipient.id is the user's Page-scoped ID. You receive it in the sender.id prop of webhook events when the user initiates a conversation.

https://developers.facebook.com/docs/messenger-platform/introduction/integration-components#psid



来源:https://stackoverflow.com/questions/47715183/sending-a-button-response-to-fb-messenger-via-api-ai

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!