TransWikia.com

How can i save the fulfillmentText in dialogflow to firebase?

Stack Overflow Asked by Reniel Mallari on December 1, 2021

I am new in Learning Dialogflow, What i am trying is to save the conversation of user and the bot.

i can already save the user response to the bot but i also want to save the bot response to the firebase.

my code is like this

  function HandleSaveToDB(agent){

    return admin.database().ref('data').push({
        bot_response: request.body.queryResult.queryText,
        user_response: request.body.fulfillmentText 
    });
    
  }

the bot_response is saving but the user_response is not saving.

here is the response of the JSON

{
  "responseId": "50359194-cadb-44a4-b649-ebd8e4606fea-425db6e2",
  "queryResult": {
    "queryText": "Hi i am paul i need help",
    "parameters": {
      "given-name": "Paul",
      "text": ""
    },
    "allRequiredParamsPresent": true,
    "fulfillmentText": "Hi Paul how can i help you today?",
    "fulfillmentMessages": [
      {
        "text": {
          "text": [
            "Hi Paul how can i help you today?"
          ]
        }
      }
    ],
    "intent": {
      "name": "projects/chatsimulator-rttunh/agent/intents/dbc7dbf8-ca8d-4f7a-86b5-a0e6eab7e0b5",
      "displayName": "Greetings"
    },
    "intentDetectionConfidence": 1,
    "diagnosticInfo": {
      "webhook_latency_ms": 4992
    },
    "languageCode": "en"
  },
  "webhookStatus": {
    "code": 4,
    "message": "Webhook call failed. Error: DEADLINE_EXCEEDED."
  }
}

One Answer

I'm presuming you're talking about a Fulfillment function being hit here.

The fulfillmentText is actually located in request.queryResult.fulfillmentText, despite what you see as the output from the diagnostic info.

Please see the spec for the fulfillment request and the queryResult property of that request.

Answered by James King on December 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP