You are on page 1of 8

Artificial Intelligence Homework – Weather Chatbot

Dearetta Putri Ramadhani (10979126)

Introduction

A Weather Bot is a chat bot that provides information regarding current temperature and weather in
specified areas according to the requests from users.

In order to build the chat bot by using Bot Framework Composer, the first step is to create an Empty Bot
by clicking ‘Create new’ as shown in the Figure 1.

Figure 1. Create new Empty bot.

After creating an Empty bot, the Composer UI should look like the Figure 2. The empty bot template is
provided by two triggers called Greeting and Unknown intent. The names of the triggers are pretty self-
explanatory. Greeting trigger functions as an indication when a user is connected to the bot where
Unknown intent trigger is an indication for the user if the bot did not understand the request queried by
the user.

Figure 2. First look after creating an Empty bot.

The greeting words can be modified by changing the text responses from the ‘Send a response’ action
box in authoring canvas (number 1) and then modify the response based on the functionality of the bot
in the Properties pane (number 2).

Next step is to create another Dialog to get the weather data such as temperature and the status of
current condition. Dialog encapsulates the main functionality of a chat bot, various tasks are performed
in each dialog for example sending a response, user prompt, and making an HTTP request. For the
weather chat bot, the dialog is created to get the weather data.

1. Click on the three dots beside the bot project name in the bot explorer (number 1) and then
click on ‘Add a dialog’ in the options that come out (number 2). See Figure 3.
Figure 3. Add a dialog.

2. Name the dialog ‘get_weather’ and put the description as ‘Retrieve current weather
information’ when prompted.

Figure 4. Create dialog for get weather information

3. Locate the BeginDialog trigger under the get_weather dialog in the bot explorer (number 1).
Then Click ‘+’ on the authoring canvas (number 2) and choose the ‘Send a response’ option
(number 3). See Figure 4.
4. On the properties pane, insert the text as follow to the bot responses. ‘Let’s check the weather
today’.

The ‘get_weather’ dialog will be activated whenever a user requested the main ‘weather_bot’ to
perform the functionality. Therefore, a trigger is needed in the main bot to start the ‘get_weather’
action.
1. Locate the weather_bot on bot explorer (number 1) and then click Change on the right side of
‘Recognizer type/ Dispatch type’ to Regular expression (number 2 and 3).

Figure 5.

2. Add a new trigger (number 1 and 2) with details as follows:


 What is the type of this trigger? – Intent recognized
 What is the name of this trigger? – weather
 Please input the regEx pattern – weather

Figure 6. Add a new trigger.


This trigger informs the main bot to find the word ‘weather’ in any incoming message.

Figure 7. Dialog management.

3. After created the ‘weather’ trigger, we need to connect it to the ‘get_weather’ dialog. Locate
‘weather’ trigger in the bot explorer (number 1), click ‘+’ (number 2) and choose ‘Dialog
management’ to ‘Begin a new dialog’ (number 3 and 4). See Figure 7.
4. Locate the newly created dialog on authoring canvas (number 1) and then choose ‘get_weather’
dialog in the properties pane, (number 2). See Figure 8.

These steps allows the ‘weather’ trigger connected to the ‘get_weather’ dialog whenever a user use the
phrase ‘weather’ in the messages.
Figure 8. Connecting the main dialog to get_weather dialog.

In order to get some information about the weather, first the bot needs to know which area is the user
requesting. Therefore, a user prompt is required. In this weather_bot, a user will be asked to provide
postal code in order to check the weather.

1. Locate ‘get_weather’ on the bot explorer and click on ‘BeginDialog’ dialog.

Figure 9. Ask a question.


2. Choose ‘Ask a question’ (number 1 and 2) and then select ‘Text’ (number 3). There will be two
nodes displaying in the authoring canvas which are ‘Prompt for text’ and ‘User input’. Each of
these nodes corresponds to a tab in the properties pane, specifically ‘Bot response’ and ‘User
input’

Figure 10. Prompt for text.

3. Locate the ‘Prompt for text’ node on the authoring canvas (number 1) and click on ‘Bot
response’ in the properties pane (number 2) and choose ‘Add alternative’ (number 3). Put the
following text: ‘What’s your postal code?’
4. Choose ‘User input’ on the properties pane, and put the following value:
a. Property - user.postalcode
b. Output format - =trim(this.value)
i. This is called adaptive expression, it prevents any spaces before or after the
postal code value if the user accidentally pressed it.
Figure 11. User input values.

You might also like