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.
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.
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:
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.