async def on_teams_task_module_fetch( self, turn_context: TurnContext, task_module_request: TaskModuleRequest ) -> TaskModuleResponse: await turn_context.send_activity( MessageFactory.text( f"on_teams_task_module_fetch:{json.dumps(task_module_request.data)}" ) ) card = CardFactory.adaptive_card( { "version": "1.0.0", "type": "AdaptiveCard", "body": [ {"type": "TextBlock", "text": "Enter Text Here",}, { "type": "Input.Text", "id": "usertext", "placeholder": "add some text and submit", "IsMultiline": "true", }, ], "actions": [{"type": "Action.Submit", "title": "Submit",}], } ) task_info = TaskModuleTaskInfo( card=card, title="Adaptive Card: Inputs", height=200, width=400 ) continue_response = TaskModuleContinueResponse(type="continue", value=task_info) return TaskModuleResponse(task=continue_response)
async def on_teams_messaging_extension_fetch_task( self, turn_context: TurnContext, action: MessagingExtensionAction ) -> MessagingExtensionActionResponse: card = create_adaptive_card_editor() task_info = TaskModuleTaskInfo( card=card, height=450, title="Task Module Fetch Example", width=500 ) continue_response = TaskModuleContinueResponse(type="continue", value=task_info) return MessagingExtensionActionResponse(task=continue_response)
async def on_teams_messaging_extension_bot_message_preview_edit( # pylint: disable=unused-argument self, turn_context: TurnContext, action: MessagingExtensionAction ) -> MessagingExtensionActionResponse: activity_preview = action.bot_activity_preview[0] content = activity_preview.attachments[0].content data = self._get_example_data(content) card = create_adaptive_card_editor( data.question, data.is_multi_select, data.option1, data.option2, data.option3, ) task_info = TaskModuleTaskInfo( card=card, height=450, title="Task Module Fetch Example", width=500 ) continue_response = TaskModuleContinueResponse(type="continue", value=task_info) return MessagingExtensionActionResponse(task=continue_response)
async def on_teams_messaging_extension_fetch_task( self, turn_context: TurnContext, action: MessagingExtensionAction, ) -> MessagingExtensionActionResponse: if action.command_id == "SignOutCommand": await turn_context.adapter.sign_out_user( turn_context, self.connection_name, turn_context.activity.from_property.id, ) card = CardFactory.adaptive_card({ "actions": [{ "type": "Action.Submit", "title": "Close", }], "body": [ { "text": "You have been signed out.", "type": "TextBlock", "weight": "bolder", }, ], "type": "AdaptiveCard", "version": "1.0", }) task_info = TaskModuleTaskInfo(card=card, height=200, title="Adaptive Card Example", width=400) continue_response = TaskModuleContinueResponse(type="continue", value=task_info) return MessagingExtensionActionResponse(task=continue_response) return None
def create_response( value: Union[str, TaskModuleTaskInfo]) -> TaskModuleResponse: if isinstance(value, TaskModuleTaskInfo): return TaskModuleResponse(task=TaskModuleContinueResponse( value=value)) return TaskModuleResponse(task=TaskModuleMessageResponse(value=value))