Reputation: 125
I've created a bot using Bot Framework and I am using the conversationID
to maintain state with my back end conversation engine. I can't find in the documentation for ending the conversation. It's imperative that, at some point, the user be able to signal an "end, or exit" to the conversation so that the next time they start a conversation, it gets a new conversationID
. It should be a simple task, I would think. I'm using the default echo template and just replaced the count the number of letters line with a method to my class, which returns the text to send back to the user.
Upvotes: 4
Views: 2431
Reputation: 8292
There is now an ActivityTypes.EndOfConversation (this is already in the sdk).
Here is one way to use it: v3
public static async Task EndConversation(this IBotToUser botToUser, string code = EndOfConversationCodes.CompletedSuccessfully, CancellationToken cancellationToken = default(CancellationToken))
{
var message = botToUser.MakeMessage();
message.Type = ActivityTypes.EndOfConversation;
message.AsEndOfConversationActivity().Code = code;
await botToUser.PostAsync(message, cancellationToken);
}
This should also be in a future release: GitHub Pull Request
v4
public static async Task EndConversation(this ITurnContext turnContext, string code = EndOfConversationCodes.CompletedSuccessfully, CancellationToken cancellationToken = default(CancellationToken))
{
var endOfConversation = Activity.CreateEndOfConversationActivity();
endOfConversation.Code = code;
await turnContext.SendActivityAsync(endOfConversation, cancellationToken);
}
Upvotes: 5
Reputation: 1812
There is a newer, shorter way1:
context.EndConversation(EndOfConversationCodes.CompletedSuccessfully);
Upvotes: 0
Reputation: 72
A json web tokens(jwt) are available in one chat only. so it gets converstionId again. The session.endConversation() method provides a convenient method for quickly terminating a conversation with a user. is used for end the conversation.
Upvotes: 0