Language

ConversationClient.SendActivityAsync Method

Definition

Sends the specified activity to the conversation endpoint asynchronously using explicit routing. Use this overload when the activity does not carry its own ServiceUrl/Conversation (for example content built with a content-only builder).

public virtual System.Threading.Tasks.Task<Microsoft.Teams.Core.SendActivityResponse?> SendActivityAsync(string conversationId, Microsoft.Teams.Core.Schema.CoreActivityInput activity, Uri serviceUrl, bool isTargeted = false, Microsoft.Teams.Core.Http.BotRequestContext? requestContext = default, System.Collections.Generic.Dictionary<string,string>? customHeaders = default, System.Threading.CancellationToken cancellationToken = default);
abstract member SendActivityAsync : string * Microsoft.Teams.Core.Schema.CoreActivityInput * Uri * bool * Microsoft.Teams.Core.Http.BotRequestContext * System.Collections.Generic.Dictionary<string, string> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Teams.Core.SendActivityResponse>
override this.SendActivityAsync : string * Microsoft.Teams.Core.Schema.CoreActivityInput * Uri * bool * Microsoft.Teams.Core.Http.BotRequestContext * System.Collections.Generic.Dictionary<string, string> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Teams.Core.SendActivityResponse>
Public Overridable Function SendActivityAsync (conversationId As String, activity As CoreActivityInput, serviceUrl As Uri, Optional isTargeted As Boolean = false, Optional requestContext As BotRequestContext = Nothing, Optional customHeaders As Dictionary(Of String, String) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of SendActivityResponse)

Parameters

conversationId
String

The ID of the conversation. Cannot be null or whitespace.

activity
CoreActivityInput

The activity to send. Cannot be null.

serviceUrl
Uri

The service URL for the conversation. Cannot be null.

isTargeted
Boolean

When true, the activity is sent as a targeted (personal) message.

requestContext
BotRequestContext

Optional per-request properties (see BotRequestContext) used as a fallback; values derived from the activity take precedence.

customHeaders
Dictionary<String,String>

Optional custom headers to include in the request.

cancellationToken
CancellationToken

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

Returns

A task that represents the asynchronous operation. The task result contains the response with the ID of the sent activity.

Applies to