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

2 Replies

    • ouadia's avatar
      ouadia
      Copper Contributor
      Hi Dinesh,

      I've added a few comments here https://stackoverflow.com/questions/78582393/unable-to-invoke-task-module-in-ms-teams-botbuilder-bot/78590539#78590539

      The code you provided does not work. I'm getting 'TaskModuleResponse' object has no attribute 'input_hint'. Is there a reason to send the response using turn_context.send_activity(response) instead of just returning the response like mentioned in this example https://github.com/microsoft/BotBuilder-Samples/blob/ce328b01cc1315d6f36ca0c9aa0d9d1cf5ad11de/archive/samples/python/54.teams-task-module/bots/teams_task_module_bot.py#L83

      Even using this sample https://github.com/microsoft/BotBuilder-Samples/blob/ce328b01cc1315d6f36ca0c9aa0d9d1cf5ad11de/archive/samples/python/54.teams-task-module/bots/teams_task_module_bot.py#L83 the code doesn't work. The code doesn't trigger any error, the MSTeams client the invoke HTTP request is returning a 200 response without any body.

      Please advice,
      Thank you so much,

      Ouadia

Resources