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
Agent |
Symbol key used to store agent identity information in the TurnContext. |
auth |
The authentication configuration for the adapter. |
auth |
The authentication provider used for token management. |
Connector |
Symbol key used to store connector client instances in the TurnContext. |
OAuth |
Symbol key used to store OAuth scope information in the TurnContext. |
on |
Gets the error handler for the adapter. |
user |
The user token client used for managing user tokens. |
Methods
continue |
Continues a conversation. |
delete |
Deletes an existing activity. |
get |
Gets an attachment. |
get |
Gets attachment information. |
send |
Sends a set of activities to the conversation. |
update |
Updates an existing activity. |
upload |
Uploads an attachment. |
use((Middleware | Middleware |
Adds middleware to the adapter's middleware pipeline. |
Property Details
AgentIdentityKey
Symbol key used to store agent identity information in the TurnContext.
AgentIdentityKey: symbol
Property Value
symbol
authConfig
The authentication configuration for the adapter.
authConfig: AuthConfiguration
Property Value
authProvider
The authentication provider used for token management.
authProvider: AuthProvider
Property Value
ConnectorClientKey
Symbol key used to store connector client instances in the TurnContext.
ConnectorClientKey: symbol
Property Value
symbol
OAuthScopeKey
Symbol key used to store OAuth scope information in the TurnContext.
OAuthScopeKey: 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.
userTokenClient
The user token client used for managing user tokens.
userTokenClient: null | UserTokenClient
Property Value
null | UserTokenClient
Method Details
continueConversation(Partial<ConversationReference>, (revocableContext: TurnContext) => Promise<void>)
Continues a conversation.
function continueConversation(reference: Partial<ConversationReference>, logic: (revocableContext: TurnContext) => Promise<void>): Promise<void>
Parameters
- 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(string, string)
Gets an attachment.
function getAttachment(attachmentId: string, viewId: string): Promise<ReadableStream>
Parameters
- attachmentId
-
string
The attachment ID.
- viewId
-
string
The view ID.
Returns
Promise<ReadableStream>
A promise representing the NodeJS.ReadableStream for the requested attachment.
getAttachmentInfo(string)
Gets attachment information.
function getAttachmentInfo(attachmentId: string): Promise<AttachmentInfo>
Parameters
- 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(string, AttachmentData)
Uploads an attachment.
function uploadAttachment(conversationId: string, attachmentData: AttachmentData): Promise<ResourceResponse>
Parameters
- 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.