Dialogflow-fulfillment-nodejs: cancel or delete outgoing context?

Created on 5 May 2018  路  2Comments  路  Source: dialogflow/dialogflow-fulfillment-nodejs

I am not sure if it is intended or not. In current design and implementation, I can only set outgoing context, but not allowed to cancel or delete contexts in webhook via this DF fulfillment sdk. Also, I noticed that DF agent will merge outgoing context set via webhook and all incoming context to outgoing contexts for an intents. This means the only way we can cancel an existing context via web interface inside the intent configuration by setting lifespan to 0 in the outgoing contexts.

Again I am wondering if this is intended. It would be nice to be able to manage contexts, especially those initiated by developers in webhook via for example setContext(), also via webhook.

Thanks.

Most helpful comment

You can set an existing contexts with the library and set the lifespan to 0 to "cancel or delete" an outgoing context. For example:

const existingContext = agent.getContext("incoming context name")
agent.setContext({'name': existingContext.name, 'lifespan': 0})

If you've set a context with the library and wish to prevent it from being sent to Dialogflow as a outgoing context you can use the clearOutgoingContexts() or clearContext("context name") methods.

All 2 comments

You can set an existing contexts with the library and set the lifespan to 0 to "cancel or delete" an outgoing context. For example:

const existingContext = agent.getContext("incoming context name")
agent.setContext({'name': existingContext.name, 'lifespan': 0})

If you've set a context with the library and wish to prevent it from being sent to Dialogflow as a outgoing context you can use the clearOutgoingContexts() or clearContext("context name") methods.

I'm sorry if this is too late, but can we put this information on the official guide?
Thank you so much for the answer and I think it will be better if this kind of information can be available on the guide too.

Was this page helpful?
0 / 5 - 0 ratings