Hi,
I created a chatbot by Bot Framework and I implemented a Reset option in order to delete the conversation e grant to the user to begin a new conversation.
- // MessageController.cs
- public async Task Post([FromBody]Activity activity)
- {
- await Conversation.SendAsync(activity, () => new RootDialog().DefaultIfException());
- return Request.CreateResponse(HttpStatusCode.OK); <- Stack is empty Exception
- }
- // RootDialog.cs
- private void ShowMenuOptions(IDialogContext context)
- {
- List<string> optionList = new List<string>();
- optionList.Add("Info");
- optionList.Add("Support");
- optionList.Add("Reset");
-
- string prompt ="How can I help you?";
-
- PromptDialog.Choice(context, this.OnOptionSelected, (IEnumerable<string>)optionList, prompt, retry, attempts);
- }
-
- private async Task OnOptionSelected(IDialogContext context, IAwaitable<string> result)
- {
- try
- {
- string optionSelected = await result;
-
- switch (optionSelected)
- {
- case "Reset":
- context.Reset();
- context.ConversationData.Clear();
- context.PrivateConversationData.Clear();
- context.UserData.Clear();
- break;
- }
- }
- }
When an user chooses reset option, the bot answers with "Sorry, my bot code is having an issue."
Debugging the code I see that the exception triggers after context.Reset().
Can anybody help me and solve it?