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.