dialogflow / dialogflow-fulfillment-nodejs

Dialogflow agent fulfillment library supporting v1&v2, 8 platforms, and text, card, image, suggestion, custom responses
Apache License 2.0
598 stars 281 forks source link

Dialogflow Fulfillment: Breaking multiple-choice questions into single questions #300

Open Gus007-BR opened 4 years ago

Gus007-BR commented 4 years ago

Hello, 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 fulfillment 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.

Thanks!

Gus