【问题标题】:Dialogflow V2 Messenger Integration with Multiple MessagesDialogflow V2 Messenger 与多条消息的集成
【发布时间】:2017-12-06 16:11:10
【问题描述】:

我试图在一个 Webhook 调用中向 Dialogflow 发送多条消息,这些消息将传递给 Messenger。现在我的 Webhook 以一个有问题的 JSON 主体响应:

{
    'fulfillmentText': "Text",
    'fulfillmentMessages': [{
        "platform": "facebook",
        "text": [{
            "text": "Text"
        }]
    }],
    'source': "facebook"
}

当我通过 Messenger 测试 Webhook 时,我看到 正在输入 符号,但从未收到 Text 消息。从 Dialogflow 控制台测试相同的 Webhook 时,我得到了

Webhook 执行成功

返回。我想我缺少一些 JSON 字段来告诉 Dialogflow 必须以哪种格式将 JSON 发送到 Messenger API。有人知道如何解决这个问题吗?


编辑: 我最新的无效试用...

{
  "fulfillmentText": "Hola!",
  "fulfillmentMessages": [
    {
      "text": {
        "text": [
          "Title: this is a title"
        ]
      },
      "platform": "FACEBOOK"
    },
    {
      "text": {
        "text": [
          "Title: this is a title"
        ]
      },
      "platform": "FACEBOOK"
    }
  ]
}

【问题讨论】:

    标签: facebook-messenger-bot dialogflow-es


    【解决方案1】:

    如果您只发送文本,您只需向fulfillmentText 提供一个字符串,而不必提供fulfillmentMessages 属性。

    如果您确实为目标平台提供了fulfillmentMessages 属性,Dialogflow 会将您的有效负载发送到 Facebook。在这种情况下,有效负载无效,Facebook 中实际上不会显示任何消息。删除响应 JSON 的 fulfillmentMessages 属性,您的机器人应该响应。

    如果您想在回复中添加卡片,可以发送以下回复:

    {
      "fulfillmentMessages": [
        {
          "platform": "FACEBOOK",
          "card": {
            "title": "Title: this is a title",
            "subtitle": "This is an subtitle.  Text can include unicode characters including emoji ?.",
            "imageUri": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
            "buttons": [
              {
                "text": "This is a button",
                "postback": "https://assistant.google.com/"
              }
            ]
          }
        }
      ]
    }
    


    编辑:如果您想发送多条消息,您可以通过发送这样的响应来实现(此 JSON 将发送两张相同的卡片,但您可以根据 this documentation 更改消息类型(卡片/文本/等)):
    {
      "fulfillmentMessages": [
        {
          "platform": "FACEBOOK",
          "card": {
            "title": "Title: this is a title",
            "subtitle": "This is an subtitle.  Text can include unicode characters including emoji ?.",
            "imageUri": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
            "buttons": [
              {
                "text": "This is a button",
                "postback": "https://assistant.google.com/"
              }
            ]
          }
        },
        {
          "platform": "FACEBOOK",
          "card": {
            "title": "Title: this is a title",
            "subtitle": "This is an subtitle.  Text can include unicode characters including emoji ?.",
            "imageUri": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
            "buttons": [
              {
                "text": "This is a button",
                "postback": "https://assistant.google.com/"
              }
            ]
          }
        }
      ]
    }
    

    【讨论】:

    • 是的,这就是我现在正在做的事情。但我想发送多条消息,我也可以在对话框流控制台中添加文本响应。
    • 其实你的编辑正是我在做什么!我没有使用卡片,而是使用文本对象,但 Dialogflow 没有响应。我将我的行为发布为编辑。你能检查一下你是否看到任何错误吗?如果不是,我很确定问题出在 Dialogflows 方面!
    【解决方案2】:

    我向 Dialogflow 支持发送了有关此问题的邮件,结果表明目前无法从 webhook 发送多条消息。

    嗨,

    此时,无法直接发送顺序消息 来自网络钩子。但是,如果您使用我们的一键式 支持丰富消息的集成,您可以在 其中多个消息通过事件从 webhook 定义为 描述于 https://dialogflow.com/docs/events#invoking_event_from_webhook

    如果您有任何问题,请告诉我。

    问候,来自 Dialogflow 的 Ankita

    【讨论】:

    • 如果您在可以发送多条消息时收到回复,请更新您的帖子并告诉我:)
    • 这有改变吗?我认为我们仍然无法发送多条消息...
    猜你喜欢
    • 2020-09-28
    • 1970-01-01
    • 2019-01-27
    • 1970-01-01
    • 2018-11-05
    • 2022-11-05
    • 1970-01-01
    • 2021-02-17
    • 1970-01-01
    相关资源
    最近更新 更多