botas-core
    Preparing search index...

    Class BotHttpClient

    Authenticated HTTP client for the Bot Service REST API.

    Wraps axios and injects a Bearer token via a request interceptor when a TokenProvider is supplied.

    Lifecycle note: Create one BotHttpClient instance per bot application and reuse it. The request interceptor is attached once in the constructor. Creating many short-lived instances is safe but wasteful — interceptors do not accumulate within a single instance.

    Response validation: Callers are responsible for validating response shapes. The generic type parameter T provides compile-time convenience but no runtime schema enforcement.

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Send an HTTP request and return the parsed response body.

      Type Parameters

      • T

        Expected shape of the response body (not validated at runtime).

      Parameters

      • method: string

        HTTP method (e.g. "GET", "POST").

      • url: string

        Fully-qualified URL to request.

      • Optionalbody: unknown

        Optional request body, serialized as JSON.

      • options: BotRequestOptions = {}

        Additional request options (error handling, headers).

      Returns Promise<T | undefined>

      The parsed response body, or undefined if the response has no content or if returnNullOnNotFound is set and a 404 was received.

      On non-404 HTTP errors, with the method, URL, and status in the message.

    • Send a GET request to a Bot Service API endpoint.

      Type Parameters

      • T

        Expected response body type.

      Parameters

      • baseUrl: string

        Service URL base (e.g. activity.serviceUrl).

      • endpoint: string

        API path (e.g. /v3/conversations).

      • Optionalparams: Record<string, string | undefined>

        Optional query string parameters; undefined values are omitted.

      • Optionaloptions: BotRequestOptions

        Additional request options.

      Returns Promise<T | undefined>

      Parsed response body, or undefined.

    post

    • post<T>(
          baseUrl: string,
          endpoint: string,
          body?: unknown,
          options?: BotRequestOptions,
          params?: Record<string, string | undefined>,
      ): Promise<T | undefined>

      Send a POST request to a Bot Service API endpoint.

      Type Parameters

      • T

        Expected response body type.

      Parameters

      • baseUrl: string

        Service URL base.

      • endpoint: string

        API path.

      • Optionalbody: unknown

        Request body, serialized as JSON.

      • Optionaloptions: BotRequestOptions

        Additional request options.

      • Optionalparams: Record<string, string | undefined>

        Optional query string parameters.

      Returns Promise<T | undefined>

      Parsed response body, or undefined.

    • Send a PUT request to a Bot Service API endpoint.

      Type Parameters

      • T

        Expected response body type.

      Parameters

      • baseUrl: string

        Service URL base.

      • endpoint: string

        API path.

      • Optionalbody: unknown

        Request body, serialized as JSON.

      • Optionaloptions: BotRequestOptions

        Additional request options.

      • Optionalparams: Record<string, string | undefined>

        Optional query string parameters.

      Returns Promise<T | undefined>

      Parsed response body, or undefined.

    • Send a DELETE request to a Bot Service API endpoint.

      Parameters

      • baseUrl: string

        Service URL base.

      • endpoint: string

        API path.

      • Optionalparams: Record<string, string | undefined>

        Optional query string parameters.

      • Optionaloptions: BotRequestOptions

        Additional request options.

      Returns Promise<void>