From 77a1069e032a92f64c8d2b67e9811d71462cbd18 Mon Sep 17 00:00:00 2001 From: Axel Suarez Date: Mon, 5 Aug 2019 10:51:59 -0700 Subject: [PATCH] Adding confirm prompt to Core Bot and fix on that sample error handling --- samples/Core-Bot/adapter_with_error_handler.py | 3 ++- samples/Core-Bot/dialogs/booking_dialog.py | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/Core-Bot/adapter_with_error_handler.py b/samples/Core-Bot/adapter_with_error_handler.py index c5180d41f..10aaa238f 100644 --- a/samples/Core-Bot/adapter_with_error_handler.py +++ b/samples/Core-Bot/adapter_with_error_handler.py @@ -21,7 +21,7 @@ def __init__( self._conversation_state = conversation_state # Catch-all for errors. - async def on_error(self, context: TurnContext, error: Exception): + async def on_error(context: TurnContext, error: Exception): # This check writes out errors to console log # NOTE: In production environment, you should consider logging this to Azure # application insights. @@ -34,6 +34,7 @@ async def on_error(self, context: TurnContext, error: Exception): ) await context.send_activity(error_message) # Clear out state + nonlocal self await self._conversation_state.delete(context) self.on_turn_error = on_error diff --git a/samples/Core-Bot/dialogs/booking_dialog.py b/samples/Core-Bot/dialogs/booking_dialog.py index e941703f1..297dff07c 100644 --- a/samples/Core-Bot/dialogs/booking_dialog.py +++ b/samples/Core-Bot/dialogs/booking_dialog.py @@ -16,7 +16,7 @@ def __init__(self, dialog_id: str = None): super(BookingDialog, self).__init__(dialog_id or BookingDialog.__name__) self.add_dialog(TextPrompt(TextPrompt.__name__)) - # self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__)) + self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__)) self.add_dialog(DateResolverDialog(DateResolverDialog.__name__)) self.add_dialog( WaterfallDialog( @@ -25,7 +25,7 @@ def __init__(self, dialog_id: str = None): self.destination_step, self.origin_step, self.travel_date_step, - # self.confirm_step, + self.confirm_step, self.final_step, ], ) @@ -133,7 +133,6 @@ async def final_step(self, step_context: WaterfallStepContext) -> DialogTurnResu if step_context.result: booking_details = step_context.options - booking_details.travel_date = step_context.result return await step_context.end_dialog(booking_details) return await step_context.end_dialog()