In this article series, we will create and run our first application using Bot framework template installed in previous article.
Start Visual Studio, go to File -> New Project and select Bot Application template under Visual C#. Name the project say HelloBots and click OK button.
Here is how the created project looks like
style="display:block; text-align:center;"
data-ad-format="fluid"
data-ad-layout="in-article"
data-ad-client="ca-pub-5021110436373536"
data-ad-slot="9215486331">
If you are familiar with Asp.Net MVC and Web Api it looks a similar structure. Those who are new, I will try to explain purpose of 2 important classes:
- WebApiConfig
Contains logic for routing user actions to specific method on controller.
- MessageController
It’s a class inheriting ApiController (Base class for all Microsooft Web API’s) and contain method that will be called when user interacts with chat bots. So the sequence of events will be like User enter message in Bot and message is received by MessageController which can further pass it on to Connector services or return response if it’s a simple flow.
Run your project. It will download all nuget packages and display web page as shown below.
Let’s now test our Bot. Since we are just using the boilerplate, when we send a message to it , it will return a custom message like
In development environment, we can test our Bot using Bot emulator which is part of Bot framework and can be downloaded and installed from here
style="display:block; text-align:center;"
data-ad-format="fluid"
data-ad-layout="in-article"
data-ad-client="ca-pub-5021110436373536"
data-ad-slot="9215486331">
In Bot emulator, enter the full Url of you Bot Endpoint. In our case its http://localhost:3979/api/Messages
Leave rest values as default and click connect. Once connected you can type a message in “Type Your message…” box at the bottom of emulator and press enter to interact with Bot.
In next article we will discuss about various kinds of activities we can use with Bot frameworks and Emulators and will try to deep dive into Emulators.