Echo Chat Bot using Microsoft Bot Framework

. 2 min read

Howdy folks!! Glad you are here to explore and create chatbot using Microsoft Bot Framework. AI-based chatbots have started to become a ubiquitous mode of communication. Well, depends! If you are here in 2017, then AWESOME !!!, it has started to get a lot of traction and you are one of the early adopters. But, if you are here in 2020, it should already be taken the test of time.

Alright, with no further delays, let’s get started to create our first bot. I assume you are well aware of what chatbots are and its ecosystem. If not, I would recommend you to read here first.

Building an Echo Chat Bot using Microsoft Bot Framework

1. Setting up a new project

Alright, we are going to create a chatbot using Microsoft Bot Framework. MS bot framework let you create bots using C#, NodeJS, REST API and the Azure bot service. We are going to use NodeJS for this particular example.

Let’s start with creating a new NodeJS project.

Since we have our new NodeJS project now, let’s add couple of Microsoft Bot Framework libraries as project dependencies to the package.json

2. Creating a Node Server

We wanna create an HTTP server that listens to a port. We are going to use Restify here, but we can use other frameworks as well, like Express.

In the example below, we are setting up the server to listen to port 3978 as default.

3. Setting up the Microsoft Bot Connector

We want the Microsoft Bot Connector to intercept and process the message for us. We are going to instantiate the connector and let it listen to a defined path. We can have custom logic, interceptors etc. as well.

4. Processing the incoming messages

Now, let's process the incoming message from the user and provide a response back as text. For now, we are going to have an echo reply and sending the message back to the user.

5. Putting it all together

Alright, we are done with our first “Echo” bot, let’s start the bot and start testing it. For this, we would need to install Microsoft Bot Emulator in the development environment. Let’s start the bot server and start testing it.

The Bot Emulator helps us test the bot locally without deploying it on servers. For testing, we don’t require the App ID and the App Password. We can directly connect to the bot server and start testing. Note that we can see and debug the bot via the raw message exchange on the right.

Demo Clip of echo chat bot built using Microsoft Bot Framework

Testing our Echo Bot.


Don’t forget to check out the release v1.0 of the repository here for the complete code.