簡體   English   中英

Dialogflow Webhook實現未返回響應

[英]Dialogflow webhook fulfillment not returning response

我正在建立一個聊天機器人,我想對地址進行一些驗證(荷蘭的郵政編碼必須寫為[1234XX]。但是在我的意圖和網絡掛接被調用之后,對話什么也沒有返回。它只是說“空響應”

在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)

我正在運行的代碼如下:

'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);
});

看起來像是agent.handleRequest(intentMap); 不滿意,但我不知道如何解決這個問題,我一直在努力嘗試整天都能在網上找到的一切...

在此處輸入圖片說明

我認為您的歡迎函數處理程序帶有下划線,其中不應有下划線,而應是:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM