Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset Context in DialogFlow V2

I would like to know how to reset contexts in DialogFlow V2. I m currently using V2 and writing the backend codes in node.js.

like image 459
Abhinav Kaimal Avatar asked Jul 09 '18 07:07

Abhinav Kaimal


People also ask

What is context lifespan in Dialogflow?

Lifespan. Each active context has a lifespan that defines the number of conversational turns for which the context remains active. The default lifespan is five conversational turns for normal intents and two conversational turns for follow-up intents. You can override the default lifespan for any contexts.

How many types of context are there in Dialogflow?

You might not have realized this, but there are actually three types of Dialogflow contexts.

What are contexts in Dialogflow?

Dialogflow contexts are similar to natural language context. If a person says to you "they are orange", you need context in order to understand what "they" is referring to. Similarly, for Dialogflow to handle an end-user expression like that, it needs to be provided with context in order to correctly match an intent.


2 Answers

Got the Solution Myself:- There are several ways to clear contexts:

  1. In a detectIntent query, you can set resetContexts to "true".
  2. To reset contexts when testing in the Dialogflow test console, click the 'RESET CONTEXTS' button.
  3. In order to reset all contexts in an intent, click on the 'X' button in the 'Contexts' section below the intent name. The contexts will be cleared after the intent completion.
  4. If you want to reset an individual context in the intent, set the context lifespan value to 0.
  5. You can also use our /contexts endpoint to perform these operations programmatically: https://dialogflow.com/docs/reference/api-v2/rest/v2/projects.agent.sessions.contexts.
  6. For resetting contexts via webhook, use the "outputContexts" field in the response from the web service: https://dialogflow.com/docs/reference/v1-v2-migration-guide-fulfillment#webhook_responses. Note that the contexts will be updated after the intent completion.
like image 85
Abhinav Kaimal Avatar answered Sep 27 '22 22:09

Abhinav Kaimal


It depends exactly what you mean by "reset contexts", but if you want to remove a context from being considered during the next user statement, you can set the context's lifespan to 0.

like image 33
Prisoner Avatar answered Sep 27 '22 20:09

Prisoner