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

Google Actions转账流程异常:第三步意图无法触发

Fixing Google Actions Transfer Flow Context Issue

It looks like your problem stems from two key issues: incorrect context naming/case sensitivity and missing output context setup in the second intent. Let's break this down and fix it step by step.

Root Causes

  1. Context Case Mismatch: You mentioned the first intent outputs transferMoney-followup, but in your second intent code, you're trying to fetch transfermoney-followup (all lowercase for "transfermoney"). Dialogflow context names are case-sensitive, so this not only breaks parameter retrieval but can also confuse intent matching.

  2. Missing Output Context in Second Intent: Your second intent is supposed to output transferMoneyFromAccount-followup to trigger the third intent, but your code doesn't actually set this context. Without it, the third intent's input context requirement isn't met—so when the user selects an option from the third list, Dialogflow falls back to the second intent (which still has the active transferMoney-followup context) instead of triggering the third one.

Step-by-Step Fixes

1. Fix Context Case Consistency

First, standardize your context names to avoid case issues. Let's use transferMoney-followup (camelCase) consistently everywhere:

Update the second intent's parameter retrieval code:

// Replace transfermoney-followup with transferMoney-followup
let amount = conv.contexts.get("transferMoney-followup").parameters.amount;

2. Add Output Context to the Second Intent

In your transferMoney.FromAccount intent, add code to set the transferMoneyFromAccount-followup context (this is what tells Dialogflow the user is ready for the third step). We'll also store the amount and fromAccountId in this context so the third intent can access them easily:

app.intent('transferMoney.FromAccount', (conv, params, option) => {
  let amount = conv.contexts.get("transferMoney-followup").parameters.amount;
  let fromAccountId = option;
  
  // Set the output context for the third step
  conv.contexts.set('transferMoneyFromAccount-followup', 5, {
    amount: amount,
    fromAccountId: fromAccountId
  });

  conv.ask("Let's send that " + amount + " from " + fromAccountId);
  conv.ask("Where should we send them to ?");
  
  // ... rest of your list building code remains the same
});

3. Update the Third Intent to Use the Context Parameters

Right now your third intent has hardcoded values for amount, fromAccountId, and toAccountId—replace those with the values stored in the context:

app.intent('transferMoney.FromAccount.ToAccount', (conv, params, option) => {
  // Fetch the context set by the second intent
  const transferContext = conv.contexts.get('transferMoneyFromAccount-followup');
  const amount = transferContext.parameters.amount;
  const fromAccountId = transferContext.parameters.fromAccountId;
  const toAccountId = option; // This is the selected target account ID

  conv.ask(`Let's send that ${amount} from ${fromAccountId} to ${toAccountId}`);
});

4. Verify Dialogflow Console Intent Configs

Double-check your intent settings in the Dialogflow console to match:

  • First intent (transferMoney):
    • Output context: transferMoney-followup (with appropriate lifespan, e.g., 5)
  • Second intent (transferMoney.FromAccount):
    • Input context: transferMoney-followup
    • Output context: transferMoneyFromAccount-followup
    • Trigger event: actions_intent_OPTION
  • Third intent (transferMoney.FromAccount.ToAccount):
    • Input context: transferMoneyFromAccount-followup
    • Trigger event: actions_intent_OPTION

Why This Works

By setting the transferMoneyFromAccount-followup context in the second intent, you're explicitly telling Dialogflow that the user has moved to the third step. When the user selects an option from the third list, Dialogflow will prioritize the third intent (since its input context is active) instead of falling back to the second intent.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 08:21:17