Context challenges of Watson Conversation Service

Some of you must have built the dialog nodes on Watson Conversation work space.

Let me show how it looks like:



Now a problem with Watson workspace is, you have to explicitly hardcode everything according to what a user can reply with,

For example: Let’s say using this service you are building a chatbot that orders a Pizza and you want user to specify size, quantity and type of the Pizza user wants to order, chances are that user may order everything in one go or two things in one go or user can specify the things one by one upon asking and there can be many more possibilities like if he ask anything which is not relevant.

In fact a simple Pizza Ordering Chatbot which asks the user to specify only three things size, type and quantity – I have to hardcode around 40 dialog nodes to make it work, from starting the conversation with greetings to ending the conversation with goodbyes.

So,you see how much work is there in the simple Chatbot which orders Pizza and ask for only three things.

Now it gets more complicated if a user miss spell anything and Watson does not recognizes it.

Now you got problems !! 

Should you hardcode a dialog node next to every node which will handle the case if user misspells anything and Watson is not able to capture it, then it will reprompt the user with a message something like:


and jump to the node where it should be, i.e the previous node where it didn’t detect anything .

What you gonna do about it ?



I found a simple and efficient solution for handling this.

The Trick is to save the context of the dialog flows which is being returned by Watson when a call to the API is being made. Let me show you what the context is and how it looks like :


It contains every bit of information like which Node is being visited, which is the current Node and this is what we need.

Having context in hand we can now make a single node which will handle all the difficulties either it is because of not spelling it correctly or Watson doesn’t recognizes anything, what we just need to do is create a dialog Node in the workspace, Anything_Node in my case  :


and make a Python Script which will handle this, which will not save the context in a file till it is at Anything_Node, this can be handled by the simple code snippet :


Isn’t this simple ?

Yes the solution is pretty simple but the problem looked scary till we didn’t know it.




Leave a Reply

Your email address will not be published. Required fields are marked *

− three = 0

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>