Build an Intelligent Bot with Microsoft Azure

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Welcome to "Build an intelligent bot: A lesson from 'Learn Azure in a Month of Lunches'" - a new series which gives you a taste of the Azure Platform without adding any stress to your development journey. Hi, there - my name is Elliot Perry. I'm a Principal Program Manager here at Microsoft, and I work on the Bot Frameworks team and my team and I are responsible for helping you to build enterprise grade conversational AI experiences. So today we're gonna be learning a chapter of the "Learn Azure in a Month of Lunches" eBook by Ian Foulds. This 350 page e-book will give you an understanding of the Azure Platform, along with hands on, step-by-step demonstrations. And, specifically, today, we're gonna be doing Chapter 17.3, which is "Build an intelligent bot to handle pizza orders." But first, let's recap what Azure offers. So Azure is the Microsoft Platform, which provides a group of services to help you build, test and deploy your application globally to Microsoft managed data centers. So whether you're building a website or a database, whether it's a desktop or mobile application Azure is there to provide you the capabilities to build your application, and we'll be with you for the lifetime of your application wherever it goes. So, using Azure App Services, you're able to easily add on security features, along with auto scaling, to handle increased usage and load balancing to handle geographic distribution. So, on top of this Azure framework, today, we are going to be building a bot. And let's talk about exactly what a bot is - so a bot, really, is just an application that responds to user input and action. And in the recent past, there have been plenty of examples of basic bots whereby the user would have had to type, usually something very clear and explicit for the bot to understand. So, perhaps, in a pizza scenario, the user would type exactly "start-pizza- order", and the bot would understand that they must start the pizza ordering process to gather what the user wants as perhaps toppings on their pizza. The challenge with these basic bots, though, is that it's very inflexible. If the user didn't know that they had to type "start-pizza-order", then the bot would not know what to do. We can build an intelligent bot utilizing machine learning so that the bot actually has a conversation using natural language. This means that the bot is going to understand a much broader range of inputs from the user to understand the intent of what the user wants. So now, the user can say "order a pizza" or "I want a pizza" or "build me a pizza" And the bot is now going to be intelligent enough to understand that all of those different phrases mean the same thing which is start the pizza ordering process. And so, in order to build that intelligence in, we are going to be using the Microsoft Bot Framework and integrating that with the Azure Botbuilder SDKs, and we will be using Node.js to enhance a basic bot template. The basic bot template gives you a lot of standard actions that a bot will do, and this saves you time so that you can then enhance your bot with specific actions that you would like it to do. We will also be using language understanding, which is called LUIS - and LUIS is our Microsoft service to help you build machine learning models so that whatever phrase the user inputs, the bot will understand whether it is to "create a pizza order" or to "look at the menu" or to perhaps "get the status of the pizza" that they have already ordered. So this example is going to be using Node.js and LUIS and all the examples are on the repose at GitHub And so the link to that is also in the description below. But, the best way to learn is by doing so - let's get started! You can see we have navigated to the Azure Portal at portal.azure.com and signed in with our account. And if you haven't got an account, you can go and create one for free to give you access to these services. So when we're inside the portal, let's go and create a resource. We're going to search this marketplace, which has all sorts of capabilities and services for you to use, and we're going to look for a Web App Bot. And here is the Microsoft Web App Bot that we can begin to deploy. So let's go ahead and create one of these to start with, and we're going to give it a name. So for example, we'll call it "my cool pizza bot". We're going to choose a subscription that we can use and place it inside a resource group, which is a container for various Azure services. So for this one, we will create a new resource group called "Azure Month of Lunches", and it's Chapter 17 The next part is where we're going to deploy our bot - and we'll leave this as central U.S. and we'll change it to one of the free pricing tiers. So you can now see here that my app name is going to be "mycoolpizzabot .azurewebsites.net . But what bots are we actually deploying? Well, we can provide a template. So if we click the bot template, we can choose here between two standard bots that will give us at least some capabilities to start with. We have an echo bot - that is a very lightweight bot - which simply will reply back any messages that is input by the user. But for this scenario, because we want to be a little bit more capabilities, we're going to choose the basic bot template, which has a lot more capabilities and also is able to much more easily connect to the language understanding service LUIS. So in this example, we're going to choose Node.js But C# is fine and choose the basic bot and select that as our template. So the next part, then, is setting up a LUIS app and service account. So, again, LUIS is that language understanding portion, which the bot will use to pass the user input to LUIS to understand what the users intent was. So for this, we will create a new LUIS account, and we'll give it something similar, such as call it "my cool pizza bot". This will be the name of the LUIS account and then just a little bit of tidy up here. We don't need application insights on just for this demo, although application insights for a larger and production-ready bot would give you insights into how the application is used and if perhaps, maybe, it needs to be scaled up or load balanced. But for now, we'll turn that off, and we're also going to ask Azure to create an app ID and password to make the deployment process secure. So for now, let's go ahead and create the bot - and at the same time, it will also speak to the LUIS service and create the corresponding LUIS account. So now, Azure is going and starting the deployment of our services, and we can track that along in the notification that we will receive when the bot and the LUIS account have been created. And that will be in your notification bar at the very top of the Azure Portal. Okay, here we are. We've received our notification that Azure has completed in deploying "my cool pizza bot" So now let's go to the resource and see what it actually did. So here is the "my cool pizza bot" Azure resource page. You can see that it's been deployed to the resource group Azure "Month of Lunches" 17 and also were given some helpful instructions here on how to start to build, deploy, test and publish your bot. But as a reminder, all we have published so far is the basic bot template, and the basic bot template will help you to get started with bot creation because it has a few simple and fundamental activities that it can perform. And, it also connects to LUIS accounts that we created to help with language understanding. But at the moment, the bot has no concept of pizzas, what pizzas are, or how to actually receive an order for a pizza. So the next step we're going to do is to go to LUIS and start to train a language understanding model which will help you and the bot to understand how to build a pizza. Okay, so in order to train LUIS, - to understand all about ordering and building pizzas, we need to train LUIS with data that gives examples of what the bot can expect. And these examples have already been generated for you. So if we go to GitHub and look at the resource files for the "Azure Month of Lunches", you can see that if we scroll down to chapter 17, we can go into the LUIS app folder and there is an azuremol.json file. So what is this .json? This .json contains data that is going to be used to train the language understanding for the bot. So taking a look at it, you can see that it has a number of intents. An intent, remember, is the action that the user wants to, complete with the phrase that they speak to the bot. So there is an action, which is a greeting - that's an intent. There's also an intent to order food. There's also intent to order status, which is to return the status of the order you've placed. And also there is an intent to "show menu." So these are the intents that we are going to teach the bot to understand. But what specific phrases are going to train those intents? Well, those are lower down in the .json under "utterances." You can see here in the text, "do you have my order" will then suggest the intent for order status or for example, if you say, "Do you have pizza?" The intent there is to show menu and we're gonna take this .json and we're going to upload it into LUIS to configure and start training the model so that bots will understand. Okay, so now let's go to luis.ai, which is the website where you build, configure and train your machine learning models for language understanding. You can see here that we already have a connection to our app, which is called the "My Cool Pizza Bot" So going into here, let's have an explore what we currently have. So remember the bot we used was just a template bot, and that basic bot template comes with a couple of intents. We have the "book flight" intent, and we have the "get weather" intent. These come as standard, but booking flights and getting weather is not useful for us and our pizza bot - so what we want to do now is to upload the .json file that we got from the GitHub repository, which is going to start to teach LUIS how to train a model to understand pizza creation, getting the pizza status and ordering a pizza. So let's start with going to manage this model. Now let's upload a new version, which is a configuration file of the LUIS model. So we go to import - and import as .json and you can see here that I go and choose the file that we already downloaded, which is the "Azure Month of Lunches .json". And we're going to name this as version one. And there we are - version one has been imported. So now let's go ahead and make sure that that's the active version, which is going to give LUIS a chance to review that configuration. But most importantly, now that you can see if we go back to the pizza bot, it now has some understanding of the new intent. This section of non-speech has been intentionally left blank. You can see here that now there are intents for "order food." We also have an order status intent and a "show menu" intent. So let's go into the "show menu" intent. So, for example, if anybody asks, "Do you have a pizza?" The intent of that question is to show the menu. If they say "list pizzas," that's also an example to show menu. And if they say, "show food" again, this is an example to show the menu. So now what LUIS will do is take these examples and train them into a model also using its own natural language databases to create a comprehensive set of phrases that will link to the "show menu" intent. So now the model has been trained, and we can go ahead and test it. So, for example, if we re type one of the utterances, "do you have pizza?" You can see here then that the intent that the model has returned is that the user wants to see the menu and with a really high confidence rating. What we can also do then is test different phrases that are not exactly in the examples that we've given. So, for example, if we say something like "what ya got?" we haven't explicitly said this means to show the menu, but you can see here that based on the machine learning, it is understood that again it's close enough to derive that the intent means to "show menu." And if we want a little bit more detail here, we can go and inspect, which is where you can see that we're less confident now that it's showing the menu. But it's still the top intent that was chosen. So this gives you an opportunity to train and to test different phrases that users may use in production. And, of course, if, for some reason, the intent that we put in was not for "show menu," then we can assign it to a new intent that we have configured. Okay, so now that we have the model that's been trained, let's go ahead and publish that - so that now our production bot will start to send the incoming requests that it receives to this LUIS model and receive back the intent of the user. So - we choose the production slot - and we press done. And here we are - LUIS is talking to Azure and creating the correct configuration so that our bot will now use this model. What we now need to do is to take the bot template that we have started with and enhance it to react to this intent. So this is where we're going to look at the code. And in a production example, you would start the bot to perhaps confirm pizza order and maybe start warming the oven. So the code to make the bot intelligent is in the GitHub repo, as well. So if we now go back to GitHub and we go into chapter 17, you'll see that we have a web app, bot and web app sites folders. And, going into here, you can see that there's a dialogues folder. So let's have a look at that and what the order dialogues does. We're not going to go through this code in a lot of detail, and there is plenty of resources to learn this at the bot framework website, which is dev.botframework.com . But just to take a quick glimpse, you can see here that we have some code which returns the intent. And if the pizza type was not provided when you start to order a pizza, then the bot will return back to the user. What type of pizza would you like? And this is the coding area where you will start to build in the actions that the bot will take after LUIS has told the bot the user's intent. So what we need to do now is to grab these code files from the GitHub repository and upload them into Azure so that the bot that we've deployed there will be able to implement this logic. So let's start by going back into the Azure Portal. Okay, here we are, back in the Azure Portal, and what we will now do is clone down the code from the GitHub repository and push it to our bot. And one way to interact with the Azure services that you have is through a command line interface called "Cloud Shell." So if we go now to shell.azure.com and this will load Cloud Shell for us. And now with the Cloud Shell loaded, let's first move into an empty working directory and we can see that there's nothing in there. So the first step to do is to clone the GitHub repo so that we have all those source files locally. And now that we have the clone complete, we now have our local copy of the source code for the "Azure Month of Lunches." GitHub repo. So the next piece, then, is to change into that working directory. And now what we want to do is to initialize this Git repository and configure it so that it's ready to push this source code to the bot. So first we will initialize, and then we get ready to do the commit. And all of these instructions that I'm following here are exactly the same as what we see in the "Azure Month of Lunches : Chapter 17.3." This section of non-speech has been intentionally left blank. Okay, now we are ready to push this code to the repo. And so it's asking me for my password for this account. Excellent. And now this is beginning the process of deploying our local code up to the remote bot. And now we will have taken our code from the GitHub repository. We pushed it to the bot So the next step to do will be to go back to the Azure Portal and let's give it a test. Okay, here we are, back in the Azure Portal and looking at the web bot page, and you can see that we have a handy little web-based web chat testing experience. And when we load that up, what we should expect now is a welcome message from the bot. And there it is. And so it's asking us what we would like to do. So now we can use natural language to ask for things such as "show me the menu." And there is our menu. Or we can say, something that is a little bit more custom, such as "what ya got" and there we are - the same message. Then if we want to start the ordering process, we can go ahead and tell the bot what pizza we would like. And there we go - the end of the pizza bot web demo. Congratulations! You've now created your bot using Azure and the Microsoft Bot Framework. So from now you can add on more capabilities to your bot or even connect it to various communication channels. I really hope you've enjoyed this lesson today, and if you have, there are 20 more just like it in the e-book "Learn Azure in a Month of Lunches", which is linked in the description below. So that's all that's left for me now to say is "Thank you for joining me in today's lesson, and I wish you all the best in your future developments with Microsoft Azure."
Info
Channel: Microsoft Azure
Views: 28,772
Rating: undefined out of 5
Keywords: Elliot Perry, azure developer, azure engineer, azure website, azure bot framework, azure bot service, sdk, github, Month of Lunches, Azure AI, Microsoft Azure, Ian Fould, Microsoft, Azure, AI, Artificial intelligence, azure ai solutions, microsoft data and ai solutions, advantages of cloud computing
Id: ZIlLvKg7owM
Channel Id: undefined
Length: 21min 5sec (1265 seconds)
Published: Thu Apr 15 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.