3 Steps to Your Own Microsoft Azure AI Bot Service



Microsoft predicts that the three forces driving advancements in IT today are IoT (Internet of Things), AI (Artificial Intelligence) and Bots (human-computer interaction). 

As a member of the Cloud Team at work, I try to keep up with the advancements of the major cloud providers on a daily basis.  Microsoft Azure recently released their Bot Service Preview, so I thought I'd give it a try.  Plus, Mark Zuckerberg wrote his home Jarvis in only 100 hours, so how hard could it be? 😊

Actually, the process of learning to train AI and integrating that AI into a chat bot was both interesting and fun.  From a high level, they steps required are:
  • Go to the Azure portal and create an empty conversational bot
  • Go to LUIS.ai (Language Understanding Intelligent Service) and build the AI
  • Go back to the Azure portal and tell your empty conversational bot’s C# code what to do with the intent and entity(ies) returned by the LUIS natural language conversation.
This Microsoft video was extremely helpful in understanding the LUIS AI portion.

Step 1: Create an Empty Conversational Bot


From the Azure portal, choose Bot Service (preview) from the Intelligence + analytics section.  Give your bot a name, a payment plan, a resource group, a geographic location and click Create.



After about 10 seconds, your bot template will be created.  Click on the bot in All Resources or your Dashboard to bring up the "Create a Microsoft App ID" page.


Click "Create Microsoft App ID and password to bring you to the Microsoft Application Console.  You may need to authenticate first.





Your app name will be filled in for you and an App ID will be generated.  Click "Generate an app password" to continue.


Copy this password to the clipboard as you will need it.  You should also save the password somewhere safe.  Click OK to be brought back to the Generate App ID and password page where the password will be filled in.


Click Finish and go back to Bot Framework.  This is where you will need to paste your password that you just generated.


Also on this page, choose your favorite programming language and the type of bot you would like to create.  For this chat bot example, I chose the Language Understanding bot.



Click Create bot, click OK to connect to LUIS and wait a few minutes for the bot to be created.  When created, you will find yourself in the web-based bot editor that looks a lot like Visual Studio.









Since you have not created any intents nor entities in LUIS yet, anything you type in the Chat window will trigger the "None" intent in BasicLuisDialog.csx.




Step 2: Build the LUIS AI

Now you need to build some natural language processing for your bot so that you can figure out what someone typed into the chat window and what you should do with the request.  This is the fun part.

Login to www.luis.ai with your Microsoft ID and Edit the App with the corresponding App ID to your bot.


If you click App settings, you can give your LUIS app a friendly name instead of YourLuisApp-2017-nn-nnnnn


This is where you decide what categories of questions you want to be able to respond to.  These categories will be your intents.  My first bot was written to find the correct presales architect for a given customer situation.  I created intents to answer questions about presentation skills, demonstration skills and quoting skills.  The subjects (entities) of these questions tend to be vendors, so I created a Vendor entity.  I also added the pre-built datetime entity so that I could respond to time-based queries.



Adding a new Intent is quite simple.  Click the + next to Intents, name the intent and give it a seed phrase.

You will see that this will be added as a new "Utterance"

Utterances are where you train the correct guessing of intents (actions) and entities (subjects).  You'll notice here that the Install Intent is already selected.  If we click on the word "microsoft", we can train LUIS that microsoft is an example of a vendor entity. 


Click Submit to save this training.

Keep entering new utterances and training any errors in intent or entity until you have built up a good base of knowledge.


You can test the AI confidence level at any time by clicking Train, then Publish.




In the publish form, click "Update published application", type in a query and hit Enter.  The resulting JSON will show you the level of confidence assigned to each intent and what value for entity was assigned from your natural language query.


For my AI, you will see that the Install intent was correctly given the highest confidence and microsoft was correctly chosen as the entity.  This is the JSON that will be returned to the bot C# application for further action.


Step 3: Program Bot Actions Based on Query Results

OK, let's head back to our bot in Azure and respond to some of these natural language queries now that LUIS has gotten so smart at interpreting them.  

You'll notice in the bot code created for you (BasicLuisDialog.csx) a stub section for the intent you just trained.  Change MyIntent to the name of your intent and insert your response code into that section.


In my presales bot, I wrote a simple case statement to respond to requests (intent + entity) as to who has the skills to present certain vendors' offerings.  


Interacting with my presales bot looks like this


Pretty cool.  In a world where natural language is gaining in popularity as the de facto human computer interaction method (Cortana, Siri, Google Now, Alexa, Google Home), it is good to understand how natural language processing works and how to train your own AI.  Microsoft has made it easy to implement bots for human computer interaction.

I hope that you have found this post helpful and informative.  I welcome your feedback.

Comments

Unknown said…
Dennis,

Very educational!!!

Thank you
Stephen
Mario said…
That was great Dennis! Very interesting!
Dennis Faucher said…
I'm glad you enjoyed the post Mario. Thank you for commenting.