How do I end the conversation?
I have created a bot using Bot Framework and I am using conversationID
to maintain state using my feedback mechanism. I cannot find in the documentation to end the conversation. It is necessary that at some point the user can signal "end or exit" for a conversation so that the next time they start a conversation he gets a new one conversationID
. I think it should be a simple task. I'm using the default echo pattern and just replaced the number of lines of letters with a method with my class that returns the text to send back to the user.
source to share
Now there is ActivityTypes.EndOfConversation (this is already in the sdk).
Here's one way to use it:
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 the next release: GitHub Pull Request
source to share