Skip to content

Latest commit

 

History

History
119 lines (65 loc) · 5.87 KB

File metadata and controls

119 lines (65 loc) · 5.87 KB

Build a weather bot

In this tutorial, you will build a weather bot using Bot Framework Composer. We'll start simple and gradullay introduce sophistication. Here are the areas we'll cover:

  • Create a new Bot
  • Author a new dialog
  • Add global help, cancel handling
  • Use language generation to power your bot's responses
  • Use Adaptive cards
  • Handling interruptions in the conversation flow
  • Add multiple dialogs to help your bot fulfill more than one scenario

Prerequisites

  • Bot Framework Composer
  • Cognitive Service Language Understanding authoring resource. To verify, click on Environment details tab in the integrated documentation pane. You should see non empty values for LUIS authoring key 1 and LUIS authoring key 2.

Create the Weather Bot

The first step in creating a bot with Bot Framework Composer is to create a new bot project from the home screen in the Composer. This will create a new folder locally on your computer with all the files necessary to build, test and run the bot.

Create Project

  1. From the home screen, select New from the upper left corner. You'll be presented with a dialog with options to either create an empty bot project from scratch, or to create one based on a template. For this workshop, make sure Create from Scratch selected and click Next

    create project

  2. The second screen asks for a Name and Description of your bot. Let's call it:

    WeatherBot

    and give it a description:

    A friendly bot who can talk about the weather.

    Make sure not to put any spaces or special characters in the bot's name.

    Leave the Location field with its default value - this will put the bot project into Composer's default project folder where it will be easy to find.

    create bot

  3. Click Next, and Composer will create the project for you!

Give your bot something to say

After creating your bot, Composer will load the new bot's Main dialog in the editor. It should look like this:

bot conversation

Each dialog contains one or more Triggers that define the actions available to the bot while the dialog is active. Right now the dialog is empty, so the bot won't do anything.

You will notice that the new bot is pre-configured with one trigger in the left dialogs window - Conversation started (ConversationUpdate).

Triggers help your dialog capture events of interest and respond to them using actions.

  1. Click the Conversation started (ConversationUpdate) trigger in the left hand explorer.

  2. You will see a new flow has been added to the dialog.

    dialog

  3. To help keep the bot organized, let's rename this trigger to something that describes what it does. In the property panel on the right side of the screen, click on the name of the trigger ("Conversation started (ConversationUpdate)"). You'll be able to update the title there, and the change will be instantly reflected in the dialog and navigation on the left. Rename ths trigger to:

    WelcomeTheUser

    trigger

Now, let's actually make the bot do something! Inside the flow, you'll see that the teal Trigger box has a line below it that includes in a "+" button.

The "+" button can be used to add Actions to the conversation flow. You can use this to add actions to the end of a flow, or insert actions at an earlier point.

For now, let's instruct the bot to send a simple greeting.

  1. Click the "+" button and select the first menu item Send a response.

    menu

  2. Select the new Send a response action in the flow and it's properties will appear on the right hand side of the screen. This action has only one main property - the text of the activity to send.

  3. Type a welcome message into this field. It is always a good idea to have your bot introduce itself and explain it's main features. So let's make the welcome message something like:

    Hi! I'm a friendly bot that can help with the weather. Try saying WEATHER or FORECAST.

Your bot should now look like this:

activity

Next, let's temporarily disable the recognizer for the main dialog. We will get back to this in the next step.

  1. Click on WeatherBot.Main in the left pane to bring up the properties editor for the root dialog.

  2. In the property editor on the right hand side, click on Recognizer type and select None.

    Dialogs in Composer support two different recognizer types - LUIS, Regex. Unless you need intent classification or entity extraction, we can remove recognizer by setting it to None.

    recognizer

Start your bot and test it

Now that our new bot has its first simple feature, let's launch it in the emulator and make sure everything works.

  1. Click the Start Bot button in the upper right hand corner of the screen. This tells Composer to launch the bot's runtime (an external app powered by the Bot Framework SDK) and updates it with the latest content and settings from Composer.

  2. After a few seconds, a second link will appear next to the button thats Test in Emulator. Click this link to open Emulator and connect.

    start bot

You should see a window like this appear:

emulator

And the bot should immediately greet you with the message we just configured:

emulator

We now have a working bot, and we're ready to add some more substantial functionality!

Next steps