Wednesday, October 27Digital Marketing Journals

Building a Weather Bot using Bot Framework Composer- Part 2 | by Mitusha Arya | Jul, 2021


Mitusha Arya

The first part of the tutorial can be found here — https://chatbotslife.com/building-a-weather-bot-with-bot-framework-composer-fa62b7cc9623

A dialog contains one or more triggers. Each trigger consists of one or more actions which are the set of instructions that the bot will execute. Dialogs can also call other dialogs and can pass values back and forth between them.

In this tutorial, you learn how to:

  • Add dialogs to a basic bot.
  • Run the bot locally and test it.

The main function of the bot is to report current weather conditions.

To do this, you will create a dialog that:

  • Prompts the user to enter a postal code to use as a location for weather lookup.
  • Calls an external API to retrieve the weather data for the specified postal code.
  1. Start Composer.
  2. Select the weather_bot bot project from the Recent bot list on the homepage.
  3. Select the three dots next your weather_bot bot project. Then select + Add a dialog.
  1. In the pop-up window, enter the following:
  2. Name: getWeather
  3. Description: Get the current weather conditions.
  1. Select OK to create the dialog.
  2. Now select the + button under the BeginDialog dialog event in the center of the authoring canvas. Select Send a response.
  3. On the right in the response editor, enter the following:
  4. Bot responseCopy
  1. We will add more functionality later, like retrieving the weather forecast, but first we need to connect the getWeather dialog to the bot with a trigger.

1. How Conversational AI can Automate Customer Service

2. Automated vs Live Chats: What will the Future of Customer Service Look Like?

3. Chatbots As Medical Assistants In COVID-19 Pandemic

4. Chatbot Vs. Intelligent Virtual Assistant — What’s the difference & Why Care?

You can break down a conversation flow into different dialogs and then connect them. The following steps explain how to connect the newly created getWeather dialog to the main dialog.

  1. Select the weather_bot dialog. Then go over to the right and change the Recognizer Type to Regular expression recognizer.
  1. Now select the three dots next to the weather_bot dialog on the left and select + Add new trigger.
  1. In the Create a trigger pop-up window, enter the following information:
  • In both What is the name of this trigger (RegEx) and Please input regex pattern text boxes, enter weather.
  • Select Submit.
  1. Note
  2. This tells the bot to look for the word weather anywhere in an incoming message. Regular expression patterns are generally much more complicated, but this is adequate for the purpose of this example.
  3. In the center of the authoring canvas, under the weather Intent recognized trigger, select the + button.
  4. Hover over Dialog management and then select Begin a new dialog.
  1. On the right, under Dialog name, select getWeather. Now your weather bot is connected to the weather trigger.

You can now test your bot, and the trigger and dialog you added to it.

  1. Go to the top right of Composer and select Start bot. It may take a few moments for your bot to start.
  2. Note
  3. If the bot is still running from the previous tutorial, you can select Restart bot. This will update the bot runtime app with all the new content and settings.
  4. The Local bot runtime manager will open. Select Open Web Chat. The Web Chat pane on the right will appear.
  1. Now test some different phrases. Notice that the bot will send the message in the getWeather dialog if the word weather is in your response. Otherwise the bot will send the message in the Unknown intent trigger.

Leave a Reply