BaseAdapter class
Abstract base class for all adapters in the Agents framework.
Remarks
This class provides core functionality for handling conversations, managing middleware, authentication, and error handling. Adapters are responsible for translating between the Agents framework and specific communication channels (like Teams, Web Chat, etc.).
Key features:
- Middleware pipeline for processing incoming and outgoing activities
- Error handling and recovery mechanisms
- Authentication provider integration
- Abstract methods for channel-specific operations
- Context management with revocable proxies for security
Properties
| Connector |
Symbol key used to store connector client instances in the TurnContext. |
| on |
Gets the error handler for the adapter. |
| User |
Symbol key used to store User Token Client instances in the TurnContext. |
Methods
| continue |
Continues a conversation. |
| delete |
Deletes an existing activity. |
| get |
|
| get |
|
| send |
Sends a set of activities to the conversation. |
| update |
Updates an existing activity. |
| upload |
|
| use((Middleware | Middleware |
Adds middleware to the adapter's middleware pipeline. |
Property Details
ConnectorClientKey
Symbol key used to store connector client instances in the TurnContext.
ConnectorClientKey: symbol
Property Value
symbol
onTurnError
Gets the error handler for the adapter.
(context: TurnContext, error: Error) => Promise<void> onTurnError
Property Value
(context: TurnContext, error: Error) => Promise<void>
The current error handler function.
UserTokenClientKey
Symbol key used to store User Token Client instances in the TurnContext.
UserTokenClientKey: symbol
Property Value
symbol
Method Details
continueConversation(string | JwtPayload, Partial<ConversationReference>, (revocableContext: TurnContext) => Promise<void>)
Continues a conversation.
function continueConversation(botAppIdOrIdentity: string | JwtPayload, reference: Partial<ConversationReference>, logic: (revocableContext: TurnContext) => Promise<void>): Promise<void>
Parameters
- botAppIdOrIdentity
-
string | JwtPayload
- reference
-
Partial<ConversationReference>
The conversation reference to continue.
- logic
-
(revocableContext: TurnContext) => Promise<void>
The logic to execute.
Returns
Promise<void>
A promise representing the completion of the continue operation.
deleteActivity(TurnContext, Partial<ConversationReference>)
Deletes an existing activity.
function deleteActivity(context: TurnContext, reference: Partial<ConversationReference>): Promise<void>
Parameters
- context
- TurnContext
The TurnContext for the current turn.
- reference
-
Partial<ConversationReference>
The conversation reference of the activity to delete.
Returns
Promise<void>
A promise representing the completion of the delete operation.
getAttachment(TurnContext, string, string)
Warning
This API is now deprecated.
This function will not be supported in future versions. Use TurnContext.turnState.get<ConnectorClient>(CloudAdapter.ConnectorClientKey). Gets an attachment.
function getAttachment(context: TurnContext, attachmentId: string, viewId: string): Promise<ReadableStream>
Parameters
- context
- TurnContext
- attachmentId
-
string
The attachment ID.
- viewId
-
string
The view ID.
Returns
Promise<ReadableStream>
A promise representing the NodeJS.ReadableStream for the requested attachment.
getAttachmentInfo(TurnContext, string)
Warning
This API is now deprecated.
This function will not be supported in future versions. Use TurnContext.turnState.get<ConnectorClient>(CloudAdapter.ConnectorClientKey). Gets attachment information.
function getAttachmentInfo(context: TurnContext, attachmentId: string): Promise<AttachmentInfo>
Parameters
- context
- TurnContext
- attachmentId
-
string
The attachment ID.
Returns
Promise<AttachmentInfo>
A promise representing the AttachmentInfo for the requested attachment.
sendActivities(TurnContext, Activity[])
Sends a set of activities to the conversation.
function sendActivities(context: TurnContext, activities: Activity[]): Promise<ResourceResponse[]>
Parameters
- context
- TurnContext
The TurnContext for the current turn.
- activities
-
Activity[]
The activities to send.
Returns
Promise<ResourceResponse[]>
A promise representing the array of ResourceResponses for the sent activities.
updateActivity(TurnContext, Activity)
Updates an existing activity.
function updateActivity(context: TurnContext, activity: Activity): Promise<void | ResourceResponse>
Parameters
- context
- TurnContext
The TurnContext for the current turn.
- activity
- Activity
The activity to update.
Returns
Promise<void | ResourceResponse>
A promise representing the ResourceResponse for the updated activity.
uploadAttachment(TurnContext, string, AttachmentData)
Warning
This API is now deprecated.
This function will not be supported in future versions. Use TurnContext.turnState.get<ConnectorClient>(CloudAdapter.ConnectorClientKey). Uploads an attachment.
function uploadAttachment(context: TurnContext, conversationId: string, attachmentData: AttachmentData): Promise<ResourceResponse>
Parameters
- context
- TurnContext
- conversationId
-
string
The conversation ID.
- attachmentData
- AttachmentData
The attachment data.
Returns
Promise<ResourceResponse>
A promise representing the ResourceResponse for the uploaded attachment.
use((Middleware | MiddlewareHandler)[])
Adds middleware to the adapter's middleware pipeline.
function use(middlewares: (Middleware | MiddlewareHandler)[]): BaseAdapter
Parameters
- middlewares
-
(Middleware | MiddlewareHandler)[]
The middleware to add.
Returns
The adapter instance.