Proactive.ContinueConversationAsync Method

Definition

Overloads

Name Description
ContinueConversationAsync(IChannelAdapter, Conversation, RouteHandler, String[], IActivity, CancellationToken)

Continues an existing conversation by calling the specified route handler within the context of the provided conversation reference. This method will provide TurnContext and TurnState relative to the original conversation.

ContinueConversationAsync(IChannelAdapter, String, RouteHandler, String[], IActivity, CancellationToken)

Continues an existing conversation by resuming activity using the specified channel adapter and conversation ID. The conversation must have previously been stored using StoreConversationAsync(ITurnContext, CancellationToken).

See ContinueConversationAsync(IChannelAdapter, Conversation, RouteHandler, String[], IActivity, CancellationToken) for more details.

ContinueConversationAsync(IChannelAdapter, Conversation, RouteHandler, String[], IActivity, CancellationToken)

Continues an existing conversation by calling the specified route handler within the context of the provided conversation reference. This method will provide TurnContext and TurnState relative to the original conversation.

public System.Threading.Tasks.Task ContinueConversationAsync(Microsoft.Agents.Builder.IChannelAdapter adapter, Microsoft.Agents.Builder.App.Proactive.Conversation conversation, Microsoft.Agents.Builder.App.RouteHandler continuationHandler, string[] autoSignInHandlers = default, Microsoft.Agents.Core.Models.IActivity continuationActivity = default, System.Threading.CancellationToken cancellationToken = default);
member this.ContinueConversationAsync : Microsoft.Agents.Builder.IChannelAdapter * Microsoft.Agents.Builder.App.Proactive.Conversation * Microsoft.Agents.Builder.App.RouteHandler * string[] * Microsoft.Agents.Core.Models.IActivity * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function ContinueConversationAsync (adapter As IChannelAdapter, conversation As Conversation, continuationHandler As RouteHandler, Optional autoSignInHandlers As String() = Nothing, Optional continuationActivity As IActivity = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

adapter
IChannelAdapter

The channel adapter used to continue the conversation. Must not be null.

conversation
Conversation

Instance of a Conversation. This can be created with Conversation constructors or ConversationBuilder.

continuationHandler
RouteHandler

The route handler delegate to execute within the continued conversation context. Must not be null.

autoSignInHandlers
String[]

Optional: The list of tokens to get. If a handler requires sign-in, only those that have done that can be returned.

continuationActivity
IActivity

Optional. If null the default continuation activity of type Event and name "ContinueConversation" is used.

cancellationToken
CancellationToken

A cancellation token that can be used to cancel the asynchronous operation.

Returns

A task that represents the asynchronous operation.

Exceptions

Thrown if the RouteHandler specifies token handlers and not all have been signed into.

Remarks

Add a ContinueConversation handler in your AgentApplication to handle incoming requests to continue conversations. For example:

public class MyProactiveAgent : AgentApplication 
{
    [ContinueConversation]
    public async Task HandleContinueConversationAsync(ITurnContext turnContext, TurnState turnState, CancellationToken cancellationToken)
    {
        // ITurnContext and TurnState will be relative to the original conversation, allowing you to continue the conversation as 
        // if you were responding to an incoming activity.
    }
}

In Program.cs, map configured ContinueConversation handlers to Http endpoints:

app.MapAgentProactiveEndpoints<MyProactiveAgent>();

Applies to

ContinueConversationAsync(IChannelAdapter, String, RouteHandler, String[], IActivity, CancellationToken)

Continues an existing conversation by resuming activity using the specified channel adapter and conversation ID. The conversation must have previously been stored using StoreConversationAsync(ITurnContext, CancellationToken).

See ContinueConversationAsync(IChannelAdapter, Conversation, RouteHandler, String[], IActivity, CancellationToken) for more details.

public System.Threading.Tasks.Task ContinueConversationAsync(Microsoft.Agents.Builder.IChannelAdapter adapter, string conversationId, Microsoft.Agents.Builder.App.RouteHandler continuationHandler, string[] autoSignInHandlers = default, Microsoft.Agents.Core.Models.IActivity continuationActivity = default, System.Threading.CancellationToken cancellationToken = default);
member this.ContinueConversationAsync : Microsoft.Agents.Builder.IChannelAdapter * string * Microsoft.Agents.Builder.App.RouteHandler * string[] * Microsoft.Agents.Core.Models.IActivity * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function ContinueConversationAsync (adapter As IChannelAdapter, conversationId As String, continuationHandler As RouteHandler, Optional autoSignInHandlers As String() = Nothing, Optional continuationActivity As IActivity = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

adapter
IChannelAdapter

The channel adapter used to send and receive activities for the conversation.

conversationId
String

The unique identifier of the conversation to continue. Cannot be null or empty.

continuationHandler
RouteHandler

A delegate that handles the routing of activities within the continued conversation.

autoSignInHandlers
String[]

Optional: The list of tokens to get. If a handler requires sign-in, only those that have done that can be returned.

continuationActivity
IActivity

Optional. If null the default continuation activity of type Event and name "ContinueConversation" is used.

cancellationToken
CancellationToken

A cancellation token that can be used to cancel the asynchronous operation.

Returns

A task that represents the asynchronous operation.

Exceptions

Thrown if no conversation reference is found for the specified conversation ID.

Thrown if the RouteHandler specifies token handlers and not all have been signed into.

Applies to