Technicals

To resolve the first issue I had to translate all the commands into English, easy thing. However, it took the users some time to get used to the new commands’ language.

The second issue was also easy to resolve — Hubot has a built-in function to mark a message as handled, it looks like this:

where you must call .finish() to mark the message as handled by the bot. Another thing is a custom listener that will catch all the messages, check if a message was handled (marked with .finish()) and, if not, send the message to Watson for further processing. This is easily done by the following code:

The first callback is used to check if a message should be send to Watson and the second callback is called only when the first callback returned a non-false value. The returned value is a text that should be processed by Watson.

The smart guy

Having the whole setup on the Halinka’s end done, I was able to start training Watson how to handle given messages, how to understand a free form text and how to transform it into a command that can be used by Halinka.

First thing to do is to define your Intents. In a basic form, an intent is a command, an action you want to express in free form sentences. That will train Watson how to match the incoming message with a command you want to perform, see the screenshot below:

an intent

An intent consists of a name (followed by #) and a set of sentences which express an action you want to perform. You should provide at least 5 such sentences — it gives enough information for Watson to learn what you meant. In the future you will be able to add more to narrow Watson’s understanding and improve accuracy of given answers.

The next step is a Dialog — a way to match an intent with an action, see the screenshot:

a dialog

As you see, on the left you select an intent and on the right you define a respond — super easy. This is the simplest form, the answer will be sent back to the bot and it can be a help message. You can also check accuracy of the matched intent, it’s a level of confidence which represents Watson’s understanding. If the confidence is too low (less than 50% as in the example above) you can answer with a common text that will help you identify intents that should be improved by adding more sentences. Or simply create a new intent. And a raw text is not the only option, you can use JSON to respond with more complicated answers.

You can also test your setup without connecting a bot. Watson has a test console built-in where you can post your sentences and see if Watson was able to recognise and match them with one of the defined intents.

a test console

You can dynamically pair existing intents with the sentence by selecting an intent from the dropdown. It is the easiest way to teach Watson and improve his accuracy.