Registry / communication / botbuilder

botbuilder

JSON →
library0.0.1jsnpmunverified

The Bot Framework SDK for JavaScript (botbuilder) is a comprehensive toolkit for developing intelligent conversational AI bots. It enables developers to build, connect, and manage bots that interact with users across various channels like web chat, Teams, Slack, and more. The current stable version is 4.23.3, with releases occurring monthly or bi-monthly, frequently addressing security updates, dependency bumps, and support for newer Node.js and TypeScript versions. Key differentiators include deep integration with Microsoft Azure Bot Service, a robust middleware pipeline, built-in dialog management, and enterprise-grade scalability. It is designed for both simple Q&A bots and complex, multi-turn conversational agents.

npm install botbuilder
INSTALL
IMPORT
SIG · BOTBUILDER
B
botbuilder
communicationjavascriptv0.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BotFrameworkAdapter
import { BotFrameworkAdapter } from 'botbuilder';
const { BotFrameworkAdapter } = require('botbuilder');
CommonJS `require` works, but ESM `import` is preferred in modern Node.js projects. This class initializes the bot's communication with channels.
ActivityHandler
import { ActivityHandler } from 'botbuilder';
import ActivityHandler from 'botbuilder';
This is a named export. `ActivityHandler` is the base class for implementing bot logic and processing incoming activities.
TurnContext
import { TurnContext, MessageFactory } from 'botbuilder';
import * as botbuilder from 'botbuilder'; const context = new botbuilder.TurnContext(...);
Directly importing `TurnContext` and `MessageFactory` is standard for handling interaction context and creating outgoing messages.

This quickstart sets up a basic 'echo' bot using `botbuilder` and `restify`. It demonstrates handling incoming messages, welcoming new members, and configuring error handling for the adapter. It uses environment variables for bot credentials.

import { BotFrameworkAdapter, ActivityHandler, TurnContext } from 'botbuilder'; import * as restify from 'restify'; // Create adapter. // See https://aka.ms/about-bot-adapter to learn more about adapters. const adapter = new BotFrameworkAdapter({ appId: process.env.MicrosoftAppId ?? '', appPassword: process.env.MicrosoftAppPassword ?? '' }); // Catch-all for errors. adapter.onTurnError = async (context, error) => { // This check writes out errors to console log .vs. app insights. console.error(`\n[onTurnError] Unhandled error: ${ error }`); // Send a trace activity, which will be displayed in Bot Framework Emulator await context.sendTraceActivity( 'OnTurnError Trace', `${ error }`, 'https://www.botframework.com/schemas/error', 'TurnError' ); // Send a message to the user await context.sendActivity('The bot encountered an error or bug.'); await context.sendActivity('To continue to run this bot, please fix the bot source code.'); }; // Define a bot. class MyBot extends ActivityHandler { constructor() { super(); this.onMessage(async (context, next) => { const replyText = `Echo: ${ context.activity.text }`; await context.sendActivity(replyText); // By calling next() you ensure that the next BotHandler is run. await next(); }); this.onMembersAdded(async (context, next) => { const welcomeText = 'Hello and welcome!'; for (const member of context.activity.membersAdded) { if (member.id !== context.activity.recipient.id) { await context.sendActivity(`Hi there ${ member.name }. ${ welcomeText }`); } } // By calling next() you ensure that the next BotHandler is run. await next(); }); } } const bot = new MyBot(); // Create HTTP server. const server = restify.createServer(); server.listen(process.env.port || process.env.PORT || 3978, () => { console.log(`\n${ server.name } listening to ${ server.url }`); console.log('\nGet Bot Framework Emulator: https://aka.ms/botframework-emulator'); console.log('\nTo talk to your bot, open the emulator and connect to: http://localhost:3978/api/messages'); }); // Listen for incoming requests. server.post('/api/messages', (req, res) => { adapter.processActivity(req, res, async (turnContext) => { // Route to main dialog. await bot.run(turnContext); }); });
Debug
Known issues
breakingNode.js versions prior to 18 are no longer supported due to updates in underlying Azure Identity and MSAL.Node packages.
fix
Upgrade your Node.js runtime to version 18 or higher (Node 20 or 22 recommended).
affects: >=4.23.0
breakingSupport for TypeScript 4.7 has been dropped due to incompatibilities with newer Node.js types. Ensure your project uses a compatible TypeScript version.
fix
Upgrade your project's TypeScript version to 5.9 or newer.
affects: >=4.23.3
gotchaFrequent security updates and dependency bumps mean that running older patch versions can expose your bot to known vulnerabilities.
fix
Regularly update `botbuilder` and its related packages to the latest stable version to incorporate critical security patches and dependency fixes.
affects: <4.23.3
gotchaFederated Identity Credentials for bot-to-channel authentication are currently supported for single-tenant applications only.
fix
If using federated credentials, ensure your bot application is configured for single-tenant authentication. Multi-tenant support may require alternative authentication methods or future SDK updates.
affects: >=4.23.2
Errors
Common errors & fixes
FetchError: request to https://login.botframework.com/v1/.well-known/openidconfiguration
Issue fetching OpenID configuration, often due to network issues, incorrect bot ID/password, or firewall blocking the endpoint.
fix
Verify network connectivity, ensure `MicrosoftAppId` and `MicrosoftAppPassword` are correctly set and valid. Check for firewall rules blocking outbound requests to `login.botframework.com`.
Error: MicrosoftAppId and MicrosoftAppPassword are required for production environments.
The `BotFrameworkAdapter` was initialized without an App ID and/or App Password, which are mandatory for connecting to channels.
fix
Set the `MicrosoftAppId` and `MicrosoftAppPassword` environment variables or provide them directly when instantiating `BotFrameworkAdapter`.
TypeError: Cannot read properties of undefined (reading 'run')
Typically occurs when `await bot.run(turnContext)` is called, but `bot` (an instance of `ActivityHandler` or a derived class) is not properly initialized or scoped.
fix
Ensure `bot` is instantiated correctly (e.g., `const bot = new MyBot();`) and is accessible in the scope where `adapter.processActivity` is called.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies
typescriptrequiredRequired for development, with specific version compatibility changes between releases.
noderequiredRuntime dependency. Minimum version requirement has increased over time.
Agent activity
39 hits · last 30 days
node
34
OpenAI (training)
1
Resources
botbuilder — npm install botbuilder · libregistry