Creating Bot Using Azure Framework Composer
8K views
Oct 30, 2023
Creating an AQI indicator Bot using a simple GUI of Azure Bot framework Composer.
View Video Transcript
0:00
Okay, so to start with a bit of introduction about myself
0:04
Yeah, hi there. This is Kuljod Singh Bakshi, first year undergrad at IIT Bombay
0:09
and the Department of Environmental Science and Engineering. Okay, so now coming to the topic of a tutorial
0:17
the topic is Bot creation using Azure Bot Framework Composer. Now, let us look at the various ways to create a bot
0:28
They are two so basically there are two ways to create a board using Microsoft Azure offering
0:33
The first one is the board framework composer and the second work is the board framework SDK
0:40
Now what we are going to look in this tutorial is the board framework composer
0:47
So there are some very basic differences between both of these that is the board framework composer
0:53
and the Bot Framework SDK. And to start with, the first difference is that Bot Framework Composer
0:59
uses graphical user interface and a tad bit of coding. That means to create a bot using the Bot Framework Composer
1:06
you need not be a master at coding. Rather, if you have an idea in mind
1:12
you can just simply create a bot with that idea using graphical user interface
1:16
And now coming to the Bot Framework SDK, The board framework SDK contains all the libraries required to build a board and make it function efficiently and it lays a lot of emphasis on coding
1:30
so if you are a master at coding or I mean prefer to
1:37
Use coding as the main framework for create for the creation of a board
1:42
When you are good to go with the board framework SDK Now the second difference is BOT Framework Composer supports node.js and C sharp language
1:54
and on the other hand BOT Framework SDK is available for C sharp, Java, JavaScript, TypeScript
2:01
and Python language. Now coming to the flow of dialogues. So the first question is what exactly are dialogues
2:15
Now when we create a bot using the bot framework composer, dialogues are the most important part of your workspace area
2:27
Dialogues are used to enhance the flow of the bot. Dialogues basically tell the bot what activity to start
2:40
So dialogues are triggered by something called as triggers. And as the name suggests, triggers are used to start a particular dialogue whenever an
2:49
intent is detected. Let's say you want to know what the weather of a city is
2:59
So when you tell the bot, when you type the sentence as in telling the bot, tell me the
3:05
weather of London. So using a conversational language understanding model, the board recognizes your intent
3:16
that is to know the weather of London. And then after recognizing that intent
3:25
the board triggers the flow of dialogues that basically let you know the weather
3:34
what the weather of London is like at that particular time. I know this concept of dialogues and triggers can be a little hard to grasp at first, but
3:47
as you move forward into the tutorial, you will sort of get familiar with the flow of
3:54
dialogues and triggers. You can club your knowledge base and conversation language understanding model with your bot
4:01
to enhance it to utterances, phrases and intense, etc. I completely get it that the concept of triggers and dialogues can be a little difficult to
4:13
solve at first. I completely get it that it can be a little difficult to grasp at first, but I would like
4:22
to let you know as we move forward with the tutorial as we move on with that tutorial
4:28
you will surely get familiar with the concept of dialogues and triggers
4:34
Yeah, so the next point is you can always club your knowledge base and conversation language understanding model with the robot to enhance it detect
4:43
references phrases intense, etc. And if you don't know about knowledge be about what our knowledge base and conversation language understanding model
4:59
So I have made a video on these two also. So at the end of the write-up
5:06
I'll be pasting a link to these articles too. And in the end, it's a never-ending series
5:14
of updating your knowledge base and consequently refining it. So it's like the more defined data
5:22
that you feed your bot with, the more efficiently the bot works
5:28
on detecting the intents and basically then triggering the flow of dialogues accordingly
5:38
Okay, so that's this slide is just a graphical representation of what a simple dialogue trigger
5:48
looks like. So, let's say you have made a bot for a pizza delivery company
5:57
So as soon as you go to the main screen, the bot asks you to move ahead with your choices
6:06
of selecting a pizza. Then you move on to the select pizza screen where you select your pizza with your choices
6:13
of toppings, whether you want to add cheese or not, whether you want your crust to be
6:18
hand tossed or let's say you want a thin crust pizza, you put in all of these values and then
6:27
move on to your checkout screen where you make your payment your delivery
6:32
address and then you are good to go so as soon as the main screen starts the
6:38
board welcomes you and then it it it triggers a dialogue which takes you to
6:46
the select pizza screen and as soon as you make your choices of toppings
6:52
pizzas and stuff like that the board then triggers a dialogue which takes you
6:59
to the checkout screen so dialogues are nothing but the board making you flow
7:08
through everything yeah so this screen is nothing but an enhanced version of what we discussed in
7:16
the previous screen so just take your time take five to ten minutes have a look at the slide like
7:25
and question yourself again and again what is a dialogue and then you'll be good to go
7:36
okay so now moving on to the next slide on this slide we have something which is called an adaptive flow so then again adaptive flow is a
7:48
Very important concept and this can be used to create complex bot systems
7:53
And as the name suggests that this refers to the ability of the board to switch to dialogues depending upon the detected intent
8:01
order trends So this slide is again a graphical representation of what an adaptive flow looks like
8:13
So let's say you created the bot for a pizza ordering company and then on the checkout screen
8:21
you place your order of one medium pepperoni size, one medium size pepperoni pizza
8:29
And as soon as you go to the checkout screen, you remember I had to order another pizza
8:36
So you type in add another pizza and then through adaptive flow, the bot takes you to
8:46
the pizza ordering site again. So basically the conventional way would have been the bot would have taken you to the checkout
8:55
option then you would have made your payment and then again you would have
9:00
started the process all over again of ordering another pizza if adaptive flow
9:06
wouldn't have been used in the board now with adaptive flow what you do is if you
9:12
want to add another pizza you tell the port I want to add another pizza the
9:20
bot then takes you to the pizza ordering section again and without placing another order the cart
9:28
automatically gets updated so this is basically what adaptive flow is in a nutshell i know this
9:37
concept again is very hard to describe in works but then again as we move on with the tutorial
9:45
You will get to know what is what basically adaptive flow Actually is okay, so we are done with the theory part of the tutorial now we
9:58
Are good to go with the practical part of the tutorial So the first step would be to open what framework composer in your screen
10:08
Wait for some time now the next step would be to click on create new option
10:15
I am comfortable in C sharp language, so I'll be using C sharp for this tutorial
10:21
You if you are comfortable with note or Js you can go with note or Js
10:26
But this tutorial as of now will be covered in C sharp language
10:31
Now click we'll be selecting empty bought empty bought from here click on next
10:39
Let's name our bought as a aq i bottom runtime type is as your web app location is okay click on create okay so our
10:56
bot has finally been created up I know you must be they will be buildered by
11:04
the fact that I named my bot as aq i bought up so to tell you what we are
11:10
going to cover in the tutorial is we are going to make a bot which is gonna output the aqi value
11:17
of a location and to sum things up it will also output values such as co concentration and into
11:26
concentration so2 so3 concentration and stuff like that and for the creation of this bot we
11:34
We will be taking the data from open weather organizations API and yeah
11:42
So moving ahead with the tutorial to give you a look at what the dashboard looks like
11:51
Here is what our main work is going to take place in
11:58
So this is the area where the board reads a user. So as soon as the as the board starts turn dot activity dot members added method is triggered
12:14
and through dialogue flow the board sends a response as in welcome to your board
12:23
obviously depending upon your choice you can obviously always change what response the board will send in the form of greeting okay
12:37
so now let us add a new dialogue click on this eq i bought and three columns
12:45
stuff click on add a dialogue let us name this dialogue as get city and
12:59
description would be getting the location of city the user is
13:11
and send about so click on this add option click on ask a question click on text
13:31
and from this area click on show code now write this code in your computer as
13:39
as well activity text is equal to enter your city
13:55
now we want a variable to store the input of the user so to do this click on user input
14:05
And now in this property area, name your variable. So, I am naming my variable as dialog.city. Okay
14:21
Now, so what we are going to do here is, we are going to take an input from the user in
14:34
which he tells us the city of the city of whose weather he wants to know about and then
14:45
through the open weather API we get the long longitude and latitude values of the city and
14:52
then from the longitude and latitude values of the city we use the open weather's API
14:58
extract the AQI value of the city and the various concentrations of CO NO2 SO2 SO3
15:07
and stuff like that so to know about the open withers API go to open
15:16
weather map open visual map API documentation for a QI value
15:38
So this is the API documentation for getting the AQI value using the using open weather's data
15:48
So, yeah. So, what we do here is we throw a HTTP call for with the values of latitude and longitude
16:06
inputted into this URL and when the open APIs, when the open weather server receives that
16:16
HTTP request it sends a JSON formatted data output and from that JSON formatted
16:23
data output we extract the aqa values and the various and the values of the
16:28
various concentrations of various gases so to know the latitude and longitude of
16:37
the city that we're concerned about yeah so to know the value of longitude and
16:45
latitude of a city we have a geocoding API from open weather in which we make a HTTP call with the
16:53
city name and the API ID to get the respective longitude and latitude value of the city that
17:00
the user is concerned about okay so yeah now back to our board framework composer we click on this
17:10
add button we click on access external resources send an HTTP request
17:21
and first and foremost we we go to our account my API keys
17:32
and so that's the default key and this is the new key that I generated this
17:46
morning so I'll be using this new key copy this key paste it in note that
17:57
Okay, now back to the geocoding API
18:08
Click on this, paste it in the notepad again
18:25
So city name would basically be dialog.city, limit would as such be save 5 and API key
18:44
would be this. Copy this. http method would we get because we want to get the json formatted data from the
19:03
dataset of open weather organization we paste the url here and click the response type to json
19:17
now click on this ad manage properties set properties click on add new and so basically we want to set the properties of lot longitude and
19:34
latitude in form of two different variables so the first property would be okay so wait a minute
19:48
Here, we have to go to result property and store this JSON formatted data in form of
19:57
a variable again. So I named the variable dialogue.apiResponse. Go to set properties, click on add new
20:09
My property name would be dialog.longitude and the value would be
20:23
So this is what an API response of HTTP GET method looks like
20:31
So to know the longitude and latitude, the command would simply look like, yeah, the
20:46
command would simply look like dialog.apiResponse.content because it is a JSON formatted data
21:01
data output dot lon yeah lon here
21:13
it is and paste it here now creating variable again for storing the value of latitude
21:24
dialog.latitude is equal to dialog.apiResponse.content.lat
21:42
Okay, so now when I have the longitude and the latitude values of the city that the user
21:57
is concerned about, I can simply make a http get method API request call to get the values
22:06
of the aq index of the city and the values of the various concentration of various gases
22:13
that is observed for that particular city so now i add click on add again click on
22:23
access external resources send an http request http method would be get now url i will have to
22:32
look the API documentation again for getting the URL okay so the API call
22:40
looks something like this first you go to notepad paste the API call URL here
22:51
latitude would be and API key would again be the same thing as before
23:34
Copy this API key and simply paste it in front of API ID
23:42
Now copy this API call URL and paste it here. Now again this HTTP GET method is gone is gonna throw a
23:57
JSON formatted data output and to show that output I need to assign a variable again
24:03
So my variable name could be dialogue dot API final Response
24:13
And response type could obviously be JSON click on add click on manage properties click on set properties
24:27
now I want to set properties for the aqi index value and the concentration of let's say carbon
24:37
monoxide gas. So click on add new. I would name this property as dialog dot aqivalue
24:49
Okay so now I would have to look at the API response here
24:56
So the API response, sorry, the API response looks something like this
25:07
So, to access the aq value, I would have to go into this list array and then from this
25:15
main semicolon area, I would have to access the aq value. So, my command for accessing the aq value would look something like dialogue.apf
25:37
API final response.content because it's JSON file.content.list0.main.aqi
26:01
Click this and paste it here
26:13
Click on add new and let's say I would name this variable as dialog.coConcentration
26:26
Now for accessing the CO concentration, my command would look something like dialog.api finalresponse.content.list1.components.co
26:59
co yep that is it now copy this and paste here
27:15
now the only thing left is to display the AQI value and the co concentration on
27:22
the monitor to the user and to do this I would simply click on send response go to show code
27:34
and write this code as well text is equal to the aqi value is
27:44
a dialogue dot aq value and the carbon
28:01
monoxide the only thing left is to start the board so simply click on start a board
28:47
click on allow access open the chat Oh yeah, so yeah, basically we forgot to go to the greeting section and add a command
29:09
which starts the dialogue which is named as getCp. So to do this click on add here and click on go to dialogue management, begin a new
29:22
dialogue and from this area here get select the dialogue that you want to begin
29:33
So I have selected get city dialogue here. So restarting the bot again click on restart bot
29:45
You can open the chat. City of interest is London
29:57
Don't know why the bot isn't replying
30:08
Let's restart a conversation. Type in London again. Yeah, so here it is
30:16
The AQI value for London is 1 and the CO concentration is 247
30:27
According to the API data returned by the OpenWeatherMap organization
30:37
So that's pretty much it for the tutorial. We are done for today
30:43
Thank you and have a nice day ahead
#Ecology & Environment
#Engineering & Technology
#Intelligent Personal Assistants
#Programming
#Software