Skip to content

Latest commit

 

History

History
 
 

01.console-echo

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

console echo

Bot Framework v4 console bot sample

This bot has been created using Bot Framework, it shows how to create a simple echo bot that you can talk to from the console window.

Prerequisites

  • Node.js version 10.14.1 or higher

    # determine node version
    node --version

To try this sample

  • Clone the repository

    git clone https://github.com/microsoft/botbuilder-samples.git
  • In a terminal, navigate to samples/typescript_nodejs/01.console-echo

    cd samples/typescript_nodejs/01.console-echo
  • Install modules

    npm install
  • Start the bot

    npm start

Testing the bot

After running npm start, the bot presents a prompt directly in the console window.

Send messages to the bot by typing them into the console. The bot will echo your message back to you.

Adapters

Adapters such as the ConsoleAdapter provide an abstraction for your bot to work with a variety of environments and messaging platforms.

The adapter is responsible for directing incoming and outgoing communication, authentication, and so on. Adapters for different platforms and messaging technologies differ internally, but achieve the same goal - connecting bots to a stream of messages and events from users. When your bot receives an activity, the adapter wraps up everything about that activity, creates a context object, passes it to your bot's application logic, and sends responses generated by your bot back to the user's channel.

In most situations, we don't work with the adapter directly, but it's good to know it's there and what it does. In this example, we're using the ConsoleAdapter, which provides a very simple way to exchange messages - they're sent and received via the console window. Using the ConsoleAdapter is a great way of getting started quickly with Botbuilder. It also allows you to build and test bots that operate on your local machine without any external API calls or client applications.

Other available adapters connect your bot to the web, or through the BotFramework Connector Service, to many popular messaging platforms.

Further reading