예제 #1
0
    async def show_card_step(self, step_context: WaterfallStepContext):
        response = step_context.result.lower().strip()
        choice_dict = {
            '1': [self.create_adaptive_card],
            'adaptive card': [self.create_adaptive_card],
            '2': [self.create_animation_card],
            'animation card': [self.create_animation_card],
            '3': [self.create_audio_card],
            'audio card': [self.create_audio_card],
            '4': [self.create_hero_card],
            'hero card': [self.create_hero_card],
            '5': [self.create_receipt_card],
            'receipt card': [self.create_receipt_card],
            '6': [self.create_signin_card],
            'signin card': [self.create_signin_card],
            '7': [self.create_thumbnail_card],
            'thumbnail card': [self.create_thumbnail_card],
            '8': [self.create_video_card],
            'video card': [self.create_video_card],
            '9': [
                self.create_adaptive_card, self.create_animation_card,
                self.create_audio_card, self.create_hero_card,
                self.create_receipt_card, self.create_signin_card,
                self.create_thumbnail_card, self.create_video_card
            ],
            'all cards': [
                self.create_adaptive_card, self.create_animation_card,
                self.create_audio_card, self.create_hero_card,
                self.create_receipt_card, self.create_signin_card,
                self.create_thumbnail_card, self.create_video_card
            ]
        }

        # Get the functions that will generate the card(s) for our response
        # If the stripped response from the user is not found in our choice_dict, default to None
        choice = choice_dict.get(response, None)
        # If the user's choice was not found, respond saying the bot didn't understand the user's response.
        if not choice:
            not_found = create_activity_reply(
                step_context.context.activity,
                'Sorry, I didn\'t understand that. :(')
            await step_context.context.send_activity(not_found)
        else:
            for func in choice:
                card = func()
                response = create_activity_reply(step_context.context.activity,
                                                 '', '', [card])
                await step_context.context.send_activity(response)

        # Give the user instructions about what to do next
        await step_context.context.send_activity(
            'Type anything to see another card.')

        return await step_context.end_dialog()
예제 #2
0
    async def options_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        if not step_context.options:
            self.current_order = DialogHelper.init_dialog()

        card = self.current_order.generate_list_items_card()

        response = activity_helper.create_activity_reply(
            step_context.context.activity, "", "", [card])

        return await step_context.prompt(TextPrompt.__name__,
                                         PromptOptions(prompt=response))
 def create_response(self, activity: Activity, attachment: Attachment):
     response = create_activity_reply(activity)
     response.Attachments = [attachment]
     return response
 def create_response(self, activity: Activity, attachment: Attachment):
     """Create an attachment message response."""
     response = create_activity_reply(activity)
     response.attachments = [attachment]
     return response
예제 #5
0
    async def show_card_step(self, step_context: WaterfallStepContext):
        """
        Send a Rich Card response to the user based on their choice.
        self method is only called when a valid prompt response is parsed from the user's
        response to the ChoicePrompt.
        """
        response = step_context.result.lower().strip()
        choice_dict = {
            "1": [self.create_adaptive_card],
            "adaptive card": [self.create_adaptive_card],
            "2": [self.create_animation_card],
            "animation card": [self.create_animation_card],
            "3": [self.create_audio_card],
            "audio card": [self.create_audio_card],
            "4": [self.create_hero_card],
            "hero card": [self.create_hero_card],
            "5": [self.create_receipt_card],
            "receipt card": [self.create_receipt_card],
            "6": [self.create_signin_card],
            "signin card": [self.create_signin_card],
            "7": [self.create_thumbnail_card],
            "thumbnail card": [self.create_thumbnail_card],
            "8": [self.create_video_card],
            "video card": [self.create_video_card],
            "9": [
                self.create_adaptive_card,
                self.create_animation_card,
                self.create_audio_card,
                self.create_hero_card,
                self.create_receipt_card,
                self.create_signin_card,
                self.create_thumbnail_card,
                self.create_video_card,
            ],
            "all cards": [
                self.create_adaptive_card,
                self.create_animation_card,
                self.create_audio_card,
                self.create_hero_card,
                self.create_receipt_card,
                self.create_signin_card,
                self.create_thumbnail_card,
                self.create_video_card,
            ],
        }

        # Get the functions that will generate the card(s) for our response
        # If the stripped response from the user is not found in our choice_dict, default to None
        choice = choice_dict.get(response, None)
        # If the user's choice was not found, respond saying the bot didn't understand the user's response.
        if not choice:
            not_found = create_activity_reply(
                step_context.context.activity, "Sorry, I didn't understand that. :("
            )
            await step_context.context.send_activity(not_found)
        else:
            for func in choice:
                card = func()
                response = create_activity_reply(
                    step_context.context.activity, "", "", [card]
                )
                await step_context.context.send_activity(response)

        # Give the user instructions about what to do next
        await step_context.context.send_activity("Type anything to see another card.")

        return await step_context.end_dialog()
 def create_response(activity: Activity, attachment: Attachment, text: str):
     """Create an attachment message response."""
     response = create_activity_reply(activity, text)
     response.attachments = [attachment]
     return response