Webhook for slot filling

If you enabled slot filling for an intent, you can optionally enable fulfillment to handle missing, required parameters. To use a webhook for slot filling, follow these steps:

  1. Check the option Enable webhook call for slot filling in the Fulfillment section of the intent.

  2. Click SAVE.

    Your webhook is called every time Dialogflow detects a missing, required parameter.

  3. Inspect the parameters object in the request sent to the webhook to determine which required parameter values have been collected. Values that have not yet been collected will be sent as empty strings.

The following code snippet using Dialogflow Fulfillment Library shows how you can use a webhook to inspect parameters and dynamically create slot filling prompts:

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {

  const agent = new WebhookClient({ request, response });

  function flight(agent) {
    const city = agent.parameters['geo-city'];
    const time = agent.parameters['time'];
    const gotCity = city.length > 0;
    const gotTime = time.length > 0;

    if(gotCity && gotTime) {
        agent.add(`Nice, you want to fly to ${city} at ${time}.`);
    } else if (gotCity && !gotTime) {
        agent.add('Let me know which time you want to fly');
    } else if (gotTime && !gotCity) {
        agent.add('Let me know which city you want to fly to');
    } else {
        agent.add('Let me know which city and time you want to fly');

  let intentMap = new Map();
  intentMap.set('flight', flight);