You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Dialogflow助手完成Webhook fulfillment后退出流程问题求助

Fixing Dialogflow Webhook Exit Issue & Passing Parameters to Next Intent

Hey Arun, let's work through this problem together! The core issue here is that by default, Dialogflow assumes the conversation wraps up once your Webhook sends a response. To keep the flow going and pass those location/name parameters to the next intent, here's what you need to do:

1. Use Contexts to Persist Parameters

Contexts are Dialogflow's built-in way to store conversation state across multiple intents. You'll want to save the extracted name and location into a context so the next intent can easily access them later.

Update your Webhook code to set a context with the parameters:

'use strict';
const functions = require('firebase-functions');
const { WebhookClient } = require('dialogflow-fulfillment');

function handleUserInfoIntent(agent) {
  // Pull the parameters you've already extracted
  const userName = agent.parameters.name;
  const userLocation = agent.parameters.location;

  // Create a context to hold the parameters (adjust lifespan based on your needs)
  agent.context.set({
    name: 'user_details_context',
    lifespanCount: 3, // How many conversation turns this context stays active
    parameters: {
      name: userName,
      location: userLocation
    }
  });

  // Send a friendly confirmation to the user
  agent.add(`Got it ${userName}! I have your location as ${userLocation}. What would you like to do next?`);
}

// Register your intent handler
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  const agent = new WebhookClient({ request, response });
  const intentMap = new Map();
  intentMap.set('YourFirstIntentName', handleUserInfoIntent); // Replace with your actual intent name
  agent.handleRequest(intentMap);
});

2. Keep the Conversation Going (Two Options)

Option A: Automatically Trigger the Next Intent

If you want to jump straight to the next intent without waiting for user input, use setFollowupEvent in your Webhook. This tells Dialogflow to immediately route the conversation to the intent tied to that event.

Add this line right after setting the context and sending the user message:

agent.setFollowupEvent({
  name: 'trigger_next_action', // Pick a unique, descriptive event name
  parameters: {
    name: userName,
    location: userLocation
  }
});

Then, in your Dialogflow console:

  • Open your next intent
  • Under the "Events" section, add the exact event name (trigger_next_action)
  • Set user_details_context as an Input Context for this intent to access the saved parameters

Option B: Let User Input Trigger the Next Intent

If you want the user to initiate the next step (e.g., "Book a restaurant" or "Find nearby cafes"), just configure your next intent to:

  • Include relevant training phrases that match user follow-up requests
  • Have user_details_context added as an Input Context
  • Mark the name and location parameters as required (they'll auto-populate from the context)

3. Verify the Webhook Response

Double-check that your Webhook isn't returning errors, and that the context is properly included in the response. You can use the Dialogflow console's Test tab to inspect the Webhook response and confirm the context is present with the correct parameters.

By setting a persistent context and either triggering a follow-up event or configuring the next intent to use the context, you'll keep the conversation flowing and pass those parameters seamlessly.

内容的提问来源于stack exchange,提问作者Arun Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:01:30