Task Module shows popup but Adaptive Card does not render using M365 Agent SDK (Python)

Akash Agarwal 0 Reputation points
2025-12-11T17:24:14.7233333+00:00

I am using the new M365 Agent SDK for Python to return a Task Module (task/fetch). The popup opens successfully when I click the button in Teams, but the Adaptive Card inside the Task Module does not render. Instead, Teams shows the generic error:

“Unable to reach app. Please try again.”

My invoke handler returns the following structure:

adaptive_card = {
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.4",
    "body": [
        {"type": "TextBlock", "text": "Sample task module card"},
        {"type": "Input.Text", "id": "notes", "isMultiline": True}
    ],
    "actions": [
        {
            "type": "Action.Submit",
            "title": "Submit",
            "data": {"action": "sample_task_submit"}
        }
    ]
}

task_response = {
    "task": {
        "type": "continue",
        "value": {
            "title": "Dialog",
            "width": "medium",
            "height": "medium",
            "card": {
                "contentType": "application/vnd.microsoft.card.adaptive",
                "content": adaptive_card
            }
        }
    }
}

return InvokeResponse(status=200, body=task_response)

Key symptoms:

Task module window opens (so invoke is successful)

Adaptive card does not render

Shows “Unable to reach app” inside popup

No errors in server logs

This happens only with Task Modules; normal message replies work fine

Questions:

Is the above Task Module response format correct for the new M365 Agent SDK for Python?

Does the SDK require a different return type or content-type for invoke responses?

Are Task Modules fully supported in the M365 Agent SDK preview?

Is there an example of returning a Task Module using the Python SDK?

Any clarification or working sample for Python would be very helpful.

SS - User's image


Microsoft Teams | Development
Microsoft Teams | Development
Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Teddie-D 9,045 Reputation points Microsoft External Staff Moderator
    2025-12-12T04:45:28.02+00:00

    Hi @Akash Agarwal 

    Thank you for posting your question in the Microsoft Q&A forum. 

    Since I’m not a Python developer, I don’t want to accidentally give you misleading instructions. For the most accurate guidance, I’d recommend opening a new thread in the Microsoft Community Hub or on GitHub, there are many developers and SDK contributors there who can give you more targeted help. 

    Alternatively, I did some research that may help clarify what’s going on: 

    The structure  task.type="continue" with an Adaptive Card contentType="application/vnd.microsoft.card.adaptive" is the correct format that Teams expects for a Task Module dialog. 

    However, the Agents SDK preview enforces typed models for invoke responses. If your handler returns a plain dictionary, the SDK’s serializer won’t accept it. When that happens, Teams falls back to the generic banner “Unable to reach app. Please try again.” 

    In the newer SDK builds, the expected response chain looks like this: 

    -TaskModuleResponse contains task and cache_info (required). 

    -TaskModuleContinueResponse wraps the TaskInfo value. 

    -CardTaskModuleTaskInfo (or equivalent) holds the Adaptive Card attachment 

    You must wrap the whole thing in an invokeResponse activity whose value is InvokeResponse
    If you want to double‑check the expected behavior, Microsoft’s documentation on Teams dialogs is helpful: Use dialogs in Microsoft Teams bots - Teams | Microsoft Learn

    Task Modules are supported in Teams when using the Python Agents SDK preview. The SDK’s dialog/activity handlers automatically map Teams invoke activities (task/fetch, task/submit) to your bot’s handler. 

    For a working reference implementation, you can look at the official sample: Microsoft-Teams-Samples/samples/bot-task-module/python at main · OfficeDev/Microsoft-Teams-Samples ….  

    I hope this information is helpful. 


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. 


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.