Bots 使用Dialogflow代理从Messenger Webview检索回发

Bots 使用Dialogflow代理从Messenger Webview检索回发,bots,dialogflow-es,Bots,Dialogflow Es,我被困在这里了。我正试图从Facebook Messenger聊天机器人中打开的网络视图中获得回帖,我正在使用NodeJS与DialoFlow的实现库一起开发该聊天机器人 我能够发送打开特定URL的有效负载,如下所示: { "facebook": { "attachment": { "type": "template", "payload": { "template_type": "button", "text": "So yo

我被困在这里了。我正试图从Facebook Messenger聊天机器人中打开的网络视图中获得回帖,我正在使用NodeJS与DialoFlow的实现库一起开发该聊天机器人

我能够发送打开特定URL的有效负载,如下所示:

{
  "facebook": {
    "attachment": {
      "type": "template",
      "payload": {
        "template_type": "button",
        "text": "So you want to open the webview huh?",
        "buttons": [{
            "type": "web_url",
            "url": "https://somewebsiteurlwithdataiwanttoget.como",
            "title": "Open Website",
            "messenger_extensions": true  // To get psid and close window event
          }]
      }
    }
  }
}
在我的webview中,我可以使用jQueryAjax:

let jqxhr = $.ajax({
    url: '/webhook',  // Fires my webhook
    data: { var1: 'Hello', var2: 'World' }, // Sent to my webhook
    dataType: 'json'
});
在我的webook中,我初始化我的代理,并使用自定义事件将此数据发送回Messenger机器人(PS:I正在使用Express)

但是,我在控制台中收到一个错误,说“
此请求不是有效的Dialogflow请求
”。我不确定我做错了什么,我希望有人能帮助我


谢谢。

发送json
{var1:'Hello',var2:'World'}
是这里的问题。 WebhookClient希望'req'参数遵循一个模式,可以如下所示:

 {
    "responseId": "e72a8020-1051-489d-acb4-95c9ebeadcb7-ee1dc704",
    "queryResult": {
    "queryText": "view appointment",
    "parameters": {
    },
    "allRequiredParamsPresent": true,
    "fulfillmentText": "Hi here you go.",
    "fulfillmentMessages": [
     .
     .
    ],
    "intent": {
      "name": "projects\/proj1\/agent\/intents\/77f38791-f2da-41bd-b44f-cef190d26fd9",
      "displayName": "2-show-appointments"
    },
    "intentDetectionConfidence": 1,
    "languageCode": "en"
  },
  "originalDetectIntentRequest": {
    "source": "GOOGLE_TELEPHONY",
    "payload": {
      "telephony": {
        "caller_id": "Anonymous"
      }
    }
  },
  "session": "projects\/proj1\/iKawldQ1RFSBIckQfGKww"
}
其中包含有关接收到的消息、检测到的意图和实现负载的信息。您无权更改架构

此外,这种方法是不可行的。根据,dialogflow在messenger平台中没有webview事件的回调

 {
    "responseId": "e72a8020-1051-489d-acb4-95c9ebeadcb7-ee1dc704",
    "queryResult": {
    "queryText": "view appointment",
    "parameters": {
    },
    "allRequiredParamsPresent": true,
    "fulfillmentText": "Hi here you go.",
    "fulfillmentMessages": [
     .
     .
    ],
    "intent": {
      "name": "projects\/proj1\/agent\/intents\/77f38791-f2da-41bd-b44f-cef190d26fd9",
      "displayName": "2-show-appointments"
    },
    "intentDetectionConfidence": 1,
    "languageCode": "en"
  },
  "originalDetectIntentRequest": {
    "source": "GOOGLE_TELEPHONY",
    "payload": {
      "telephony": {
        "caller_id": "Anonymous"
      }
    }
  },
  "session": "projects\/proj1\/iKawldQ1RFSBIckQfGKww"
}