Create a bot with the Bot Framework SDK

  • 11 minutes to read

APPLIES TO: SDK v4

In this quickstart, you'll learn how to build your first bot with the Bot Framework SDK for C#, Java, JavaScript or Python, and how to test your bot with the Bot Framework Emulator.

Creating your first bot doesn't require an Azure subscription or an Azure Bot Service resource. This quickstart focuses on creating your first bot locally. If you'd like to learn how to create a bot in Azure, see Create an Azure Bot resource.

Prerequisites

  • C#
  • Java
  • JavaScript
  • Python
  • ASP.NET Core Runtime 3.1
  • Bot Framework Emulator
  • Knowledge of ASP.NET Core and asynchronous programming in C#

Templates

  • Visual Studio
  • VS Code / CLI
  • Visual Studio 2019 or later
  • Bot Framework v4 SDK Templates for Visual Studio

To add the bot templates to Visual Studio, download and install the Bot Framework v4 SDK Templates for Visual Studio VSIX file.

Note

The VSIX package includes both .NET Core 2.1 and .NET Core 3.1 versions of the C# templates. When creating new bots in Visual Studio 2019 or later, you should use the .NET Core 3.1 templates. The current bot samples use .NET Core 3.1 templates. You can find the samples that use .NET Core 2.1 templates in the 4.7-archive branch of the BotBuilder-Samples repository.

To install the templates in Visual Studio, in the top menu bar, navigate to Extensions > Manage Extensions. Then search for and install Bot Framework v4 SDK for Visual Studio.

For information about deploying .NET Core 3.1 bots to Azure, see how to deploy your bot to Azure.

Create a bot

  • C#
  • Java
  • JavaScript
  • Python
  • Visual Studio
  • VS Code
  • CLI

In Visual Studio, create a new bot project using the Echo Bot (Bot Framework v4 - .NET Core 3.1) template. Choose AI Bots from the project types to show only bot templates.

Visual Studio create a new project dialog

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

Note

If you create a Core bot, you'll need a LUIS language model. You can create a language model at luis.ai. After creating the model, update the configuration file.

Start your bot

  • C#
  • Java
  • JavaScript
  • Python
  • Visual Studio
  • VS Code
  • CLI

In Visual Studio

  1. Open your bot project.
  2. Run the project without debugging.

This 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 on port 3978.

Start the Emulator and connect your bot

  1. Start the Bot Framework Emulator.

  2. Select Open Bot on the Emulator's Welcome tab.

  3. Enter your bot's URL, which is your local host and port, with /api/messages added to the path. The address is usually: http://localhost:3978/api/messages.

    open a bot

  4. Then select Connect.

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

    echo message

Additional Resources

  • See Debug a bot for how to debug using Visual Studio or Visual Studio Code and the Bot Framework Emulator.
  • See Tunneling (ngrok) for information on how to install ngrok.

Next steps