|
| 1 | + |
| 2 | +# Adaptive Card Dialog (Python) |
| 3 | + |
| 4 | +## Summary |
| 5 | + |
| 6 | +This sample demonstrates how to open dialog boxes from Adaptive Cards in a Microsoft 365 Copilot declarative agent. Users can browse programming tutorials for Node.js, JavaScript, and Git, watch official Microsoft video tutorials embedded in dialog boxes, and take interactive quizzes with instant feedback—all within the Copilot interface. |
| 7 | + |
| 8 | +The sample showcases Action.OpenUrlDialog from Adaptive Cards v1.5, Python Azure Functions backend, and API Plugin integration. |
| 9 | + |
| 10 | +<img src="assets/AdaptiveCardsDialogBox.gif" alt="Adaptive Card Dialog" width="100%" /> |
| 11 | + |
| 12 | + |
| 13 | +## Version history |
| 14 | + |
| 15 | +Version|Date|Author|Comments |
| 16 | +-------|----|----|-------- |
| 17 | +1.0|April 20, 2026|[YugalPradhan31](https://github.com/YugalPradhan31)|Initial release |
| 18 | + |
| 19 | +## Prerequisites |
| 20 | + |
| 21 | +* [Microsoft 365 account with Copilot access](https://www.microsoft.com/microsoft-365/enterprise/copilot-for-microsoft-365) |
| 22 | +* [Python](https://www.python.org/downloads/) version 3.10 or later |
| 23 | +* [Azure Functions Core Tools](https://learn.microsoft.com/azure/azure-functions/functions-run-local) v4 |
| 24 | +* [Visual Studio Code](https://code.visualstudio.com/) |
| 25 | +* [Microsoft 365 Agents Toolkit for VS Code](https://marketplace.visualstudio.com/items?itemName=TeamsDevApp.ms-teams-vscode-extension) |
| 26 | +* [Dev tunnels CLI](https://learn.microsoft.com/azure/developer/dev-tunnels/get-started) for local development |
| 27 | + |
| 28 | +## Minimal Path to Awesome |
| 29 | + |
| 30 | +* Clone this repository (or download this solution as a .ZIP file then unzip it) |
| 31 | + ```bash |
| 32 | + git clone https://github.com/pnp/copilot-pro-dev-samples.git |
| 33 | + cd copilot-pro-dev-samples/samples/da-adaptive-card-dialog-python |
| 34 | + ``` |
| 35 | +* Open the project in Visual Studio Code |
| 36 | +* Select the **Microsoft 365 Agents Toolkit** icon on the left in the VS Code toolbar |
| 37 | +* In the **Account** section, sign in with your Microsoft 365 account if you haven't already |
| 38 | +* Install Python dependencies: |
| 39 | + ```bash |
| 40 | + pip install -r requirements.txt |
| 41 | + ``` |
| 42 | +* Create Teams app by selecting **Provision** in the **Lifecycle** section |
| 43 | +* Select **Preview in Copilot (Edge)** or **Preview in Copilot (Chrome)** from the launch configuration dropdown, or use **Debug in Microsoft 365 Agents Playground** for local testing |
| 44 | +* Once the agent is loaded, you can ask questions like: |
| 45 | + - "Show me programming tutorials" |
| 46 | + - "I want to learn JavaScript" |
| 47 | + - "Git tutorials for beginners" |
| 48 | +* The agent will respond with programming tutorials and you can interact with action buttons: |
| 49 | + - **Watch Video** - Opens YouTube embed in a large dialog |
| 50 | + - **Interactive Quiz** - Opens custom HTML quiz with instant feedback |
| 51 | +
|
| 52 | +## Features |
| 53 | +
|
| 54 | +This sample illustrates the following concepts for Microsoft 365 Copilot declarative agents: |
| 55 | +
|
| 56 | +* **Action.OpenUrlDialog** - Opens URLs in modal dialogs within Microsoft 365 Copilot without leaving the chat interface |
| 57 | +
|
| 58 | +### What is Action.OpenUrlDialog? |
| 59 | +
|
| 60 | +`Action.OpenUrlDialog` is a new Adaptive Card action (v1.5+) that opens a URL in a modal dialog within Microsoft 365 Copilot, providing an integrated experience without leaving the chat interface. |
| 61 | +
|
| 62 | +**Key Characteristics:** |
| 63 | +- Opens URLs in modal dialogs within Copilot |
| 64 | +- Supports custom dialog sizes (width/height in px or predefined: small, medium, large) |
| 65 | +- Requires URLs to be whitelisted in `validDomains` in manifest.json |
| 66 | +- Works with YouTube embeds, custom HTML pages, and other web content |
| 67 | +
|
| 68 | +### Interaction Flow |
| 69 | +
|
| 70 | +**Step 1: Ask for tutorials** |
| 71 | +``` |
| 72 | +User: "Show me programming tutorials" |
| 73 | +``` |
| 74 | +
|
| 75 | +**Step 2: Browse learning resources** |
| 76 | +The agent returns adaptive cards showing: |
| 77 | +- Topic name (Node.js, JavaScript, Git) |
| 78 | +- Difficulty level and duration |
| 79 | +- Description |
| 80 | +- Two action buttons |
| 81 | +
|
| 82 | +**Step 3: Watch Video** |
| 83 | +Click "Watch Video" button: |
| 84 | +- Opens YouTube embed in a large dialog |
| 85 | +- Shows official Microsoft tutorial videos |
| 86 | +- Supports fullscreen playback |
| 87 | +
|
| 88 | +**Step 4: Take Interactive Quiz** |
| 89 | +Click "Interactive Quiz" button: |
| 90 | +- Opens custom HTML quiz in dialog (700px height) |
| 91 | +- 3 questions with multiple choice options |
| 92 | +- Instant feedback with explanations |
| 93 | +- Progress bar showing completion |
| 94 | +- Final score and key takeaways |
| 95 | +- Option to retake quiz |
| 96 | +
|
| 97 | +
|
| 98 | +## Help |
| 99 | +
|
| 100 | +We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues. |
| 101 | +
|
| 102 | +You can try looking at [issues related to this sample](https://github.com/pnp/copilot-pro-dev-samples/issues?q=label%3A%22sample%3A%20da-adaptive-card-dialog-python%22) to see if anybody else is having the same issues. |
| 103 | +
|
| 104 | +If you encounter any issues using this sample, [create a new issue](https://github.com/pnp/copilot-pro-dev-samples/issues/new). |
| 105 | +
|
| 106 | +Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/copilot-pro-dev-samples/issues/new). |
| 107 | +
|
| 108 | +
|
| 109 | +## Disclaimer |
| 110 | +
|
| 111 | +**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.** |
| 112 | +
|
| 113 | +
|
| 114 | +## Further reading |
| 115 | +
|
| 116 | +- [Action.OpenUrlDialog Documentation](https://learn.microsoft.com/en-us/microsoft-365-copilot/extensibility/adaptive-card-dialog-box) |
| 117 | +- [Build declarative agents for Microsoft 365 Copilot](https://learn.microsoft.com/microsoft-365-copilot/extensibility/overview-declarative-agent) |
| 118 | +- [Adaptive Cards Schema Explorer](https://adaptivecards.io/explorer/) |
| 119 | +- [API Plugins for Microsoft 365 Copilot](https://learn.microsoft.com/microsoft-365-copilot/extensibility/overview-api-plugins) |
| 120 | +
|
| 121 | +<img src="https://m365-visitor-stats.azurewebsites.net/copilot-pro-dev-samples/samples/da-adaptive-card-dialog-python" /> |
| 122 | +
|
| 123 | +--- |
0 commit comments