ChannelServiceHandler.OnCreateConversationAsync(ClaimsIdentity, ConversationParameters, CancellationToken) Method

Definition

CreateConversation() API.

protected virtual System.Threading.Tasks.Task<Microsoft.Bot.Schema.ConversationResourceResponse> OnCreateConversationAsync (System.Security.Claims.ClaimsIdentity claimsIdentity, Microsoft.Bot.Schema.ConversationParameters parameters, System.Threading.CancellationToken cancellationToken = default);
abstract member OnCreateConversationAsync : System.Security.Claims.ClaimsIdentity * Microsoft.Bot.Schema.ConversationParameters * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Bot.Schema.ConversationResourceResponse>
override this.OnCreateConversationAsync : System.Security.Claims.ClaimsIdentity * Microsoft.Bot.Schema.ConversationParameters * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Bot.Schema.ConversationResourceResponse>
Protected Overridable Function OnCreateConversationAsync (claimsIdentity As ClaimsIdentity, parameters As ConversationParameters, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ConversationResourceResponse)

Parameters

claimsIdentity
ClaimsIdentity

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

parameters
ConversationParameters

Parameters to create the conversation from.

cancellationToken
CancellationToken

The cancellation token.

Returns

Task<ConversationResourceResponse>

task for a conversation resource response.

Remarks

Override this method to create a new Conversation.

POST to this method with a

  • Bot being the bot 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 bots initiating a direct

message conversation. An example of how to do that would be:

var resource = await connector.conversations.CreateConversation(new

ConversationParameters(){ Bot = bot, members = new ChannelAccount[] { new

ChannelAccount("user1") } );

await connect.Conversations.OnSendToConversationAsync(resource.Id, new

Activity() ... ) ;

end.

Applies to