Vik
Vik

Reputation: 9289

Sending a button response to fb messenger via api.ai

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?

Upvotes: 0

Views: 1485

Answers (2)

Vik
Vik

Reputation: 9289

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"
      }
     ]
   }
 }
}
}

Upvotes: 2

amuramoto
amuramoto

Reputation: 2848

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

Upvotes: 0

Related Questions