The course is part of this learning path
This course shows you the fundamentals of how to design, create, and test chatbots using the Azure Bot Framework SDK. You’ll learn about the Bot Framework SDK, the key components that form a chatbot, and how to use templates in Visual Studio to create chatbots.
We'll help you understand the importance of Turn Context and State Management and how these are used in chatbots with the Bot Framework SDK. We'll also cover the dialog library, different types of dialogs, and how you can use these to model conversational logic in your chatbots.
The course wraps up by showing you how to get your chatbot published in Azure and test your chatbot using the Azure Portal.
- Using the Bot Framework SDK to create a chatbot
- Implementing Dialogs and State Management
- Testing chatbots using the Bot Framework Emulator
- Deploying a chatbot to Azure
- Testing a chatbot in Azure
This course is intended for developers and software architects who want to learn more about the Bot Framework SDK and how it can be used to create conversational AI solutions in Microsoft Azure.
Intermediate knowledge of C# is required for this course. You’ll also need to be familiar with Azure concepts such as App Service and Azure Key Vault, and be comfortable using Microsoft Visual Studio Community edition.
Let's look at what's involved when deploying a bot to Azure. In this lecture, we'll see how to get your chatbot hosted in Azure, you'll learn how to obtain your Microsoft App ID and Microsoft App Password, and finally, you'll see how to test your chatbot in the Azure portal. Let's look at what's involved in getting your chatbot in Azure.
A chatbot is an application that consists of a few components in Azure. They are the Azure bot itself, a chatbot code, Microsoft App ID, and the Microsoft App Password, which is stored in Azure Key Vault. To host your chatbot in Azure, you need an Azure bot resource, Az Bot, we can see here. You create this resource like any other in Azure. An important thing to note here is the Bot Handle, this is the name of your chatbot.
Another important thing to note during the creation of the bot resource is the Microsoft App ID. The Microsoft App ID is an identifier that is unique to the chatbot that you're creating in Azure. This key piece of information is required to create an Azure bot resource. You have the option of creating a new Microsoft App ID when you initially create your Azure bot. Alternatively, you can decide to use an existing app registration. I normally find it easier just to create a new Microsoft App ID for each Azure bot I need to create.
When your Azure bot resource has been deployed, you're then free to browse to the configuration settings for the new resource. During this deployment process, an associated Azure Key Vault is created. This contains the Microsoft App Password for your chatbot. This is only one half of the process, however, as browsing to the Test in Web Chat blade will display a message to let you know that you must first configure the messaging endpoint for your chatbot, that's what we can see here.
You may be wondering where you get a messaging endpoint. The messaging endpoint is generated after you successfully publish your chatbot from Visual Studio to Azure. All endpoints end in a suffix: api/messages. You can see an example messaging endpoint here. To successfully publish a chatbot from Microsoft Visual Studio to Azure, you need to get and set the Microsoft App ID and Microsoft App Password. Here, we'll see where to get the Microsoft App ID and Microsoft App Password for your chatbot.
When publishing your chatbot to Azure, you need to use the Microsoft App ID and Microsoft App Password. You can access the Microsoft App ID from the Configuration screen that we were just looking at earlier, you can see that here. The Microsoft App Password for your chatbot is stored in Azure Key Vault as client secret. You access the Microsoft App Password by clicking on the Manage link. This will take to the Azure Key Vault that's associated with your chatbot.
The Key Vault contains a client secret which is your Microsoft App Password, that's what we can see here. You take the Microsoft App ID and Microsoft App Password and set these values in the App Settings' JSON file in your chatbot solution in Visual Studio, that's what we can see here. When these are set, you can then publish your chatbot from Visual Studio to Azure. Visual Studio will then create an App Service in Azure to host your chatbot code.
After publishing your chatbot to Azure from Visual Studio, the site URL is generated, that's what we can see here. The site URL, it's just to form part of the messaging endpoint in the chatbot configuration screen in Azure, you can see this here. You can also paste the site URL into your web browser. During this, we'll display the chatbot welcome screen. This lets you know your chatbot has successfully been published to Microsoft Azure. This is one of the first things that you should test for when deploying your chatbot, as it lets you know that your chatbot code is now hosted in Azure. It's now time for a demo.
In this demo, we'll obtain the Microsoft App ID and Microsoft App Password from the Azure portal. We'll take these values and update our settings of Visual Studio, we'll publish a chatbot from Visual Studio to Azure, and then finally, we'll test the chatbot in the web chat screen via the Azure portal. So, here, we're in the Azure portal, and we can see that we already have our Azure bot resource and the Key Vault that was automatically generated for us. There is also an associated app service with an app service plan.
The first thing that we have to do is to get our Microsoft App ID for our chatbot. We can do this by clicking on the Azure bot resource. When in here, click in Configuration. Here, we can see we get access to the Microsoft App ID, so we'll take a copy of that. Next, we need to obtain the Microsoft App Password. This is stored as a client secret in an Azure Key Vault. That gets automatically created for you when you create the Azure bot resource.
We browse back to the Azure Key Vault by selecting the resource tool that houses our Azure bot resource. We can select the Key Vault, Secrets, and then click on the secret. When in here, select the current version, and finally, click on Show Secret Value. We take a copy of the client secret. Now that we have both values, we can update the app settings in Visual Studio for our chatbot. With the settings updated, we can then publish our chatbot to Azure. The chatbot welcome page is displayed. This means that the chatbot has been successfully deployed to Azure.
The final thing that we can do is to browse back to the Azure portal and use the testing web chat page. Here, we can create our chatbot with a message. Our chatbot then asks the questions that are part of the waterfall dialog we set up in the previous lecture.
In this demo, we've seen how to deploy your chatbot to Azure from Visual Studio. We've seen how to obtain your Microsoft App ID from your chatbot configuration screen. We also seen how to obtain the Microsoft App Password from Azure Key Vault and set these values in your chatbot code. And finally, we tested the chatbot using the Test in Web Chat screen within the Azure portal.
Jamie Maguire is a Software Architect, Developer, Microsoft MVP (AI), and lifelong tech enthusiast with over 20 years of professional experience.
Jamie is passionate about using AI technologies to help advance systems in a wide range of organizations.
He has collaborated on many projects including working with Twitter, National Geographic, and the University of Michigan. Jamie is a keen contributor to the technology community and has gained global recognition for articles he has written and software he has built.
He is a STEM Ambassador and Code Club volunteer, inspiring interest at grassroots level. Jamie shares his story and expertise at speaking events, on social media, and through podcast interviews.
He has co-authored a book with 16 fellow MVPs demonstrating how Microsoft AI can be used in the real world and regularly publishes material to encourage and promote the use of AI and .NET technologies.