ICopilotClient.ExecuteAsync(String, IActivity, CancellationToken) Method

Definition

Executes an activity within the context of a specific conversation. This method ensures the activity is associated with the provided conversation ID.

public System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.Core.Models.IActivity> ExecuteAsync(string conversationId, Microsoft.Agents.Core.Models.IActivity activityToSend, System.Threading.CancellationToken cancellationToken);
abstract member ExecuteAsync : string * Microsoft.Agents.Core.Models.IActivity * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.Core.Models.IActivity>
Public Function ExecuteAsync (conversationId As String, activityToSend As IActivity, cancellationToken As CancellationToken) As IAsyncEnumerable(Of IActivity)

Parameters

conversationId
String

The conversation ID to execute the activity within. Cannot be null.

activityToSend
IActivity

The activity to send to the Copilot Studio agent. Cannot be null.

cancellationToken
CancellationToken

Cancellation token to cancel the operation.

Returns

An async enumerable stream of activities representing the agent's responses.

Exceptions

ArgumentNullException

Thrown when activityToSend or conversationId is null.

HttpRequestException

Thrown when the HTTP request to Copilot Studio fails.

JsonException

Thrown when the response cannot be deserialized.

Remarks

This method forces the activity's conversation ID to match the provided parameter, overriding any conversation ID that may already be set on the activity.

Applies to