You can set parameters programmatically in your fulfillment webhook by setting the needed context's and their parameters. Note that this is not the intended use of slot filling.
Dialogflow by default creates 3 output contexts when filling in parameters
<intentId>_id_dialog_context
<intentname>_dialog_context
<intentname>_dialog_params_<parameterName>
You can find these contexts by using Webhookclient.contexts
Note that the context containing the parameterName will change according to which parameter is being asked for by Dialogflow.
For instance, if you fill in parameter a1, dialog will ask for a2. The context will be <intentname>_dialog_params_a2
All of these contexts contain the parameters needed for the intent.
You can programmatically set these parameters using this approach:
- Users fills in a1
- In your webhook, determine if a2 should be asked or skipped
- if it should be asked, do nothing or send in a different prompt using
webhookClient.add(responses)
if it should be skipped:
- set both
_dialog_context
contexts using
webhookClient.setContext(context)
- while setting them, send in the parameter a2 as something being not
null
- remove the context _params_a2
- set context _params_a3, with the same parameters
Probably your parameters now look something like:
{a1 : 'someUserValue', a2 : 'someValueByWebhook', a3 : ''}
By doing this Dialogflow already has a value for a2, and won't ask for it again