I'm completely new to DialogFlow.. I wanted to create a chat bot that I can ask a question to and it would respond with a value retrieved from my Firebase Firestore database.
I've already created the necessary intent (GetPopulationInCity) and selected Enable webhook call for this intent
Preferably I would like to use the DialogFlow Fulfillment alongside my other CloudFunction app.
I've used the code in the following example:
'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(`Welcome to my agent!`);
}
function GetPopulationInCity(agent) {
//Search Firestore for value, if found =>
agent.add(`There are 10,000 people living in XXX`); //should it be ask or something like send or return?
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Get Population', GetPopulationInCity);
intentMap.set('Default Fallback Intent', fallback);
agent.handleRequest(intentMap);
});
but I have no clue how to create a handler for my intent and return a value. Is there anyone who could help me out?