Before proceeding further, I recommend you read my first article: Getting Started with Microsoft Bot Framework.
Once you are done with creating the project as you can see there is an API Controller in Controllers folder named “MessageController”.
- [BotAuthentication]
- public class MessagesController: ApiController
- {
- /// <summary>
- /// POST: api/Messages
- /// Receive a message from a user and reply to it
- /// </summary>
- public async Task < Message > Post([FromBody] Message message)
- {
- if (message.Type == "Message")
- {
- // calculate something for us to return
- int length = (message.Text ? ? string.Empty).Length;
- // return our reply to the user
- return message.CreateReplyMessage($ "You sent {length} characters");
- }
- else
- {
- return HandleSystemMessage(message);
- }
- }
- }
I am changing text a little bit and my message will look like this.
- /// <summary>
- /// POST: api/Messages
- /// Receive a message from a user and reply to it
- /// </summary>
- public async Task < Message > Post([FromBody] Message message)
- {
- if (message.Type == "Message")
- {
- // return our reply to the user
- return message.CreateReplyMessage($ "Raj said:{message.Text}");
- }
- else
- {
- return HandleSystemMessage(message);
- }
- }
Run your application,

If you want to run on emulator to test your calls, Install emulator form here.
Pass three things when you run Bot Emulator.
- URL - You have to mention your application url with port before api/messages.
- AppId - Defined in web.config
- AppSecret - Defined in web.config

Conclusion
In this article, we have learned how to create a bot using Microsoft Bot Framework. In next article we will see how to publish your Bot Application to Microsoft Azure. If you have any question or comments, message me on C# Corner comments section.


Bhavik PatelPosted Jul 16, 2016, 6:44 PM EDT
Good one
kalu singh raoPosted Jul 5, 2016, 10:10 PM EDT
Nice...
Prasanna MuraliPosted Jun 23, 2016, 9:18 PM EDT
Nice one..
Raveendra Reddy ChitapanaPosted Jun 10, 2016, 2:25 AM EDT
Good Article
Thiruppathi RPosted Jun 9, 2016, 11:05 PM EDT
Nice.
RajaPosted Jun 9, 2016, 8:35 PM EDT
Nice Share...
Debasis SahaTOP 100Posted Jun 9, 2016, 8:17 PM EDT
Good one..
Sanjay SabariyaPosted Jun 8, 2016, 7:49 PM EDT
nice one..
Santhakumar MunuswamyPosted Jun 8, 2016, 7:38 PM EDT
Thanks for sharing
Mahesh ChandTOP 10Posted Jun 8, 2016, 6:50 PM EDT
Nice to see some Bot applications. This will be the next big thing.
jaymin sutharPosted Jun 8, 2016, 6:27 PM EDT
Give us source code
jaymin sutharPosted Jun 8, 2016, 6:27 PM EDT
Provide source code
Bhavik PatelPosted Jun 8, 2016, 6:22 PM EDT
nice explained.
Sonu ChaudharyPosted Jun 8, 2016, 10:52 AM EDT
good one ..