I am using the dialogflow enterprise edition bot,the issue is about receiving responses from rest api(node.js sdk).Recently we have shifted from dialogflow standard edition to Enterprise edition. We have referred and used the following code in this link


We have created our own cloud function using rest Api which takes the user answer as the request and send the fulfillment text(questions in that particular intent) as the response to the user.When multiple request calls happen the the cloud function is not showing proper response which means

When user(Android/IOS) "A" started answering the bot then the cloud function triggering gets started and it send the questions as the response to the user but when the multiple users started answering the bot, due to multiple calls for the cloud function, the questions which are displayed to the one user are not going to be displayed to the other user say "B". Please help us in handling the multiple calls for node.js sdk

https://i.stack.imgur.com/BVAci.png This is the view of an intent in dialogflow.

https://i.stack.imgur.com/aRAr6.png ,

 Above five screenshots represent the first time when the user triggers 
 the cloud function, and the 1st question is displayed. When we answer the 
 first question and submit the answer, next question is not displayed.(I am 
 getting the empty response).  

https://i.stack.imgur.com/rLI2I.png , https://i.stack.imgur.com/T5wZL.png

These screenshots represent the empty response after first question is answered.

const functions = require('firebase-functions');
const dialogflow = require('dialogflow');
const Firestore = require('@google-cloud/firestore');
const firestore = new Firestore();
var db = admin.firestore();
const {WebhookClient} = require('dialogflow-fulfillment');

exports.fulfillmenttext = functions.https.onRequest((req,res) =>{

  async function runSample() {
    const projectId = 'bodha-192606';
    const sessionId = uuid.v4();
    const answer = req.body.Text;
    console.log("Text said by the user",answer);
    const languageCode = 'en-US';
    const credentials = {
      client_email: 'xxxx ',
      Private_key:'xxxx ',
    // Instantiate a DialogFlow client.
    const dialogflow = require('dialogflow');
    const sessionClient = new dialogflow.SessionsClient({
    // Define session path
    const sessionPath = sessionClient.sessionPath(projectId, sessionId);
    // The text query request.
    const request = {
      session: sessionPath,
      queryInput: {
        text: {
          text: answer,
    const responses = await sessionClient.detectIntent(request);
    console.log('Detected intent');
    const result = responses[0].queryResult;
    let action = result.action;
    console.log("action is"+action);
    console.log(` Query: ${result.queryText}`);
    console.log(` Response: ${result.fulfillmentText}`);
    if (result.intent) {
      console.log(` Intent: ${result.intent.displayName}`);
    } else {
      console.log(` No intent matched.`);
      res.status(400).send("No Intent matched");

1 Answers

Prisoner On

It looks like you are using the same session ID for all of your clients. I'm not certain, but I can certainly understand that if Dialogflow gets two requests for the same session at the same time, that it can mix up the replies.

You should be generating a new session for each of your clients - possibly by putting something into an HTTP session (aha!) cookie when they first connect and continuing to use that during the session.