Skip to content

Store multiple parameters from different Intents

I have an issue saving multiple parameters from different intents in dialogflow firebase fullfillment. I’ve tried declaring a global variable to store the data there but to no avail . here is what I have so far.

I would like to save the parameters from multiple intents to a firebase db

    'use strict';

const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const requestLib = require('request');

const admin = require('firebase-admin');
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 });
  const timestamp =new Date().toLocaleString();
  let MyData = {};

  function getTeamHandler(agent) { = ;
      MyData.user_id =;

  function getPwiHandler(agent) {
      MyData.pwi = agent.parameters.with_pwi ;
      return admin.database().ref('/spo').push({temp:,user_id :MyData.user_id,with_pwi : MyData.pwi,timestamp:timestamp}).then((snapshot) => {
      agent.add(`Please wait for the response for code : ${}`);

  let intentMap = new Map();
  intentMap.set('', getTeamHandler);
  intentMap.set('2.pwi', getPwiHandler);



You can use context to save/use data across multiple intents. You need to set output context and then in next webhook request you can get context what you have set in previous intent