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 ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You will need to play with context here. If your account parameter is collected first you can continue like the following:
- 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.
- 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.
标签:
dialogflow