The first step to creating a bot with Bot Framework Composer is creating a new bot project from the home screen. This will create a new folder on your computer with all the files necessary to build, test and run the bot.
-
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 sureCreate from Scratch
selected and clickNext
-
The second screen asks for a
Name
andDescription
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. -
Click
Next
, and Composer will create the project for you!
After creating your bot, Composer will load the new bot's Main
dialog in the editor. It should look like this:
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 - Handle ConversationUpdate
.
Triggers help your dialog capture events of interest and respond to them using actions.
-
Click the
Handle ConversationUpdate
trigger in the left hand explorer. -
You will see a new flow has been added to the dialog.
-
To help keep the bot organized, let's rename this trigger to something that describes what it does. In the
property editor
on the right side of the screen, click on the name of the trigger ("Handle 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
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.
-
Click the "+" button and select the first menu item
Send a response
. -
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. -
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.
Your bot should now look like this:
Next, let's temporarily disable the recognizer for the main dialog. We will come back to this in the next step.
-
Click on
WeatherBot.Main
in the left pane to bring up the properties editor for the root dialog. -
In the property editor on the right hand side, click on
Recognizer type
and selectNone
.Dialogs in Composer support 2 different recognizer types - LUIS, Regex. Unless you need intent classification or entity extraction, we can remove recognizer by setting it to
None
.
Now that our new bot has its first simple feature, let's launch it in the emulator and make sure everything works.
-
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. -
After a few seconds, a second link will appear next to the button thats
Test bot in emulator
. Click this link to open Emulator and connect.
You should see a window like this appear:
And the bot should immediately greet you with the message we just configured:
We now have a working bot, and we're ready to add some more substantial functionality!
- Create a new bot project
- Add a trigger to a dialog
- Adding an action to a trigger
- Using the dialog flow editor, property editors
- Running the bot locally
- Testing the bot using Bot Framework Emulator