Create a bot with the Bot Framework SDK for .NET

APPLIES TO: yesSDK v4 no SDK v3

This quickstart walks you through building a bot by using the C# template, and then testing it with the Bot Framework Emulator.

Creating a bot with Azure Bot Service and creating a bot locally are independent, parallel ways to create a bot.

Prerequisites

Create a bot

Install BotBuilderVSIX.vsix template that you downloaded in the prerequisites section.

In Visual Studio, create a new bot project using the Echo Bot (Bot Framework v4) template.

Visual Studio project

Tip

If needed, change the project build type to .Net Core 2.1. Also if needed, update the Microsoft.Bot.Builder NuGet packages.

Thanks to the template, your project contains all of the code that's necessary to create the bot in this quickstart. You won't actually need to write any additional code.

Start your bot in Visual Studio

When you click the run button, Visual Studio will build the application, deploy it to localhost, and launch the web browser to display the application's default.htm page. At this point, your bot is running locally.

Start the emulator and connect your bot

Next, start the emulator and then connect to your bot in the emulator:

  1. Click the Create a new bot configuration link in the emulator "Welcome" tab.
  2. Fill out the fields for your bot. Use your bot's welcome page address (typically http://localhost:3978) and append routing info '/api/messages' to this address.
  3. then click Save and connect.

Interact with your bot

Send a message to your bot, and the bot will respond back with a message.

Emulator running

Note

If you see that the message can not be sent, you might need to restart your machine as ngrok didn't get the needed privileges on your system yet (only needs to be done one time).

Additional resources

See tunneling (ngrok) for how to connect to a bot hosted remotely.

Next steps