Build and Deploy a Web App Bot using Azure Machine Learning Model

Aindrila Das
5 min readJul 1, 2021

A bot is an application that’s programmed to respond to tasks and input from a user. If this sounds much like any normal application, well, it’s pretty much is! The difference is how the bot application determines the response and provides some form of automation.

Here, we will be using Microsoft Bot Framework and Botbuilder SDKs. Also, we will be using Node.js to enhance the basic bot template. The basic bot template gives you a lot of standard actions that the bot will do. To train and test our bot and to make it understand the conversation language we will be using Language Understanding (LUIS).

So, let’s get started!

First things first: you need to have an Azure account. If you don’t have one, click here and create a free account.

  1. Go to Azure Portal and click on Create a resource.

2. Search for Web App Bot in the search bar.

3. Click on the Create button.

Fill in all the details as shown below:

Bot handle: I am giving the bot handle name MySmartPizzaBot. You can choose something else.

Subscription: I am choosing my Visual Studio Enterprise Subscription. If you have any other subscription, go ahead and use that.

Resource Group: Here we are going to create a new resource group. I’m naming it as AzureMOL.

Location: Central India is the location I’m using here.

Pricing tier: Choose F0 (10K Premium Messages)

App Name: Default name (in my case MySmartPizzaBot)

Bot Template: Choose Basic Bot (NodeJS)

LUIS App location: West US

LUIS Accounts: Create something similar to your bot name.

App service plan/location: Keep it as it is.

Application Insights: Turn off.

Click on Create.

Your deployment will start shortly and you can see that in the notification bar.

After your deployment is being finished, click on Go to resources.

Now that you have created the resource successfully, go to this GitHub repo: azure-mol-samples-2nd-ed/azuremol.json at master · fouldsy/azure-mol-samples-2nd-ed (github.com) and download the azuremol.json file.

Now go to LUIS website and train your bot. If you are using LUIS for the first time, you will see a window like this from where you need to choose your subscription and click on select or create an authoring resource. Now select the authoring resource of your bot (for me it’s MySmartPizzaBot). Click on Done.

You can see that we now have a connection to our bot here. If you click into it, you will see different intents there. Now we will upload the json file which we have downloaded from the GitHub repository.

Follow these steps:

  • Click on MANAGE and choose Versions.
  • Click on Import drop down menu and choose Import as JSON option.
  • Now, choose azuremol.json file from your local computer.
  • Name it as version 1 (1.0) and click Done.

Now that the version is imported, click on it and make it Active by selecting the Activate button from the top.

If you click on the current version now, you will see the intents has been updated.

Click on the Train option to train your model. Now that the model is trained, you can test your model by clicking on the Test option.

Now if you type something from the example user input, it will show you results. It also gives result for not the exact same inputs. You can click on Inspect button to have a detailed observation.

Now that we have our bot trained and tested, we can go ahead and publish it.

Click on the Publish button and select Production Slot. Click on Done.

Now we will use a basic Node.js app from the GitHub sample repo. To update your web app bot with your trained LUIS bot, follow these steps:

  1. Go to your Azure Portal and choose your resource group.
  2. To deploy the bot, open Cloud Shell. Now clone the GitHub repo-
git clone https://github.com/fouldsy/azure-mol-samples-2nd-ed.git

3. Change the directory to chapter 17-

cd azure-mol-samples-2nd-ed/17/webappbot

4. Initialize the Git repo, and add the bot files:

git init && git add . && git commit -m "Pizza"

5. To upload the sample bot, create a connection to your web app. The following command gets the web app repository and configures your local samples Git repo to connect to it.

git remote add webappbot \
$ (az webapp deployment source config-local-git \
--resource-group azuremolchapter17 \
--name azuremol \
--output tsv)

6. Push the sample Node.js bot to your web app using the following command:

git push webappbot master

7. Enter your Git password.

Now go back to your Azure Portal for your web app bot and select Test in Web Chat. It takes a few seconds the first time you connect, but then you should be able to interact with your bot.

Congratulations! You have created your smart bot using Azure Machine Learning Model.

If you wish to connect with me here are the links to my GitHub repo and Twitter handle.

Thanks for reading. Follow me for more amazing contents. Your claps are much appreciated :)

--

--

Aindrila Das

Co-organizer @GDG Kolkata • Women Techmakers Ambassador • Google Cloud Champion Innovator • Former GDSC Lead • Gold MLSA • Postman Student Leader #IAMRemarkable