CloudAdapter class
Adapter for handling agent interactions with various channels through cloud-based services.
- Extends
Remarks
CloudAdapter processes incoming HTTP requests from Azure Bot Service channels, authenticates them, and generates outgoing responses. It manages the communication flow between agents and users across different channels, handling activities, attachments, and conversation continuations.
Constructors
| Cloud |
Creates an instance of CloudAdapter. |
Properties
| connection |
Client for connecting to the Azure Bot Service |
| on |
Gets the error handler for the adapter. |
Inherited Properties
| Connector |
Symbol key used to store connector client instances in the TurnContext. |
| User |
Symbol key used to store User Token Client instances in the TurnContext. |
Methods
Inherited Methods
| use((Middleware | Middleware |
Adds middleware to the adapter's middleware pipeline. |
Constructor Details
CloudAdapter(AuthConfiguration, AuthProvider, UserTokenClient)
Creates an instance of CloudAdapter.
new CloudAdapter(authConfig?: AuthConfiguration, authProvider?: AuthProvider, userTokenClient?: UserTokenClient)
Parameters
- authConfig
- AuthConfiguration
The authentication configuration for securing communications.
- authProvider
- AuthProvider
No longer used.
- userTokenClient
- UserTokenClient
No longer used.
Property Details
connectionManager
Client for connecting to the Azure Bot Service
connectionManager: Connections
Property Value
Connections
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.
Inherited Property Details
ConnectorClientKey
Symbol key used to store connector client instances in the TurnContext.
ConnectorClientKey: symbol
Property Value
symbol
Inherited From BaseAdapter.ConnectorClientKey
UserTokenClientKey
Symbol key used to store User Token Client instances in the TurnContext.
UserTokenClientKey: symbol
Property Value
symbol
Inherited From BaseAdapter.UserTokenClientKey
Method Details
continueConversation(string | JwtPayload, ConversationReference, (revocableContext: TurnContext) => Promise<void>, Boolean)
Continues a conversation.
function continueConversation(botAppIdOrIdentity: string | JwtPayload, reference: ConversationReference, logic: (revocableContext: TurnContext) => Promise<void>, isResponse?: Boolean): Promise<void>
Parameters
- botAppIdOrIdentity
-
string | JwtPayload
The bot identity to use when continuing the conversation. This can be either: a string containing the bot's App ID (botId) or a JwtPayload object containing identity claims (must include aud).
- reference
- ConversationReference
The conversation reference to continue.
- logic
-
(revocableContext: TurnContext) => Promise<void>
The logic to execute.
- isResponse
-
Boolean
No longer used.
Returns
Promise<void>
A promise representing the completion of the continue operation.
createConversationAsync(string, string, string, string, ConversationParameters, (context: TurnContext) => Promise<void>)
Creates a conversation.
function createConversationAsync(agentAppId: string, channelId: string, serviceUrl: string, audience: string, conversationParameters: ConversationParameters, logic: (context: TurnContext) => Promise<void>): Promise<void>
Parameters
- agentAppId
-
string
The agent application ID.
- channelId
-
string
The channel ID.
- serviceUrl
-
string
The service URL.
- audience
-
string
The audience.
- conversationParameters
- ConversationParameters
The conversation parameters.
- logic
-
(context: TurnContext) => Promise<void>
The logic to execute.
Returns
Promise<void>
A promise representing the completion of the create operation.
createIdentity(string)
Creates the JwtPayload object with the provided appId.
static function createIdentity(appId: string): JwtPayload
Parameters
- appId
-
string
The bot's appId.
Returns
JwtPayload
The JwtPayload object containing the appId as aud.
createTurnContext(Activity, AgentHandler, JwtPayload)
Warning
This API is now deprecated.
This function will not be supported in future versions. Create TurnContext directly. Creates a TurnContext for the given activity and logic.
function createTurnContext(activity: Activity, logic: AgentHandler, identity?: JwtPayload): TurnContext
Parameters
- activity
- Activity
The activity to process.
- logic
- AgentHandler
The logic to execute.
- identity
-
JwtPayload
The identity used for the new context.
Returns
The created TurnContext.
deleteActivity(TurnContext, Partial<ConversationReference>)
Deletes an 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
The context for the turn.
- 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
The context for the turn.
- attachmentId
-
string
The attachment ID.
Returns
Promise<AttachmentInfo>
A promise representing the AttachmentInfo for the requested attachment.
process(Request<Record<string, unknown>, Record<string, undefined | string | string[]>>, Response<any, Record<string, any>>, (context: TurnContext) => Promise<void>, HeaderPropagationDefinition)
Processes an incoming request and sends the response.
function process(request: Request<Record<string, unknown>, Record<string, undefined | string | string[]>>, res: Response<any, Record<string, any>>, logic: (context: TurnContext) => Promise<void>, headerPropagation?: HeaderPropagationDefinition): Promise<void>
Parameters
- request
-
Request<Record<string, unknown>, Record<string, undefined | string | string[]>>
The incoming request.
- res
-
Response<any, Record<string, any>>
The response to send.
- logic
-
(context: TurnContext) => Promise<void>
The logic to execute.
- headerPropagation
- HeaderPropagationDefinition
Optional function to handle header propagation.
Returns
Promise<void>
sendActivities(TurnContext, Activity[])
Sends multiple 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 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
The context for the turn.
- conversationId
-
string
The conversation ID.
- attachmentData
- AttachmentData
The attachment data.
Returns
Promise<ResourceResponse>
A promise representing the ResourceResponse for the uploaded attachment.
Inherited Method Details
use((Middleware | MiddlewareHandler)[])
Adds middleware to the adapter's middleware pipeline.
function use(middlewares: (Middleware | MiddlewareHandler)[]): CloudAdapter
Parameters
- middlewares
-
(Middleware | MiddlewareHandler)[]
The middleware to add.
Returns
The adapter instance.
Inherited From BaseAdapter.use