In search of a conversation… Opening Dialogue, a medical chatbot case study

In search of a conversation… Opening Dialogue, a medical chatbot case study

All of us have been to a doctor at least once. The majority of the visit consists of a conversation in which the doctor tries to figure out what ails us, takes careful notes, and prescribes a solution.

But we may also have a lot of questions.

For instance, how much will the procedure or visit cost? How does that cost compare to what my friends are paying for the same service or treatment?

Medical insurance billing is a black box to many of us who can’t determine the size of the bill before it arrives.

In attempting to provide answers to patient questions, the CareX Blockchain Platform is working on a solution using AI, or artificial intelligence.

To see how we plan to implement AI into the CareX Blockchain Platform, consider an example:

Peter is our fictional character who is trying to check the best place to get a heart transplant. He asks the CareXBot to help him find the most affordable hospital. The conversation between them goes something like this:

Peter: Hi

CareXBot: Hello Peter, how are doing today?

Peter: Doing well, Thanks.

CareXBot: How can I help you today?

Peter: I am looking for hospitals in CareX Network

CareXBot: What services are you looking at?

Peter: a Heart Transplant

CareXBot: Where are you looking to have your operation? State, a city or even a zip code is fine.

Peter: Texas

CareXBot: The most affordable hospital for a Heart Transplant is xxx and costs you $xxx.

To have peace of mind, it helps to know your costs and plan for them. Having shopped and prepared properly by comparing the available prices here and elsewhere, the patient can receive the service knowing they planned accordingly.

Having achieved this conversational milestone, the CareXBot can move onto new conversations that involve more difficult questions and more complicated answers, such as preliminary medical diagnosis.

How does our medical chatbot work?

The part of AI which deals with human interaction through language is called Natural Language Processing, or NLP.

The process of NLP

Computers don’t understand anything other than numbers. Representing human language in a form that computers understand is the science of NLP.

The first important thing is to understand what a human is saying. This part is called Natural Language Understanding.

Next, we analyze the statement as a query and see if all the required information is available to give an answer. Otherwise, we must ask the user about what is missing. This process is the conversational part and requires Heuristic Search as well as NLG, or Natural Language Generation.

Finally, the Intelligent Virtual Assistant will look for the information and reply back with it in a human way.

Doing this requires a process, which Swaroop Kallakuri has developed into an Algorithm to classify user speech into different classes called Intents. Intents are the intentions of the speech. His algorithm retrieves the important information from the speech and intelligently asks questions to get all the required information.

A vast amount of data to make the connections:

To get intents to work, it is first necessary to have data to analyze.

In the age of Big Data, this is usually not a problem. It is often an issue of having too much data rather than too little.

To combat this issue, AI has developed a discipline known as Deep Learning.

Deep learning is a branch of machine learning where a multi-layered (deep) architecture is used to map the relations between inputs or observed features and the outcome.

Our very own Swaroop Kallakuri, who is a master of deep learning, has incorporated these structures into his algorithm.

Let’s look at the workflow of the whole process:

  1. User either speaks or types a statement — in technical terms we call it an Utterance.
  2. These Utterances are classified by sophisticated algorithms into Intents.
  3. Classifying utterance to an intent is not as easy as it looks, the input is converted to a text string and converted to a vector. This vector is compared to the trained set of text and compare the meanings and then classify with the highest probable intent — this is called NLU.
  4. Once Intent is Identified, another algorithm kicks in and checks for the completeness of the information, if not, it generates text to ask few other questions to get the required information — this is NLG.
  5. Once the Virtual Assistant has all the information, it searches for the information in the knowledge base and replies back with a meaningful text.


While having a conversation may seem pretty straightforward, it is not as simple as it looks. Creating a functioning AI involves many sleepless nights in a constant battle to achieve intelligent interaction.

One reason for this is that the intelligent search for information is not the same as algorithmic search, it is significantly more complex work than that. To do a search for some information, the Search Space should be optimized and for it to be optimized, the problem must be deterministic, but NLP is non-deterministic.

Before jumping too deep into the weeds, let’s back up and clarify these terms:

  • The region, place or data where we search is called Search Space.
  • The way we optimize or reduce this Search Space is the actual search function — Heuristic in our case, since complete optimization is not possible.

Problems in AI fall into 2 categories:

  • Deterministic — which means it has proper rules, with what happens next always coming from a set of rules and conditions. Examples of Deterministic situations are Sudoku, Chess etc.
  • Non-Deterministic — which means we cannot predict from a set of rules -We can’t ask a human to repeat only what I know…NLP falls into this latter category.

Since many human requests are Non-Deterministic, the first major problem is understanding what users are saying.

On the CareX platform questions generally fall into three big baskets. Are users asking about a service, disease or a doctor?

Nothing can be done without first defining this. Then the challenge is about bringing the user to a common point in which the CareXBot understands exactly what the person is asking.

In technical terms, we have to convert the Non-Deterministic problem into a Deterministic problem, thereby reducing the Search space by getting the relevant information. Then we can attempt a search and reply with the proper answer.

Let’s look at our example again and see if we can break down the different parts of the process.

Future Versions:

We are constantly working on many features to make the CareXBot a better virtual assistant. In future we want patients to be able to use the CareXbot to check their account balances, schedule an appointment, reschedule an appointment, get reviews for a hospital or a doctor, or even give a review.

That is a key aspect of artificial intelligence, it must have the tools needed to keep getting better and better. Machine learning, deep learning and constant attention to new problems is what it takes to make chatbots better and better.

The results are left up to the imagination.

Just in the healthcare space, we can automate a lot of the drudgery out for both patients and providers.

Imagine what you can do with your project!

About the CareX Team:

The AI Team at Carex is lead by Swaroop Kallakuri, who works on multiple areas to get this wonderful thing working. Kallakuri has been working in AI for several years, with more than a year focused on developing the virtual assistant for Carex.