ICopilotClient.SubscribeAsync(String, String, CancellationToken) Method

Definition

Subscribes to an ongoing conversation to receive updates and activities. This method supports reconnection scenarios by allowing specification of the last received event ID.

public System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.CopilotStudio.Client.Models.SubscribeEvent> SubscribeAsync(string conversationId, string? lastReceivedEventId, System.Threading.CancellationToken cancellationToken);
abstract member SubscribeAsync : string * string * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.CopilotStudio.Client.Models.SubscribeEvent>
Public Function SubscribeAsync (conversationId As String, lastReceivedEventId As String, cancellationToken As CancellationToken) As IAsyncEnumerable(Of SubscribeEvent)

Parameters

conversationId
String

The conversation ID to subscribe to. Cannot be null.

lastReceivedEventId
String

Optional. The ID of the last event received before disconnection. Used for resuming subscriptions.

cancellationToken
CancellationToken

Cancellation token to cancel the subscription.

Returns

An async enumerable stream of subscribe events containing activities and event IDs.

Exceptions

ArgumentNullException

Thrown when conversationId is null.

HttpRequestException

Thrown when the HTTP request to Copilot Studio fails.

JsonException

Thrown when the response cannot be deserialized.

Remarks

This feature is currently available to Microsoft internal developers only. When reconnecting, provide the last received event ID to resume from that point.

Applies to