Create a bot with the Bot Framework SDK for .NET
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.
- Visual Studio 2017 or later
- Bot Framework SDK v4 template for C#
- Bot Framework Emulator
- Knowledge of ASP.Net Core and asynchronous programming in C#
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.
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:
- Click the Create a new bot configuration link in the emulator "Welcome" tab.
- 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.
- then click Save and connect.
Interact with your bot
Send a message to your bot, and the bot will respond back with a message.
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).
See tunneling (ngrok) for how to connect to a bot hosted remotely.