Search code examples
ibm-watsonwatson-conversation

Watson Conversation - handling invalid inputs


We are building an app using Watson Conversation but are having a problem handling invalid user responses. Our bot is designed to make hotel bookings and a simplified version of the dialog is:

  • Node 1: clear the context; ask “What date do you want to arrive?”
  • Node 2: Trigger @sys-date; update context for date; ask “how many nights do you want to stay”
  • Node 3: Trigger @sys-number; update context for number of nights; summarise the booking “So you are arriving on [DATE] for [NUMBER OF NIGHTS]”

If the user provides sensible answers then all works but if their response to the check-in date is “blah” it fails so we added a new node (as a sibling of node 2) with an “anything_else” trigger and output “sorry we wanted a date, try again”.

Ideally we would want to loop back to our existing Node 2 so that the trigger @sys-date could catch the user’s revised response but that created an infinite loop so we a child node to “anything_else” that is a copy of Node 2 ie update the context for the date and asks “how many nights…” but now we want to catch the response to that question in node 3 so we can pick up the existing flow so added a jump to node 3. This fails as we end up exiting the dialog branch.

If we use "anything_else" to catch invalid user inputs how do we rejoin the existing dialog flow? At the moment the only solution we have is to duplicate nodes 2 and 3 but in the real dialog branch there are many more nodes so that approach is not practical.


Solution

  • You just need to Jump to the node (the small balloon with 3 dots in the left of the node 2). This way, if the user input a invalid date or number, it will return to catch the user valid input and it'll save in the context, like you wanted to do. You can Jump to any node of your workspace. Here is a json exemple. Hope I helped you!