12

so right now I'm using Microsoft.Bot.Builder.Dialogs.Conversation.SendAsync and Microsoft.Bot.Builder.Dialogs.Conversation.ResumeAsync to implement a way to pause and resume conversation but it seems impossible to 'exit' or go back to the previous state. It's stuck in the conversation dialog.

Do I just implement a 'Cancel' command? If so, what data do I need to clear so that it will be back to the original state?

 public static readonly IDialog<string> dialog = Chain .PostToChain() .Switch( new Case<Message, IDialog<string>>((msg) => { var regex = new Regex("login", RegexOptions.IgnoreCase); return regex.IsMatch(msg.Text); }, (ctx, msg) => { return Chain.ContinueWith(new ChatDialog(msg), async (context, res) => { var token = await res; //var valid = await Helpers.ValidateAccessToken(token); //var name = await Helpers.GetProfileName(token); var name = "User"; context.UserData.SetValue("name", name); return Chain.Return($"You are logged in as: {name}"); }); }) ).Unwrap().PostToUser(); 

so if I send a 'login' it will go and start a new ChatDialog conversation but it seems to get stuck in this state. Even if I try to send another command, it will keep asking for login. Do I implement another Case class to handle a 'Cancel' command? Or should it automatically cancel the conversation when the user sends the same 'login' command more than once? Seems kinda clunky to have to send a 'cancel' command separately.

1
  • Just wondering, have you found a solution after all? I'm having the same issue. Commented Aug 24, 2016 at 2:38

2 Answers 2

3

I think you are missing the DefaultCase. Check this. It shows the implementation of the DefaultCase for the Facebook Auth Sample. BTW, in that sample they also have a Logout command.

Sign up to request clarification or add additional context in comments.

Comments

0

I would consider how your users will interpret the end of the conversation, and think about those scenarios and how people end conversations.

You can add code to handle resetting or the end of a conversation based on specific keywords, and by using the GlobalMessageHandler pattern.

https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/core-GlobalMessageHandlers

Also, expect users to just "hang up" / close the window once they are done.

A good set of metrics can help collect information on how people are using the bot for the owners to improve it. i.e: Did interaction X lead on to expected interaction Y, or what was the last interaction we saw for this conversation... etc.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.