Harry Stuart
Harry Stuart

Reputation: 1945

Dialogflow chatbot async

I am using Dialogflow with the the V2 C# client library. When the user provides the Chatbot with an address, I use a web-hook to send the address to my back-end.

My back-end then validates the address and does some other things (my back-end takes about 2 seconds).

However, I would like the chatbot to respond to the user with something along the lines of "Give me a second and I will validate the address you provided me" before my back-end has finished.

Then once my back-end has finished, respond to the user with the results of the address validation. I don't want to accept input during the 2 seconds my back-end is processing.

In summary, I would like to know, what is the best way to acknowledge a user's input with a message, not accept any further input until my back-end processing is complete and then finally responding to the user with the results of my back-end?

Upvotes: 0

Views: 149

Answers (1)

Pruthvi Kumar
Pruthvi Kumar

Reputation: 898

You need to manage this via contexts. If you are using Dialogflow SDK instead of the UI, you could control all of this via code which is more convenient.

If you are using the GUI, set an input_context and give it some lifetime as you see fit. On your web-hook's successful resolution, update or cancel respective input_context via an output_context to demonstrate completeness of a request.

By using contexts event if user asks any other question, you will not loose previous question and its answer will still be rendered to user.

Disengaging the chatbot by not taking any questions might not be a good user experience. If you really wanted to do it, you will need some JS to help you create a loading/processing sort of icon on your bot's interface for specific intents while you programatically control the mute & unmute commands on the UI.

Upvotes: 2

Related Questions