Forum Discussion

ouadia's avatar
ouadia
Copper Contributor
Jun 06, 2024

Unable to invoke Task module in MS Teams botbuilder bot

Hi there,

 

We are facing an issue while trying to invoke a task module in Microsoft Teams. We have create an adaptive card with a button that submit a task/fetch action.

 

"actions": [{
    "type": "Action.Submit",
    "title": "Test Fetch",
    "data": {
        "msteams": {
            "type": "task/fetch"
        },
        "data": "toto"
    }
}]

 

When we click the button , the method on_teams_task_module_fetch() is triggered. A TaskModuleTasInfo is returned, but the popup is showing an error.

 

class TaskModuleResponseFactory:
    @staticmethod
    def create_response(value: Union[str, TaskModuleTaskInfo]) -> TaskModuleResponse:
        if isinstance(value, TaskModuleTaskInfo):
            return TaskModuleResponse(task=TaskModuleContinueResponse(value=value))
        return TaskModuleResponse(task=TaskModuleMessageResponse(value=value))

    @staticmethod
    def to_task_module_response(task_info: TaskModuleTaskInfo):
        return TaskModuleResponseFactory.create_response(task_info)

async def on_teams_task_module_fetch(self, turn_context: TurnContext, task_module_request: TaskModuleRequest):
    task_info = TaskModuleTaskInfo(
        width=900,
        height=900,
        title="Super Title",
        url="https://app.random-coffee.com",
        fallback_url="https://app.random-coffee.com",
    )
    return TaskModuleResponseFactory.to_task_module_response(task_info)

 

Could anyone provide insights on how to troubleshoot and fix this issue? Is there something I'm missing in the setup or response handling?

 

Thank you in advance for your assistance!

Ouad

Resources