【问题标题】:Sending a button response to fb messenger via api.ai通过 api.ai 向 fb messenger 发送按钮响应
【发布时间】:2017-12-11 15:56:29
【问题描述】:

我已经开始使用带有 fb messenger 集成的 diaglofFlow a.k.a api.ai。

我定义了一个当前返回 3 个响应的意图。 2 个文本响应和 1 个自定义负载。

两个文本响应很好,但假设返回按钮的自定义有效负载不是。

自定义负载看起来像

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

另外,请注意收件人 ID 是我不确定应该如何提供的东西。 fb文档说它应该是收件人的号码。我不知道我将如何得到它?

【问题讨论】:

  • 当用户向您的页面发送消息时,您会获得(收件人)ID ...

标签: facebook facebook-messenger dialogflow-es


【解决方案1】:

其实这样可以的

{
 "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 是用户的页面范围 ID。当用户发起对话时,您会在 webhook 事件的 sender.id 属性中收到它。

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

    【讨论】:

    • 感谢您的回复。但是,就我而言,当用户键入消息时,它会通过 webhook 进入对话流。现在假设对话流使用 psid 进行响应。但是我看不到在作为自定义响应响应时应该在我的对话流中的哪里访问它?
    猜你喜欢
    • 2023-04-04
    • 2015-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多