[Azure] Building a Cortana based skilled bot
In my previous post I discussed how to build a bot using a Web Project and deploying it as a DLL to an Azure Function. The Azure Function would then function as the endpoint for your bot which you can make available through channels which include Facebook, Skype (for Business) and many more. Starting at //BUILD this year, Cortana was also included in that list of channels. Cortana of course is a bit of a special channel, since we’ll then be using voice to communicate with our bot. But if you think of it, voice translates to text and text is the input of choice for the bot that we build. So it should be that difficult, right? It’s not!
The Cortana SDK or development framework or whatever you’d like to call it calls this skills. Basically you’re learning Cortana new skills as you would learn a pet or child something new. The set-up on the Cortana side is simpler than you might think. You simply enable the Cortana channel for your bot, fill in some fields and you’re good to go.
One of these fields is the invocation name. That’s how Cortana will understand she needs to route a message to our bot. For my home automation sample, I’ll be using “The House” as invocation name, so a command might be “Hey Cortana, tell The House to turn on the lights in the kitchen”. If you haven’t read it yet, take 5 minutes to read Cortana kills + LUIS pre-built domains on how to effortlessly teach you bot these kinds of intents.
Another cool thing you can configure is which data Cortana will supply your bot with. Since Cortana is the digital assistant of the user you will be communicating with, she knows things about this user. These things you can request for so that you can make use of the data in your bot code.
Be aware though: the user does need to consent to Cortana sending this information to the bot before she actually does so.
Another handy thing is to put Cortana herself into Developer Mode. You can do this by heading over to the Cortana Dashboard (the link is displayed with the Cortana channel itself). Here, under the Debug section there’s the option to enable Developer Mode by simply clicking a checkbox.
After which invoking a command will show you debug info:
Debugging the bot
For testing and debugging your bot, you get all of the options you normally have for bots (and for Azure Functions by the way). Of course you cannot get the online version of Cortana to call a local instance of your bot, but you can simply pass in the text of the intent you want to test via the bot framework emulator. One feature gap at this moment is the fact that the bot emulator does not allow us to pass in the additional channel data that Cortana can supply (context / user info). What you could do is attach your debugger to an Azure hosted instance of your bot and then debug that specific part.
That’s it for now, in my next post I’ll be going in a bit deeper into how this all comes together.