Language

ICopilotClient.SendActivityAsync(IActivity, CancellationToken) Method

Definition

Sends an activity to the remote bot and returns the response as an async enumerable stream of activities.

public System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.Core.Models.IActivity> SendActivityAsync(Microsoft.Agents.Core.Models.IActivity activity, System.Threading.CancellationToken cancellationToken = default);
abstract member SendActivityAsync : Microsoft.Agents.Core.Models.IActivity * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.Core.Models.IActivity>
Public Function SendActivityAsync (activity As IActivity, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of IActivity)

Parameters

activity
IActivity

The activity to send.

cancellationToken
CancellationToken

The cancellation token.

Returns

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

Exceptions

Thrown when activity is null.

Thrown when the HTTP request to Copilot Studio fails.

Thrown when the response cannot be deserialized.

Remarks

This method uses the conversation ID from the activity if present, otherwise it uses the conversation ID from a previous StartConversationAsync call.

Applies to