Dialogflow - Google Assistant:显示消息后 setFollowupEvent

Mar*_*lla 6 node.js actions-on-google dialogflow-es

这是我的用例:在我的实现中的某个地方,在处理意图 A 时,我想使用 调用意图setFollowupEventB。就像是:

function intentA_Handler(){
    ....
    agent.add('This is the response when calling Intent A');
    agent.setFollowupEvent('call_intent_B_event');
}

function intentB_Handler(){
    agent.add('I am in intent B now.');
    ....
}
Run Code Online (Sandbox Code Playgroud)

我期待什么:

  1. 助手显示并说出字符串这是调用 Intent A 时的响应
  2. 然后打电话并显示并说出我现在处于意图 B 中的agent.setFollowupEvent('call_intent_B_event');字符串。

会发生什么:

助手立即向我显示并说出我现在在意图 B 中的字符串,并省略第一个字符串这是调用意图 A 时的响应

已经尝试过:

function intentA_Handler(){
    ....
    new Promise((resolve, reject) => {
        agent.add('This is the response when calling Intent A');
        resolve();
    });

    agent.setFollowupEvent('call_intent_B_event');
}
Run Code Online (Sandbox Code Playgroud)

但结果还是一样。知道如何实现我的目标吗?

Leo*_*lls 2

这是预期的行为。后续事件返回到 Dialogflow,而不是 Google 平台上的 Actions。第二个意图响应将作为来自代理的唯一响应返回给助手。

如果您使用 Actions on Google 客户端库 ( https://developers.google.com/actions/reference/nodejsv2/overview ),它可以通过后续事件传递参数:https://actions-on -google.github.io/actions-on-google-nodejs/classes/dialogflow.dialogflowconversation.html#followup 您可以使用参数值来跟踪要包含在最终响应中的其他信息。