0

I have managed to retrieve the context variables from the webhook using dialogflow-fulfillment agent.context.get() function however it does not provide the context variables that aren't set as input in that specific intent.

Intent A: "What city are you in?"

  • Through Dialogflow UI, the output context placeholder 'city' is set .
  • User answers => "Montréal"
  • Here I set the output context 'city' with the following code through the fulfiller:

agent.context.set('city', 100, {cityName: "Montréal"})

Intent B: "When will it freeze?"

  • Intentionally, no input/output context is set on Dialogflow. As I want the user to be able to ask this question without context.
  • When the intent is matched, Dialogflow sends the following request to my fullfiler.

{ "responseId": "496a4ed8-8421-4297-b464-adc54632cc93-32d6a6f2", "queryResult": { "queryText": "when will it freeze", "parameters": {}, "allRequiredParamsPresent": true, "fulfillmentText": "It will freeze next week", "fulfillmentMessages": [ { "text": { "text": [ "It will freeze next week" ] } } ], "intent": { "name": "projects/project-name/locations/global/agent/intents/7df0bb1d-f4ef-4e69-b9c4-4b6a2f91c95f", "displayName": "zone.freezing_dates via Fulfiller" }, "intentDetectionConfidence": 1, "diagnosticInfo": { "webhook_latency_ms": 59 }, "languageCode": "fr", "sentimentAnalysisResult": { "queryTextSentiment": { "score": 0.1, "magnitude": 0.1 } } }, "webhookStatus": { "message": "Webhook execution successful" }, "agentId": "5d8b71c7-cd3a-453a-b446-6d00334f1ae8" }

As you can see, the context parameters aren't present in the webhook request even though the city parameter has been set by intent A).

Therefore, how do we retrieve the context variables from the user's session (and not from the intent's webhook)?

I have a feeling it has to do with the agent session path as described here but in this sample, it's part of the intent (again) as I expect a way to retrieve the agent context outside of the intent's scope.

I will also add as a note, I know the city context var exists because I can see it through the Dialogflow UI when I add it to the response text.

Alextoul
  • 839
  • 3
  • 9
  • 19

0 Answers0