Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dialogflow Fulfillment: Breaking multiple choice questions into single questions

I'm relatively new to Dialogflow and I'm trying to create a healthcare diagnosis voice chatbot that would work as follow.

User Experience

  1. User calls into a system and is welcomed by the chatbot.
  2. Chatbot starts asking triage related questions (e.g., "do you have a history of chronic kidney disease?").
  3. User would answer questions and eventually receive some kind of recommendation (e.g., quarantine yourself, or call you doctor to get tested for XYZ).

System Setup

  1. The Dialogflow agent welcomes the user, explains that we will be asking a series of questions, and prompts for the first question ("How old are you?").
  2. A different intent matches the user’s response (e.g., "I'm 40 years old") and sends a webhook request to my webhook servers.
  3. My webhook server receives the request, which triggers a REST API request to a third-party medical API provider.
  4. The third-party API provider replies with a multiple-choice question ("Please select all statements that apply to you"). This is where things get complicated for me.

The Question

What is the best way to break that multiple-choice question into single "yes/no" questions? Given that I'm dealing with a voice chatbot, I can't play 10 questions to the caller in a row and expect them to answer them correctly. I have to send one question at a time to the caller.

My initial thought is that I would need to create some kind of session management in my webhook server, so that it can send one question/response at a time and keep track of their answers. However, given that Dialogflow is already doing session management, that kind of sounds redundant. My preference would be for my webhook server to remain stateless and to extract all data I need from the context object in the webhook request.

I don't want to hard code all possible triage questions as “required parameters” inside of an intent. Instead, I want the third-party API provider to handle the content/questions for obvious reasons.

An ideal solution would be if there was a way for my fulfilment webhook server to provide a dynamic list of required parameters to the intent on a per session basis. In other words, the webhook response would include a list of required parameters and a question/text for each parameter. The intent would then use this list to prompt the caller one question at a time.

I don't think this is possible, but it I guess it doesn't hurt to try... Most likely, I will have to do some session management and prompt flow control in my webhook server. However, I'm open to any new ideas or recommendations you may have.

like image 246
Gus Avatar asked Nov 19 '25 05:11

Gus


1 Answers

You're on the right track. Although you can't dynamically create prompts for Dialogflow to ask, you can store the information you need to ask in a Context and, as they answer the previous question, check the Context for what else you need to ask and ask the next question on the list.

This scheme might look something like this:

  1. When you get to the part of the interview when you need to ask the triage questions, you'll make the API call, get the list of questions to ask, and store them in a "triage" Context with a very long lifespan under a "questions" parameter.
  2. You then ask the first question, putting that in a "current" parameter, so you know which question is being answered.
  3. You'll have an Intent which has "triage" as the Input Context and has responses such as "yes", "no", and "I don't know" as entities for the training phrase. This Intent will trigger your webhook.
  4. When your webhook is called you'll get the response from the parameter, get the question being asked from the "current" context parameter, and store both of these in an "answers" parameter on the same context. (Or use a different context. Doesn't matter much.)
  5. You'll then take the next question from the "questions" parameter in the Context, make it the "current" one, and ask it as the next question.
  6. Then repeat steps 3-5 using the same Intent each time, until all questions have answers.

Your server remains stateless - all the state it needs for the next question is in the "triage" Context

like image 157
Prisoner Avatar answered Nov 20 '25 20:11

Prisoner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!