【问题标题】:WebhookClient.add() is not working anymoreWebhookClient.add() 不再工作
【发布时间】:2018-07-01 09:33:25
【问题描述】:

我正在使用 DialogFlow 的内联编辑器。在 webhook 中,我通过 WebhookClient.add() API 将来自谷歌助手的语音响应发送给用户。但它现在似乎没有工作。我知道 V2 API 已经发布并且现在正式发布。我以为我正在使用 V2 API。看起来不是。请告诉我WebhookClient.add() 的替代方案。我尝试使用conv,但它也不起作用。这是我的使用方法:

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));
  const conv = agent.conv();

  function welcome(agent) {
    agent.add('Welcome to MY AGENT');//This and the next line are not sending speech output.Earlier it was working fine
    agent.add('This is the Webhook');
    conv.ask('Welcome to My agent');
    conv.ask('This is the Webhook!');
  }
let intentMap = new Map(); // Map functions to Dialogflow intent names
intentMap.set('Default Welcome Intent', welcome);
agent.handleRequest(intentMap);
}

请帮我看看这是怎么回事。 更新:添加意图映射

【问题讨论】:

  • 您能否详细说明“它现在似乎不起作用”?你有任何错误吗?
  • 我没有收到任何错误。我检查了日志。即使是Dialog flow(温度转换器)给出的样本也不起作用。
  • 您的代码 sn-p 非常混乱。我不确定你为什么同时使用agent.add 和conv.ask,因为我认为你应该只使用其中一个。

标签: node.js webhooks actions-on-google dialogflow-es


【解决方案1】:

好的,您正在尝试通过实现使某些意图包含响应,因此您需要确保为您想要包含 agent.add() 的所有意图启用切换 Enable webhook call for this intent方法。
此外,您应该只将 conv 用于 Actions on Google 的特定功能。

'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 welcome (agent) {
    agent.add(`Hey buddy, welcome to my agent!`);
  }

  let intentMap = new Map();
  intentMap.set('Default Welcome Intent', welcome);
  agent.handleRequest(intentMap);
});

【讨论】:

    猜你喜欢
    • 2013-03-16
    • 2012-04-11
    • 2018-06-01
    • 2016-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多