IChannelApiHandler.OnCreateConversationAsync Method

Definition

CreateConversation() API.

public System.Threading.Tasks.Task<Microsoft.Agents.Connector.Types.ConversationResourceResponse> OnCreateConversationAsync(System.Security.Claims.ClaimsIdentity claimsIdentity, Microsoft.Agents.Core.Models.ConversationParameters parameters, System.Threading.CancellationToken cancellationToken = default);
abstract member OnCreateConversationAsync : System.Security.Claims.ClaimsIdentity * Microsoft.Agents.Core.Models.ConversationParameters * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Agents.Connector.Types.ConversationResourceResponse>
Public Function OnCreateConversationAsync (claimsIdentity As ClaimsIdentity, parameters As ConversationParameters, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ConversationResourceResponse)

Parameters

claimsIdentity
ClaimsIdentity

claimsIdentity for the Agent, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.

parameters
ConversationParameters

Parameters to create the conversation from.

cancellationToken
CancellationToken

The cancellation token.

Returns

task for a conversation resource response.

Remarks

POST to this method with a * Agent being the Agent creating the conversation * IsGroup set to true if this is not a direct message (default is false) * Array containing the members to include in the conversation

The return value is a ResourceResponse which contains a conversation ID which is suitable for use in the message payload and REST API URIs.

Most channels only support the semantics of Agents initiating a direct message conversation. An example of how to do that would be:

var resource = await connector.conversations.CreateConversation(new ConversationParameters(){ Agent = "agent", members = new ChannelAccount[] { new ChannelAccount("user1") } ); await connect.Conversations.OnSendToConversationAsync(resource.Id, new Activity() ... ) ;

end.

Applies to