BotAdapter class

Abstract base class for all adapter plugins.

Remarks

Adapters manage the communication between the bot and a user over a specific channel, or set of channels.

Properties

onTurnError

Gets/sets a error handler that will be called anytime an uncaught exception is raised during a turn.

Methods

continueConversation(Partial<ConversationReference>, (revocableContext: TurnContext) => Promise)

Proactively continues an existing conversation.

deleteActivity(TurnContext, Partial<ConversationReference>)

Deletes an existing activity.

sendActivities(TurnContext, Partial<Activity>[])

Sends a set of activities to the user.

updateActivity(TurnContext, Partial<Activity>)

Replaces an existing activity.

use((context: TurnContext, next: () => Promise<void>) => Promise | Middleware[])

Registers middleware handlers(s) with the adapter.

Property Details

onTurnError

Gets/sets a error handler that will be called anytime an uncaught exception is raised during a turn.

onTurnError: (context: TurnContext, error: Error) => Promise<void>

Property Value

(context: TurnContext, error: Error) => Promise<void>

Method Details

continueConversation(Partial<ConversationReference>, (revocableContext: TurnContext) => Promise)

Proactively continues an existing conversation.

function continueConversation(reference: Partial<ConversationReference>, logic: (revocableContext: TurnContext) => Promise<void>)

Parameters

reference
Partial<ConversationReference>

Conversation reference for the conversation being continued.

logic
(revocableContext: TurnContext) => Promise<void>

Function to execute for performing the bots logic.

Returns

Promise<void>

deleteActivity(TurnContext, Partial<ConversationReference>)

Deletes an existing activity.

function deleteActivity(context: TurnContext, reference: Partial<ConversationReference>)

Parameters

context
TurnContext

Context for the current turn of conversation with the user.

reference
Partial<ConversationReference>

Conversation reference of the activity being deleted.

Returns

Promise<void>

sendActivities(TurnContext, Partial<Activity>[])

Sends a set of activities to the user.

function sendActivities(context: TurnContext, activities: Partial<Activity>[])

Parameters

context
TurnContext

Context for the current turn of conversation with the user.

activities
Partial<Activity>[]

Set of activities being sent.

Returns

Promise<ResourceResponse[]>

Remarks

An array of responses from the server will be returned.

updateActivity(TurnContext, Partial<Activity>)

Replaces an existing activity.

function updateActivity(context: TurnContext, activity: Partial<Activity>)

Parameters

context
TurnContext

Context for the current turn of conversation with the user.

activity
Partial<Activity>

New replacement activity. The activity should already have it's ID information populated.

Returns

Promise<void>

use((context: TurnContext, next: () => Promise<void>) => Promise | Middleware[])

Registers middleware handlers(s) with the adapter.

function use(middleware: (context: TurnContext, next: () => Promise<void>) => Promise<void> | Middleware[])

Parameters

middleware
(context: TurnContext, next: () => Promise<void>) => Promise<void> | Middleware[]

One or more middleware handlers(s) to register.

Returns

this