To sum up the problem I was facing with Dialogflow integration with Firebase, The user input isn't publishing onto the Firebase/cloud FireStore when it should. I am intending the parameter that I named Locations to be published into the collection I named as Location.
First, I followed a tutorial in which the user enables slot filling for the intent which I have done. The Intent name is Location.
Next, on Firebase I opened up the database which corresponded with my bot project ID and created a collection with the identifier name: Location.
Next I attempted to publish the user input for the parameter (named Locations) using the inline editor
package.json Code:
{
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "8"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^2.12.0",
"firebase-admin": "^9.0.0",
"firebase-functions": "^3.9.0",
"dialogflow": "^1.2.0",
"dialogflow-fulfillment": "^0.6.1"
}
}
nodejs code:
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const admin = require('firebase-admin');
admin.initializeApp();
const db = admin.firestore();
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
function getLocationHandler(agent) {
let location = agent.parameters.location;
db.collection("Location").add({ Location: location });
}
let intentMap = new Map();
intentMap.set('Location', getLocationHandler);
agent.handleRequest(intentMap);
});