Create a new BotApplication.
Options fall back to environment variables (CLIENT_ID, CLIENT_SECRET,
TENANT_ID) when not provided explicitly.
Bot credentials and configuration. Defaults to env vars.
Static ReadonlyversionThe Botas SDK version.
ReadonlyoptionsResolved options for this application instance.
ReadonlyconversationClient for sending, updating, and deleting activities via the Bot Service API.
OptionalonOptional CatchAll handler. When set, completely replaces per-type handler dispatch — all activities are delivered directly to this handler.
Register a handler for a given activity type.
Only one handler per type is supported; registering the same type twice replaces the previous handler.
CoreActivity type string (e.g. "message", "conversationUpdate").
Async function called with the turn context.
this for method chaining.
Add a middleware to the turn processing pipeline.
Middleware runs in registration order before the activity handler.
Middleware function to add. See TurnMiddleware.
this for method chaining.
Register a handler for an invoke activity by its activity.name sub-type.
The handler must return an InvokeResponse — the status and body are written directly to the HTTP response for invoke activities.
Only one handler per name is supported; registering the same name twice replaces the previous handler.
The invoke name (e.g. "adaptiveCard/action", "task/fetch").
Async function that returns an InvokeResponse.
this for method chaining.
Process an incoming HTTP request (Express / Node.js http.Server).
Reads the request body, validates the activity, runs the middleware
pipeline, and writes a 200 {} response. For invoke activities,
writes the InvokeResponse returned by the registered handler instead.
Writes 413 for oversized bodies and 500 on unhandled errors.
Node.js incoming HTTP request.
Node.js server response to write the result to.
Process a raw JSON request body without touching the HTTP layer.
Use this with frameworks that manage their own response lifecycle (e.g.
Hono), where writing to ServerResponse directly would cause issues.
For invoke activities, the returned InvokeResponse must be
written to the HTTP response by the caller.
Raw JSON string from the HTTP request body.
The InvokeResponse for invoke activities, or
undefined for all other activity types.
Proactively send an activity to a conversation.
Bot Service service URL.
Target conversation ID.
CoreActivity payload to send.
The ResourceResponse containing the new activity ID, or undefined.
ProtectedhandleInternalDispatch the activity to the CatchAll or per-type handler.
Core bot application that processes incoming Bot Service activities.
Web-server-agnostic — use processAsync with Express (or any Node.js
http.Server) and processBody with frameworks that manage their own HTTP response lifecycle (e.g. Hono).Example