Tutorial: Create and test a bot
APPLIES TO: Composer v1.x and v2.x
This tutorial shows you how to create a basic bot.
You will learn how to:
- Create a basic bot using Bot Framework Composer
- Run the bot locally and test it using the Bot Framework Emulator
Create the bot
The first step in creating a bot with Composer is to start a project from a template. This will create a new folder on your local computer with all the files necessary to build, test and run the bot.
Select + Create new.
Select the C# Empty Bot template. Then select Next.
The Empty Bot template creates a bot with two triggers:
- Greeting: when a user connects to the bot, sends the user a greeting.
- Unknown intent: when the user sends a message the bot doesn't recognize, the bot sends a message telling the user it did not understand.
Now fill in the following values on the Create your bot project window:
- Name: weather_bot
- Runtime type: Select Azure Web App
- Location: Select a location to store your bot.
Select Submit to create a bot from the template. Note that this may take a few moments.
After creating the bot, Composer will load the bot's main dialog.
A dialog contains one or more triggers that define the actions available to the bot while the dialog is active. When you create a new bot, an Activities trigger of type Greeting (ConversationUpdate activity) is automatically provisioned. Triggers help your dialog capture events of interest and respond to them using actions.
Select the Greeting trigger on the left. Scroll to the bottom and select the Send a response action.
Select the text on the right (Welcome to your bot). Delete the text and replace it with the following:
Welcome to the weather bot! Say "weather" to get started.
Your screen should look like the following:
Your bot is now ready to test.
Test the bot
Now that your new bot has its first simple feature, you can launch it in Web Chat and verify that it works.
Select Start bot in the upper right corner of the screen. This tells Composer to launch the bot's runtime, which is powered by the Bot Framework SDK.
After selecting Start bot, the button text changes to Starting bot. Once the bot's runtime is running, it switches to Restart bot.
Once the bot's runtime has started, the Local bot runtime manager will open. You can also select the icon on the right of the text Restart bot, to open and close the Local bot runtime manager.
Select Open Web Chat in the Local bot runtime manager.
The Web Chat pane will appear on the right, and you should be greeted with the message in the Greeting trigger. Try typing anything to activate the Unknown intent trigger.
When you're done, you can stop the bot by selecting the Stop Bot button in the lower left of the Local bot runtime manager.
You now have a working bot, and you're ready to add more functionality!