Dialogflow fulfillment 不响应关键字

Dialogflow fulfillment not responding to keywords

我试图弄清楚实现的工作原理,但我无法从 if 语句中得到响应。每当我写关键字时,我得到的默认响应是 Not available。 启用了意图的 webhook,意图中的实体也是 'hooked'。 我在这里错过了什么?

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."
  }
}

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

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

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