Instantly share code, notes, and snippets.

Embed
What would you like to do?
//...
firebase.initializeApp(functions.config().firebase);
exports.waterLog = functions.https.onRequest((request, response) => {
//Initialise app dependencies
const dialogflowApp = new DialogflowApp({request, response});
const userManager = new UserManager(firebase);
const waterLog = new WaterLog(firebase, userManager);
const conversation = new Conversation(dialogflowApp, userManager, waterLog);
//Define map of Dialogflow agent Intents
let actionMap = new Map();
actionMap.set(Actions.ACTION_WELCOME, () => conversation.actionWelcomeUser());
actionMap.set(Actions.ACTION_LOG_WATER, () => conversation.actionLogWater());
actionMap.set(Actions.ACTION_GET_LOGGED_WATER, () => conversation.actionGetLoggedWater());
//Handle request from Dialogflow (will be dispatched into appropriate action defined above)
dialogflowApp.handleRequest(actionMap);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment