javascriptdialogflow-esactions-on-googledialogflow-es-fulfillment

Dialogflow fulfillment not responding to keywords


I am trying to make sense of how the fulfillment works, and I cannot get the responses from the if statements to work. Whenever I write the keyword, the default response I get is Not available. The webhook for the intent is enabled, the entity is 'hooked' in the intent as well. What am I missing here?

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

Default Welcome Intent

Entity

enter image description here

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

Solution

  • I don't know where you got conv.parameters(USER_MESSAGE_ENTITY).

    The parameters of the intent are accessible as a second function argument. It is going to be a map:

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