{"id":2284,"date":"2017-07-18T12:51:49","date_gmt":"2017-07-18T11:51:49","guid":{"rendered":"http:\/\/blog.repsaj.nl\/?p=2284"},"modified":"2017-07-18T12:51:49","modified_gmt":"2017-07-18T11:51:49","slug":"azure-building-a-cortana-based-skilled-bot","status":"publish","type":"post","link":"http:\/\/blog.repsaj.nl\/index.php\/2017\/07\/azure-building-a-cortana-based-skilled-bot\/","title":{"rendered":"[Azure] Building a Cortana based skilled bot"},"content":{"rendered":"<p>In my <a href=\"http:\/\/blog.repsaj.nl\/index.php\/2017\/06\/azure-building-a-bot-using-dll-webproject\/\">previous post<\/a>\u00a0I 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\u00a0<em><strong>channels<\/strong><\/em> 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&#8217;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&#8217;s not!<\/p>\n<p>&nbsp;<\/p>\n<h2>Cortana Skills<\/h2>\n<p>The Cortana SDK or development framework or whatever you&#8217;d like to call it calls this\u00a0<strong>skills<\/strong>. Basically you&#8217;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&#8217;re good to go.<\/p>\n<p><a href=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-skill.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignright wp-image-2286 size-medium\" src=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-skill-300x254.png\" alt=\"cortana-skill\" width=\"300\" height=\"254\" srcset=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-skill-300x254.png 300w, http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-skill.png 561w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>One of these fields is the\u00a0<strong>invocation name<\/strong>. That&#8217;s how Cortana will understand she needs to route a message to our bot. For my home automation sample, I&#8217;ll be using &#8220;The House&#8221; as invocation name, so a command might be &#8220;Hey Cortana, tell\u00a0<em>The House<\/em> to turn on\u00a0the lights in the kitchen&#8221;. If you haven&#8217;t read it yet, take 5 minutes to read\u00a0<a href=\"http:\/\/blog.repsaj.nl\/index.php\/2017\/06\/azure-cortana-skills-luis-pre-built-domains\/\" target=\"_blank\">Cortana kills + LUIS pre-built domains<\/a>\u00a0on how to effortlessly teach you bot these kinds of intents.<\/p>\n<p>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.<\/p>\n<p><a href=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-userprofile.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-2285 size-full\" src=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-userprofile.png\" alt=\"cortana-userprofile\" width=\"654\" height=\"252\" srcset=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-userprofile.png 654w, http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-userprofile-300x116.png 300w\" sizes=\"(max-width: 654px) 100vw, 654px\" \/><\/a><\/p>\n<p>Be aware though: the user does need to consent to Cortana sending this information to the bot before she actually does so.<\/p>\n<p><a href=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana_permission.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-2287 size-medium\" src=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana_permission-228x300.png\" alt=\"cortana_permission\" width=\"228\" height=\"300\" srcset=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana_permission-228x300.png 228w, http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana_permission.png 727w\" sizes=\"(max-width: 228px) 100vw, 228px\" \/><\/a><\/p>\n<h2><\/h2>\n<h2>Developer mode<\/h2>\n<p>Another handy thing is to put Cortana herself into\u00a0<strong>Developer Mode<\/strong>. You can do this by heading over to the Cortana Dashboard (the link is displayed with the Cortana channel itself). Here, under the\u00a0<strong>Debug<\/strong> section there&#8217;s the option to enable Developer Mode by simply clicking a checkbox.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-debug.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2288\" src=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-debug.png\" alt=\"cortana-debug\" width=\"768\" height=\"123\" srcset=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-debug.png 768w, http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-debug-300x48.png 300w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/a><\/p>\n<p>After which invoking a command will show you debug info:<\/p>\n<p><a href=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-debugon.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2289\" src=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-debugon.png\" alt=\"cortana-debugon\" width=\"327\" height=\"453\" srcset=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-debugon.png 327w, http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2017\/06\/cortana-debugon-217x300.png 217w\" sizes=\"(max-width: 327px) 100vw, 327px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>Debugging the bot<\/h2>\n<p>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.<\/p>\n<p>&nbsp;<\/p>\n<p>That&#8217;s it for now, in my next post I&#8217;ll be going in a bit deeper into how this all comes together.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my previous post\u00a0I 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\u00a0channels which include Facebook, Skype (for Business) and many more. Starting at \/\/BUILD this<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[34],"tags":[78,192,198],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3KFR1-AQ","_links":{"self":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts\/2284"}],"collection":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/comments?post=2284"}],"version-history":[{"count":0,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts\/2284\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/media?parent=2284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/categories?post=2284"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/tags?post=2284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}