将数据从Webhook对话框流传递到有角度的应用程序

时间:2018-12-04 22:44:47

标签: angular firebase webhooks dialogflow dialogflow-fulfillment

我的角度应用程序中的webhooks确实存在全球性问题。我不明白这个概念。我可以在自己的Assets文件夹中正确实现,但是我不知道如何与之交互,尤其是从dialogflow获得响应。

我正在处理这个项目:https://github.com/mlabouardy/dialogflow-angular5

但是我不能再使用dialogflow V1,因为我无法随时删除上下文。

所以我想实现这个“基本的” webhook:https://github.com/dialogflow/fulfillment-webhook-nodejs

我可以按照自己的资产进入webhooks.js

const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');

process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  const agent = new WebhookClient({ request, response });
  console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
  console.log('Dialogflow Request body: ' + JSON.stringify(request.body));

  function welcome (agent) {
    agent.add(`Welcome to my agent!`);
  }

  function fallback (agent) {
    agent.add(`I didn't understand`);
    agent.add(`I'm sorry, can you try again?`);
  }

但是已经3周了,我对如何调用或将webhooks.js导入我的应用程序一无所知。我试图这样导入它:

enter image description here

感谢您的帮助。罗曼(Romain)

0 个答案:

没有答案