/qa-bot

Primary LanguageJavaScript

This sample shows how to create a simple echo bot that you can talk to from the console window.

To try this sample

  • Clone the repository
    git clone https://github.com/microsoft/botbuilder-samples.git
  • In a terminal, navigate to samples/javascript_typescript/01.console-echo
    cd samples/javascript_typescript/01.console-echo
  • Install modules and start the bot
    npm i && npm start

Prerequisite

Install TypeScript

In order to run this sample, you must have TypeScript installed. To install TypeScript:

  • Navigate to the TypeScript portal.
  • Click the Download button.
  • Follow the installation instructions for your development environment.

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