Skip to content

Instantly share code, notes, and snippets.

@frogermcs
Created October 26, 2017 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frogermcs/51ba29a7cf0794848e153e21166a7e9c to your computer and use it in GitHub Desktop.
Save frogermcs/51ba29a7cf0794848e153e21166a7e9c to your computer and use it in GitHub Desktop.
//...
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