Class ChannelServiceAdapterBase
An adapter that implements the Activity Protocol and can be hosted in different cloud environments both public and private.
public abstract class ChannelServiceAdapterBase : ChannelAdapter, IChannelAdapter
- Inheritance
-
ChannelServiceAdapterBase
- Implements
- Inherited Members
Constructors
ChannelServiceAdapterBase(IChannelServiceClientFactory, ILogger)
An adapter that implements the Activity Protocol and can be hosted in different cloud environments both public and private.
protected ChannelServiceAdapterBase(IChannelServiceClientFactory channelServiceClientFactory, ILogger logger = null)
Parameters
channelServiceClientFactory
IChannelServiceClientFactoryThe IConnectorFactory to use.
logger
ILoggerThe ILogger implementation this adapter should use.
Properties
ChannelServiceFactory
Gets the IChannelServiceClientFactory instance for this adapter.
protected IChannelServiceClientFactory ChannelServiceFactory { get; }
Property Value
- IChannelServiceClientFactory
The IChannelServiceClientFactory instance for this adapter.
Logger
Gets a ILogger to use within this adapter and its subclasses.
protected ILogger Logger { get; }
Property Value
Methods
ContinueConversationAsync(ClaimsIdentity, ConversationReference, AgentCallbackHandler, CancellationToken)
Sends a proactive message to a conversation.
public override Task ContinueConversationAsync(ClaimsIdentity claimsIdentity, ConversationReference reference, AgentCallbackHandler callback, CancellationToken cancellationToken)
Parameters
claimsIdentity
ClaimsIdentityA ClaimsIdentity for the conversation.
reference
ConversationReferenceA reference to the conversation to continue.
callback
AgentCallbackHandlerThe method to call for the resulting Agent turn.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
Remarks
Call this method to proactively send a message to a conversation. Most channels require a user to initiate a conversation with an Agent before the Agent can send activities to the user.
ContinueConversationAsync(ClaimsIdentity, ConversationReference, string, AgentCallbackHandler, CancellationToken)
Sends a proactive message to a conversation.
public override Task ContinueConversationAsync(ClaimsIdentity claimsIdentity, ConversationReference reference, string audience, AgentCallbackHandler callback, CancellationToken cancellationToken)
Parameters
claimsIdentity
ClaimsIdentityA ClaimsIdentity for the conversation.
reference
ConversationReferenceA reference to the conversation to continue.
audience
stringA value signifying the recipient of the proactive message.
callback
AgentCallbackHandlerThe method to call for the resulting Agent turn.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
Remarks
Call this method to proactively send a message to a conversation. Most channels require a user to initiate a conversation with an Agent before the Agent can send activities to the user.
ContinueConversationAsync(ClaimsIdentity, IActivity, AgentCallbackHandler, CancellationToken)
Sends a proactive message to a conversation.
public override Task ContinueConversationAsync(ClaimsIdentity claimsIdentity, IActivity continuationActivity, AgentCallbackHandler callback, CancellationToken cancellationToken)
Parameters
claimsIdentity
ClaimsIdentityA ClaimsIdentity for the conversation.
continuationActivity
IActivityAn Microsoft.Agents.Core.Models.Activity with the appropriate Microsoft.Agents.Core.Models.ConversationReference with which to continue the conversation.
callback
AgentCallbackHandlerThe method to call for the resulting Agent turn.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
- Task
A task that represents the work queued to execute.
Remarks
Call this method to proactively send a message to a conversation. Most channels require a user to initiate a conversation with an Agent before the Agent can send activities to the user.
ContinueConversationAsync(ClaimsIdentity, IActivity, string, AgentCallbackHandler, CancellationToken)
Sends a proactive message to a conversation.
public override Task ContinueConversationAsync(ClaimsIdentity claimsIdentity, IActivity continuationActivity, string audience, AgentCallbackHandler callback, CancellationToken cancellationToken)
Parameters
claimsIdentity
ClaimsIdentityA ClaimsIdentity for the conversation.
continuationActivity
IActivityAn Microsoft.Agents.Core.Models.Activity with the appropriate Microsoft.Agents.Core.Models.ConversationReference with which to continue the conversation.
audience
stringA value signifying the recipient of the proactive message.
callback
AgentCallbackHandlerThe method to call for the resulting Agent turn.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
Remarks
Call this method to proactively send a message to a conversation. Most _channels require a user to initiate a conversation with an Agent before the Agent can send activities to the user.
ContinueConversationAsync(string, ConversationReference, AgentCallbackHandler, CancellationToken)
Sends a proactive message to a conversation.
public override Task ContinueConversationAsync(string agentAppId, ConversationReference reference, AgentCallbackHandler callback, CancellationToken cancellationToken)
Parameters
agentAppId
stringreference
ConversationReferenceA reference to the conversation to continue.
callback
AgentCallbackHandlerThe method to call for the resulting Agent turn.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
Remarks
Call this method to proactively send a message to a conversation. Most _channels require a user to initiate a conversation with an Agent before the Agent can send activities to the user.
ContinueConversationAsync(string, IActivity, AgentCallbackHandler, CancellationToken)
Sends a proactive message to a conversation.
public override Task ContinueConversationAsync(string agentAppId, IActivity continuationActivity, AgentCallbackHandler callback, CancellationToken cancellationToken)
Parameters
agentAppId
stringcontinuationActivity
IActivityAn Microsoft.Agents.Core.Models.Activity with the appropriate Microsoft.Agents.Core.Models.ConversationReference with which to continue the conversation.
callback
AgentCallbackHandlerThe method to call for the resulting Agent turn.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
Remarks
Call this method to proactively send a message to a conversation. Most channels require a user to initiate a conversation with an Agent before the Agent can send activities to the user.
CreateClaimsIdentity(string)
This is a helper to create the ClaimsIdentity structure from an appId that will be added to the TurnContext. It is intended for use in proactive and named-pipe scenarios.
protected static ClaimsIdentity CreateClaimsIdentity(string agentAppId)
Parameters
agentAppId
stringThe Agent's application id.
Returns
- ClaimsIdentity
A ClaimsIdentity with the audience and appId claims set to the appId.
CreateConversationAsync(string, string, string, string, ConversationParameters, AgentCallbackHandler, CancellationToken)
Creates a conversation on the specified channel.
public override Task CreateConversationAsync(string agentAppId, string channelId, string serviceUrl, string audience, ConversationParameters conversationParameters, AgentCallbackHandler callback, CancellationToken cancellationToken)
Parameters
agentAppId
stringTThe application ID of the Agent.
channelId
stringThe ID for the channel.
serviceUrl
stringThe channel's service URL endpoint.
audience
stringThe audience for the connector.
conversationParameters
ConversationParametersThe conversation information to use to create the conversation.
callback
AgentCallbackHandlerThe method to call for the resulting Agent turn.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
Remarks
To start a conversation, your Agent must know its account information and the user's account information on that channel. Most channels only support initiating a direct message (non-group) conversation.
The adapter attempts to create a new conversation on the channel, and
then sends a conversationUpdate
Activity through its middleware pipeline
to the callback
method.
If the conversation is established with the specified users, the ID of the activity's Microsoft.Agents.Core.Models.Activity.Conversation will contain the ID of the new conversation.
DeleteActivityAsync(ITurnContext, ConversationReference, CancellationToken)
When overridden in a derived class, deletes an existing activity in the conversation.
public override Task DeleteActivityAsync(ITurnContext turnContext, ConversationReference reference, CancellationToken cancellationToken)
Parameters
turnContext
ITurnContextThe context object for the turn.
reference
ConversationReferenceConversation reference for the activity to delete.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
Remarks
The Microsoft.Agents.Core.Models.ConversationReference.ActivityId of the conversation reference identifies the activity to delete.
- See Also
ProcessActivityAsync(ClaimsIdentity, IActivity, AgentCallbackHandler, CancellationToken)
Creates a turn context and runs the middleware pipeline for an incoming TRUSTED activity.
public override Task<InvokeResponse> ProcessActivityAsync(ClaimsIdentity claimsIdentity, IActivity activity, AgentCallbackHandler callback, CancellationToken cancellationToken)
Parameters
claimsIdentity
ClaimsIdentityA ClaimsIdentity for the request.
activity
IActivityThe incoming activity.
callback
AgentCallbackHandlerThe code to run at the end of the adapter's middleware pipeline.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
- Task<InvokeResponse>
If an Invoke Activity was received, an Microsoft.Agents.Core.Models.InvokeResponse, otherwise null.
ProcessProactiveAsync(ClaimsIdentity, IActivity, IAgent, CancellationToken, string)
public override Task ProcessProactiveAsync(ClaimsIdentity claimsIdentity, IActivity continuationActivity, IAgent agent, CancellationToken cancellationToken, string audience = null)
Parameters
claimsIdentity
ClaimsIdentitycontinuationActivity
IActivityagent
IAgentcancellationToken
CancellationTokenaudience
string
Returns
ProcessProactiveAsync(ClaimsIdentity, IActivity, string, AgentCallbackHandler, CancellationToken)
The implementation for continue conversation.
public override Task ProcessProactiveAsync(ClaimsIdentity claimsIdentity, IActivity continuationActivity, string audience, AgentCallbackHandler callback, CancellationToken cancellationToken)
Parameters
claimsIdentity
ClaimsIdentityA ClaimsIdentity for the conversation.
continuationActivity
IActivityThe continuation Microsoft.Agents.Core.Models.Activity used to create the ITurnContext.
audience
stringThe audience for the call.
callback
AgentCallbackHandlerThe method to call for the resulting Agent turn.
cancellationToken
CancellationTokenCancellation token.
Returns
- Task
A task that represents the work queued to execute.
SendActivitiesAsync(ITurnContext, IActivity[], CancellationToken)
When overridden in a derived class, sends activities to the conversation.
public override Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext turnContext, IActivity[] activities, CancellationToken cancellationToken)
Parameters
turnContext
ITurnContextThe context object for the turn.
activities
IActivity[]The activities to send.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
- Task<ResourceResponse[]>
If the activities are successfully sent, the task result contains an array of Microsoft.Agents.Core.Models.ResourceResponse objects containing the IDs that the receiving channel assigned to the activities.
- See Also
StreamedResponseAsync(IActivity, IActivity, CancellationToken)
protected virtual Task<bool> StreamedResponseAsync(IActivity incomingActivity, IActivity outActivity, CancellationToken cancellationToken)
Parameters
incomingActivity
IActivityoutActivity
IActivitycancellationToken
CancellationToken
Returns
UpdateActivityAsync(ITurnContext, IActivity, CancellationToken)
When overridden in a derived class, replaces an existing activity in the conversation.
public override Task<ResourceResponse> UpdateActivityAsync(ITurnContext turnContext, IActivity activity, CancellationToken cancellationToken)
Parameters
turnContext
ITurnContextThe context object for the turn.
activity
IActivityNew replacement activity.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
- Task<ResourceResponse>
If the activity is successfully sent, the task result contains a Microsoft.Agents.Core.Models.ResourceResponse object containing the ID that the receiving channel assigned to the activity.
Before calling this, set the ID of the replacement activity to the ID of the activity to replace.
- See Also