Default Welcome Intent - search
Let's create a search intent for getting the search term our users want to start their search.
Steps
// See https://github.com/dialogflow/dialogflow-fulfillment-nodejs
// for Dialogflow fulfillment library docs, samples, and to report issues
"use strict";
const functions = require("firebase-functions");
const { WebhookClient } = require("dialogflow-fulfillment");
const { Card, Suggestion } = 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(
`Hello! Welcome to the GDG Cloud directory conversational app. Would you like to find a lead by 1. Name, 2. Skill`
);
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
function getSearchTerm(agent) {
if (agent.parameters.search_terms == 1) {
agent.add(`What's the GDG Cloud lead's name?`);
} else {
agent.add(`Which skill are you looking for?`);
}
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set("Default Welcome Intent", welcome);
intentMap.set("Default Fallback Intent", fallback);
intentMap.set("Default Welcome Intent - search", getSearchTerm);
agent.handleRequest(intentMap);
}
);Explanation:
Follow-up intent Explanation
Last updated