botas-core
    Preparing search index...

    Class BotApplication

    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).

    const bot = new BotApplication({ clientId: '...', clientSecret: '...' });

    bot.on('message', async ({ activity, send }) => {
    await send(`You said: ${activity.text}`);
    });
    Index

    Constructors

    Properties

    version: string = ...

    The Botas SDK version.

    Resolved options for this application instance.

    conversationClient: ConversationClient

    Client for sending, updating, and deleting activities via the Bot Service API.

    onActivity?: CoreActivityHandler

    Optional CatchAll handler. When set, completely replaces per-type handler dispatch — all activities are delivered directly to this handler.

    Methods

    • Register a handler for a given activity type.

      Only one handler per type is supported; registering the same type twice replaces the previous handler.

      Parameters

      • type: string

        CoreActivity type string (e.g. "message", "conversationUpdate").

      • handler: CoreActivityHandler

        Async function called with the turn context.

      Returns this

      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.

      Parameters

      Returns this

      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.

      Parameters

      • req: IncomingMessage

        Node.js incoming HTTP request.

      • res: ServerResponse

        Node.js server response to write the result to.

      Returns Promise<void>

      Never — errors are caught and written to res as HTTP status codes.

    • 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.

      Parameters

      • body: string

        Raw JSON string from the HTTP request body.

      Returns Promise<InvokeResponse | undefined>

      The InvokeResponse for invoke activities, or undefined for all other activity types.

      If the body is not valid JSON or fails activity validation.

      If the activity's serviceUrl is not on the allowlist.

      If an activity handler throws during processing.