如何在Dialogflow中创建Facebook轮播作为“自定义有效载荷”

问题描述 投票:0回答:1

我想在不使用webhook的情况下使用Dialogflow创建一个样机Facebook Bot。

可以在Dialogflow中定义特定于通道的答案。您可以在其中选择预定义的响应类型或自定义有效负载。简单按钮的自定义有效负载有效,但是当我尝试创建caroussel时,什么也没有发生。

https://developers.facebook.com/docs/messenger-platform/send-messages/template/generic#carousel

我在哪里可以找到Dialogflow支持什么,什么不支持?如何使用自定义有效载荷来构建卡鲁塞尔卡?

{
  "facebook": {
    "attachment": {
      "type": "template",
      "payload": {
        "template_type": "generic",
        "elements": [
          {
            "title": "Welcome!",
            "image_url": "https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png",
            "subtitle": "We have the right hat for everyone.",
            "default_action": {
              "type": "web_url",
              "url": "https://commons.wikimedia.org/wiki/File:Example.png",
              "messenger_extensions": false,
              "webview_height_ratio": "tall",
              "fallback_url": "https://website.com/"
            },
            "buttons": [
              {
                "type": "web_url",
                "url": "https://commons.wikimedia.org/wiki/File:Example.png",
                "title": "View Website"
              },
              {
                "type": "postback",
                "title": "Start Chatting",
                "payload": "DEVELOPER_DEFINED_PAYLOAD"
              }
            ]
          }
        ]
      }
    }
  }
}
dialogflow facebook-messenger facebook-messenger-bot dialogflow-fulfillment
1个回答
0
投票

如果您从JSON中删除messenger_extensionsfallback_url,它应该可以正常工作。

通过使用dialogflow中的自定义有效负载,只要您发送正确的对应通道json,一切都受支持

这是轮播(多个元素)的经过工作测试的示例

{
 "facebook":{
  "attachment":{
     "type":"template",
     "payload":{
        "template_type":"generic",
        "elements":[
           {
              "title":"Welcome!",
              "image_url":"https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png",
              "subtitle":"We have the right hat for everyone.",
              "default_action":{
                 "type":"web_url",
                 "url":"https://www.google.com/",
                 "webview_height_ratio":"tall"
              },
              "buttons":[
                 {
                    "type":"web_url",
                    "url":"https://www.google.com/",
                    "title":"View Website"
                 },
                 {
                    "type":"postback",
                    "title":"Start Chatting",
                    "payload":"DEVELOPER_DEFINED_PAYLOAD"
                 }
              ]
           },
               {
              "title":"Welcome!",
              "image_url":"https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png",
              "subtitle":"We have the right hat for everyone.",
              "default_action":{
                 "type":"web_url",
                 "url":"https://www.google.com/",
                 "webview_height_ratio":"tall"
              },
              "buttons":[
                 {
                    "type":"web_url",
                    "url":"https://www.google.com/",
                    "title":"View Website"
                 },
                 {
                    "type":"postback",
                    "title":"Start Chatting",
                    "payload":"DEVELOPER_DEFINED_PAYLOAD"
                 }
              ]
           },
               {
              "title":"Welcome!",
              "image_url":"https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png",
              "subtitle":"We have the right hat for everyone.",
              "default_action":{
                 "type":"web_url",
                 "url":"https://www.google.com/",
                 "webview_height_ratio":"tall"
              },
              "buttons":[
                 {
                    "type":"web_url",
                    "url":"https://www.google.com/",
                    "title":"View Website"
                 },
                 {
                    "type":"postback",
                    "title":"Start Chatting",
                    "payload":"DEVELOPER_DEFINED_PAYLOAD"
                 }
              ]
           }
        ]
     }
  }
 }
 }
© www.soinside.com 2019 - 2024. All rights reserved.