如何重置参数值,以便代理可以再次请求参数? [英] How to reset a parameter value so agent can ask for the parameter again?

查看:91
本文介绍了如何重置参数值,以便代理可以再次请求参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个dialogflow代理,并在其中创建了多个意图。一种这样的意图要求两个参数:account和balance_type。
然后将webhook请求发送到写入代码的位置,以检查数据库中是否存在该帐号。如果这样做,它将获取余额并发回给用户。
现在,如果帐号不存在,我必须要求用户再次输入帐号( account的值)。对如何实现它有任何想法吗?

I have created a dialogflow agent and multiple intents in it. One such intent asks for 2 parameters : account and balance_type. It then sends the webhook request where the code is written to check if the account number exists in the DB. If it does it fetches the balance and sends back to the user. Now in case the account number does not exist, i have to ask the user to again enter the account number (value for "account") only. Any thoughts on how i can achieve it ?

推荐答案

您将需要在这里使用上下文。如果首先收集了帐户参数,则可以像下面这样继续操作:

You will need to play with context here. If your account parameter is collected first you can continue like the following:


  • 为webhook启用插槽填充(可选)。一旦您提供帐号,这将触发webhook意图,您可以在询问帐号类型之前对其进行验证。

  • 如果未启用广告位填充,您将收集两个参数并移动

  • 确保不要在Dialogflow中设置输出上下文,因为您将通过webhook对其进行设置。

  • 如果帐户有效-继续设置下一个意图的上下文

  • 如果无效,则将输出上下文设置为与意图的输入上下文相同,寿命为2(用于2个对话互动)并要求用户提供正确的帐号。

  • 当用户再次说出帐号时,将具有相同的上下文和相同的用户语音。

  • enable slot filling for webhook (optional). This will trigger the webhook intent as soon as you provide an account number and you can validate it before asking for account type.
  • if not enabling slot filling, you will collect the two parameters and move to intent handler code in the webhook.
  • make sure not to set output context in the Dialogflow as you will be setting it from webhook.
  • if the account is valid - continue by setting the context for next intent
  • if not valid set the output context as same as the input context of your intent with lifespan say 2 (for 2 conversations interaction) and ask the user to provide the correct account number.
  • when the user will speak the account number again there will be the same context and same user speech.

如果您要在余额类型之后收集帐户参数,则可以继续执行上述方法,但是在这种情况下,您将一次又一次地收集余额类型,甚至什么时候 用户正确提供了它。最好将帐户参数移到单独的帐户意图中。

If you are collecting account parameter after the balance type, then you may continue with the above approach, but in that case, you will be collecting balance type again and again even when the user is providing it correctly. Better would be to move account parameter to separate account intent.


  • 在Dialogflow中为余额意图设置输出上下文,例如 get_account lifespan = 2

  • 将帐户意图的输入上下文设置为 get_account

  • 在提供帐户参数并触发webhook时,对其进行验证

  • 如果有效-继续设置下一个意图的上下文

  • 如果无效,请将上下文设置为 get_account lifespan = 2并要求再次提供帐号。 / li>
  • set the output context in the Dialogflow for balance intent say "get_account" lifespan = 2
  • set input context of account intent as "get_account"
  • when account parameter is provided and webhook is triggered, validate it
  • if valid - continue an set context for next intent
  • if not valid, set the context as "get_account" lifespan=2 and ask to provide account number again.

这样,通过播放上下文,您可以验证参数并重新提示用户输入正确的格式。

So this way, by playing with the context you can validate the parameters and re-prompt the user for correct format.

这篇关于如何重置参数值,以便代理可以再次请求参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆