【问题标题】:Dialogflow fulfillment not responding to keywordsDialogflow 实现未响应关键字
【发布时间】:2021-08-02 23:08:34
【问题描述】:

我试图弄清实现的工作原理,但我无法从 if 语句中获得响应。每当我编写关键字时,我得到的默认响应是不可用。 意图的 webhook 已启用,实体也被“挂钩”在意图中。 我在这里错过了什么?

const functions = require('firebase-functions');
const { dialogflow } = require('actions-on-google');
const app = dialogflow();

const WELCOME_INTENT = 'Default Welcome Intent';
const USER_MESSAGE_ENTITY = 'UserMessage';

app.intent(WELCOME_INTENT, (conv) => {
  const userMessage = conv.parameters(USER_MESSAGE_ENTITY).toLowerCase();
  if (userMessage == 'hey') {
    conv.ask('Hey there');
  } else if (userMessage == 'greetings') {
    conv.ask('Greetings, how are you');
  } else if (userMessage == 'evening') {
    conv.ask('Good evening');
  }
});

exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);

{
  "responseId": "8499a8f2-b570-4fb2-9f3c-262bd03db01e-c4f60134",
  "queryResult": {
    "queryText": "hey",
    "action": "input.welcome",
    "parameters": {
      "UserMessage": "hey"
    },
    "allRequiredParamsPresent": true,
    "intent": {
      "name": "projects/wandlee-zad-rekrutacyjne--euol/agent/intents/d76ffc6c-c724-4fa4-8c9b-7178a2d7f9b7",
      "displayName": "Default Welcome Intent"
    },
    "intentDetectionConfidence": 1,
    "diagnosticInfo": {
      "webhook_latency_ms": 76
    },
    "languageCode": "pl",
    "sentimentAnalysisResult": {
      "queryTextSentiment": {
        "score": 0.2,
        "magnitude": 0.2
      }
    }
  },
  "webhookStatus": {
    "code": 14,
    "message": "Webhook call failed. Error: UNAVAILABLE."
  }
}

【问题讨论】:

  • 您在哪里进行了测试?在 Dialogflow 控制台或 Google 控制台上的操作中?可以编辑您的帖子并包含测试屏幕截图吗?
  • 我只在对话框右侧的控制台中运行它。我已附上控制台的屏幕截图 + 诊断信息
  • 我明白了。由于您的代码使用conv.ask(),我假设您的目标是使用 Google 上的 Actions。您可以在 Actions on Google 模拟器中对此进行正确测试。您可以查看此git repository 以了解 Actions on Google 示例。

标签: javascript dialogflow-es actions-on-google dialogflow-es-fulfillment


【解决方案1】:

我不知道你从哪里得到conv.parameters(USER_MESSAGE_ENTITY)

意图的参数可以访问as a second function argument。这将是一张地图:

app.intent(WELCOME_INTENT, (conv, params) => {
  const userMessage = params[USER_MESSAGE_ENTITY].toLowerCase();
  // ...
})
``

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多