Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Create a Hello bot using Microsoft Botbuilder SDK in Node.js


    Understanding the basics of botbuilder sdk by microsoft, and exploring the basic bot setup to run and respond to messages on any command line client.

    The botframework provides two connector classes ConsoleConnector, ChatConnector.

    1. To setup connection to the terminal we used the ConsoleConenctor class
    2. Though in production environment you would like to deploy the bot on to various platforms like facebook, skype, slack etc. the ChatConnector class provides the functionality to do this.
    3. The Chat Connector setup is a bit more complicated, yet doesn't affect the actual logic that you will build your bot on.


    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    First, we'll start by installing the BotBuilder SDK. Let's clear this out. Now, we'll import the BotBuilder SDK as Builder using the require function. We'll create a connector, especially the console connector, using the BotBuilder SDK's ConsoleConnector class.

    Now, we'll start listening on the disconnector using the listen function. Then we can take input from the console and output to the console. We can then use the BotBuilder SDK's universal bot class to instantiate a new bot.

    The constructer takes in two parameters. The first one is the connector itself, and the second one is a callback function that is called whenever an input is provided from the console. The callback function takes in a single parameter session. The session has some useful functions when such a function is send.

    We can use the send function to send a reply as soon as we have an input. Now, we can run the bot from the console. As you can see, as soon as we give it an input we could then output as hey. No matter what input you give it, you could always supply it with the string hey. Let's make our bot a little bit more interesting by canceling in the input.

    We'll change the string to inaudible and then we'll add the actual input that is parsed in through the session variable to the string. Now, let's go ahead and stop our bot and restart it. Let's give it an input of hi. The bot, I called it hi with the string attached. If you give it any other string it will take it out of the string and just throw it out.