Shubhang Arora
Shubhang Arora

Reputation: 290

How to store data in conversation using Dialogflow webhook

I am using dialogflow webhook and want to store data in conversation.

Below is what i understood from dialogflow docs

response.setHeader('Content-Type', 'application/json');
   response.send(JSON.stringify({
    "payload": {
        "google": {
          "expectUserResponse": true,
          "richResponse": {
            "items": [
              {
                "simpleResponse": {
                  "textToSpeech": "OKAY"
                }
              }
            ]
          }, 
          "conversationToken" : "count=1"
        }
      }
   }))

This does not work as the JSON from the next request does not have this stored value.

Upvotes: 0

Views: 837

Answers (1)

Abhinav Tyagi
Abhinav Tyagi

Reputation: 5256

You can check my complete answer here. In short use contexts to store parameters.

Use the output context to save parameters

{  
  "fulfillmentText":"This is a text response",
  "fulfillmentMessages":[  ],
  "source":"example.com",
  "payload":{  
    "google":{  },
    "facebook":{  },
    "slack":{  }
  },
  "outputContexts":[  
    {  
      "name":"<Context Name>",
      "lifespanCount":5,
      "parameters":{  
        "<param name>":"<param value>"
      }
    }
  ],
  "followupEventInput":{  }
}

Upvotes: 1

Related Questions