Chatbots - should I call LUIS?
Radical changes in Microsoft BotFramework v4
Microsoft stack for bots lets you quickly build smart and functional bots. It's great, check it out, build your own
friends virtual assistants. Architecture can be boiled down to:
- Bot Service - a connector that abstracts any channel (Skype, slack, etc.)
- REST-ful app that you develop with BotFramework SDK that is called by Bot Service with every message
- Any additional services that provide "intelligence" to your bot (LUIS, QnA, Azure Search..)
LUIS, part of that offering - Language Understanding service - enables you to easily detect what the user wants. If you want to know that user asks to "BookFlight" (intent) and you expect people to say something like:
Book flight to [place] on [date] I want to go to [place] on [date] On [date] I want to fly to [place]
> Congratulations, you have just pretty much written down a LUIS model and can use the API to know that someone is interested in flying away.
Now, if you are interested in BotFramework you may have noticed that in SDK v3 the default behavior is to send every user query to LUIS. All samples related to intelligence use middleware that hijacks the flow if an intent is found in user answer.
Should we call LUIS on every single message?
The short answer: no. And that's also direction SDK v4 has recently taken, but before that let's consider two situations:
Where do you want to pick up your order?
- At our restaurant
- At your office
- At your home
What's your home address?
Home Street 1145
Asking LUIS by default wouldn't provide any value. And on the other side we would dent our LUIS calls quota (50 calls / sec / service, chargable) and possibly get sensitive user data in endpoint logs!
SDK v4 - changes!
BotFramework SDK v3 is the current production-quality release. V4 is in preview and changes rapidly, but if you look at the docs and samples you can still see LUIS middlewares used everywhere.
Well. 27.06, pretty much a week ago, all middleware for LUIS and QnA was removed from master branch. The idea is that we as developers must own the decision when to call LUIS. And that's great!
LUIS and input
In contrast to previous samples, let's consider:
What's your street address?
Wait, why do you need my address?
In that case the user obviously (for me and my fellow humans) wants to do something different, but at the level of input to an app - we don't really know that. Should we call LUIS always anyway?
Undo to the rescue
One of the most important (and far too often not used) patterns in user experience is the ~undo~.
We will send your package to "Wait, why do you need my address". If that's not correct, tell me to go back and change.
What's your zip code?
no, go back!
What's your street address? If you want to ask any other question or change your current order just tell me to cancel.
Voilà! We reduced infinite space of any possible user command to finite set of expected inputs.
Building chatbots is a very different kind of challenge that any traditional UI. There are hundreds of weird edge cases like that and at the end we are still nowhere near pretending to create human-level experience with chatbots. But if we as creators don't overpromise - maybe humans will turn a blind eye for some minor blunders in our "intelligent" applications. And get some real problems for users solved behind the chats which is the only thing that counts in the end.
Still, some wildcards that use preview version of BotFramework SDK may be in for a surprise after next release (though small and easily fixed code-wise :) ).