简体   繁体   English

Dialogflow Webhook实现未返回响应

[英]Dialogflow webhook fulfillment not returning response

I am building a chatbot, and i want to do some validation on address (zipcodes in the netherlands have to be written like [1234XX]. But after my intent and the webhook is being called nothing is being returned to the conversation. It just says "empty response" 我正在建立一个聊天机器人,我想对地址进行一些验证(荷兰的邮政编码必须写为[1234XX]。但是在我的意图和网络挂接被调用之后,对话什么也没有返回。它只是说“空响应”

In Firebase the following error comes up: 在Firebase中,出现以下错误:

Error: No handler for requested intent
    at WebhookClient.handleRequest (/user_code/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:287:29)
    at exports.dialogflowFirebaseFulfillment.functions.https.onRequest (/user_code/index.js:49:9)
    at cloudFunction (/user_code/node_modules/firebase-functions/lib/providers/https.js:26:47)
    at /var/tmp/worker/worker.js:689:7
    at /var/tmp/worker/worker.js:673:9
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickDomainCallback (internal/process/next_tick.js:128:9)

The code i am running is the following: 我正在运行的代码如下:

'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = 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 woningwaarde_instant_function (agent) {
    // get the employee ID parameter from the request header received from Dialogflow
    let zipcode = agent.parameters.zipcode;
    if (zipcode.length === 6) { 
        agent.add(`The length of the Employee ID should be six characters. Please enter the correct ID.`); 
    } else { agent.add('lengte van postcode == 6'); }
  }

  function welcome (agent) {
    agent.add(`Welcome to my agent!`);
    agent.add(agent.request_.body.queryResult.fulfillmentText);
  }

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

  // Run the proper function handler based on the matched Dialogflow intent name
  let intentMap = new Map();
  intentMap.set('woningwaarde_instant', woningwaarde_instant_function);
  intentMap.set('Default Welcome Intent', welcome);
  intentMap.set('Default Fallback Intent', fallback);
  agent.handleRequest(intentMap);
});

It seems like agent.handleRequest(intentMap); 看起来像是agent.handleRequest(intentMap); Doesn't satisfy but i have no clue how to fix this and i have been trying everything i could find online all day long... 不满意,但我不知道如何解决这个问题,我一直在努力尝试整天都能在网上找到的一切...

在此处输入图片说明

我认为您的欢迎函数处理程序带有下划线,其中不应有下划线,而应是:

    agent.add(request.body.queryResult.fulfillmentText);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM