Getting Started with Building Bots using Visual Studio 2017


The Bot Framework enables you to build bots that support different types of interactions with users. You can design conversations in your bot to be freeform. Your bot can also have more guided interactions where it provides the user choices or actions. The conversation can use simple text strings or more complex rich cards that contain text, images, and action buttons. And you can add natural language interactions, which let your users interact with your bots in a natural and expressive way.

In this article, we can create a bot by using the Visual studio 2017 with Bot template and testing it with the Bot Emulator.

Install Visual Studio 2017:

Download Visual Studio 2017 from the following URL given below.

Download Visual Studio 2017 from
Refer Visual Studio 2017 system requirement from


You can build bots for free with Visual Studio 2017 Community.

The Bot Builder SDK for .NET currently supports Only on Windows. Visual Studio for Mac is not supported.

Bot Application template:

Download the Bot Application template from the following url and install the template by saving the .zip file to your Visual Studio 2017 project templates directory.
The Visual Studio 2017 project templates directory is typically located following url

%USERPROFILE%\Documents\Visual Studio 2017\Templates\ProjectTemplates\Visual C#\

Create New Project:

Let's start with creating a new Bot application in Visual Studio 2017.
Click on Windows Key > Select Visual Studio 2017.

Now, open VS and create new project with c# project, select the Bot applications template as per below

The Bot application was created with all of the components and installed all required Nuget reference

Update Bot Builder Nuget Package:

Verify your application Microsoft.Bot.Builder nuget package was installed under reference .if not , refer follow below steps
Right-click on the Bot project(DevEnvExeBot) and select Manage NuGet Packages.In the Browse tab, type "Microsoft.Bot.Builder" and click on Search
Locate the Microsoft.Bot.Builder package in the list of search results, and click the Update button for that package or Uninstall and Install the package .

Update Code:

The Default application added simple conde snipper, no need to change anything. if you want to test your custom message, you can change like below.

You can find messagereceiveAsync method from Dialogs / RootDialog.cs file.

In this method activity.Text will return user text input so you can reply message based input text .

private async Task MessageReceivedAsync(IDialogContext context, IAwaitable
var activity = await result as Activity;
// calculate something for us to return
int length = (activity.Text ?? string.Empty).Length;
// return our reply to the user
if (activity.Text.Contains("technology"))
await context.PostAsync("Refer C# corner website for tecnology");
else if (activity.Text.Contains("morning"))
await context.PostAsync("Hello !! Good Morning , Have a nice Day");
else if (activity.Text.Contains("night"))
await context.PostAsync(" Good night and Sweetest Dreams with Bot Application ");
else if (activity.Text.Contains("date"))
await context.PostAsync(DateTime.Now.ToString());
await context.PostAsync($"You sent {activity.Text} which was {length} characters");

Install bot Emulator:

You will need to download and install the emulator for testing bot application .You can download bot emulator from .

Run Bot Application:

The emulator is a desktop application that lets you test and debug your bot on localhost or remotely. Now, you can click on run the application in any browser

Test Application on Bot Emulator:

  • You can follow below steps for test bot application
  • Open Bot Emulator
  • Copy above localhost url and past it from emulator eg: http://localHost:3979
  • You can append the /api/message from above localhost url eg: http://localHost:3979/api/messages.
  • You won't need to specify Microsoft App ID and Microsoft App Password for localhost testing so click on Connect


You can download the complete source code from MSDN sample. 


This article your learned about how to create Bot application using visual studio 2017.If you have any questions/ feedback/ issues, please write in the comment box.


Featured Post

Latest Windows 10 Update Is Now Breaking WiFi and IE, Edge, UWP App, Mobile Emulator and office 365 No Internet – Microsoft Shared new update Version 1903 with Fix

I have encountered lost Internet connection, network connectivity issue when using Microsoft Office, Office 365, Outlook, Teams, Internet Ex...

Subscribe to the FREE Weekly Newsletter to receive all the latest Microsoft Azure, AI, Xamarin

Popular Posts