【问题标题】:How to reach back to previous intent in dialogflow from current intent?如何从当前意图回到对话流中的先前意图?
【发布时间】:2019-12-16 12:24:32
【问题描述】:

我一直在做一个关于对话流的项目。我正在构建一个聊天机器人,用户需要在其中插入一系列信息,最后将信息发送到 webhook。 为此,我一直在构建一系列后续意图。就像

用户名意图(主要意图)

电话号码意图(用户名的后续意图,用户插入用户名后出现)

我想做的是在收到用户名并联系电话号码后更改用户名。

例如:

Bot:您好,输入您的用户名。 用户:大卫 Bot:你输入了大卫作为你的名字。 输入 -1 更改您的姓名。输入你的电话号码。 用户:-1 Bot:Hello 插入您的用户名(达到相同的意图)

我需要一个适当的解决方案来解决它。 我尝试使用之前的选择进行跟进,但无法获得解决方案。

提前谢谢你。

【问题讨论】:

    标签: node.js dialogflow-es chatbot dialogflow-es-fulfillment


    【解决方案1】:

    将事件添加到您的 enter-name Intent 中,以便您可以在用户键入 -1 时从履行函数中调用它。

    为您提示用户输入电话号码的后续意图启用 webhook 调用。并在您的履行功能中执行以下操作:

    function getPhone(agent) {
       const phoneNumber = agent.parameters.phonenumber;
       if (phoneNumber == -1) {
          agent.add(`Okey, going back`); // This won't print as the followup intent will trigger instanty but you still need to add a response to your agent.
          return agent.setFollowupEvent('change_username');
       } else {
          return agent.add(`You entered ${phoneNumber} as your phone number.`); 
       }
    }
    
    let intentMap = new Map();
    intentMap.set('enter-phonenumber', getPhone); // where 'enter-phonenumber' is the name of your intent which gathers phonenumbers
    agent.handleRequest(intentMap);
    

    启用 webhook:https://cloud.google.com/dialogflow/docs/tutorials/build-an-agent/create-fulfillment-using-webhook


    否则,您可能希望查看以下内容:https://www.youtube.com/watch?v=xxSa9g3ripQ

    如果用户突然输入by the way, my name is Eric 并在其中捕捉到它,您只需继续前进并收集所需信息并准备好带有活动上下文的意图。

    【讨论】:

    • 好吧,当用户输入 -1 时,webhook 不接受它并抛出一个错误,例如响应未定义,因为它不匹配任何意图。我也尝试过回退,但不起作用
    • 您有电话号码的自定义实体吗?在这种情况下,请尝试识别 @sys.integer。
    • 是的,我也尝试过保留 sys.number 但不起作用。它抛出同样的错误
    • 奇怪,我可以在@sys.integer 上匹配“-1”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-26
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多