This sample demonstrates how to use the Microsoft Graph API as a Copilot plugin in a declarative agent with some variation from the blog post https://blog.franckcornu.com/post/copilot-graph-api-qna-plugin/ focusing this time how to list and create my To-Do tasks since the QnA feature has retired since March 2025.
The following blog post describes the complete solution setup:Building a Copilot Agent with Teams Toolkit and Microsoft Graph Plugin to list my ToDo Tasks
- Reshmee Auckloo - M365 Development MVP
| Version | Date | Comments |
|---|---|---|
| 1.0 | April 18, 2025 | Initial solution |
| 2.0 | May 18, 2025 | Added action to create my To-Do task |
Prerequisites
To run this app template in your local dev machine, you will need:
- Node.js, supported versions: 18, 20, 22
- A Microsoft 365 account for development.
- Teams Toolkit Visual Studio Code Extension version 5.0.0 and higher or Teams Toolkit CLI
- Microsoft 365 Copilot license
-
Clone this repository (or download this solution as a .ZIP file then unzip it)
-
Register an Entra ID application in Azure and add the API permissions
Tasks.ReadWrite,User.Read,Directory.Read.All(delegated). Add thehttps://teams.microsoft.com/api/platform/v1.0/oAuthRedirectas a redirect URL for web platform in the Authentication settings.
-
In the Teams developer portal, add a new OAuth client registration and register a new client with the following information (replace
tenantidby your own value):App settings
- Registration name: ToDo
- Base URL:
https://graph.microsoft.com/beta(QnA are only usable through the beta endpoint) - Restrict usage by org: My organization only
- Restrict usage by app: Any Teams app (when agent is deployed, use the Teams app ID).
OAuth settings
- Client ID: <the entra ID application ID>
- Client secret: <the Entra ID application secret>
- Authorization endpoint: https://login.microsoftonline.com/tenantid/oauth2/v2.0/authorize
- Token endpoint: https://login.microsoftonline.com/tenantid/oauth2/v2.0/token
- Refresh endpoint: https://login.microsoftonline.com/tenantid/oauth2/v2.0/refresh
- Scope: Tasks.ReadWrite,User.Read,Directory.Read.All
Save the information. A new OAuth registration key will be generated.
-
Open the ai-plugin.json file and replace the auth property by the following, using the key from the previous step. You can also use the
${{OAUTH2_REGISTRATIONKEY}}token defined the.env.devfile:
"auth": {
"type": "OAuthPluginVault",
"reference_id": "ZTRhNDM5YjQtM2..."
},- From Teams Toolkit, sign-in to your Microsoft 365 account.
- From Teams Toolkit, provision the solution to create the Teams app.
- Go to https://www.office.com/chat?auth=2 URL and enable the developer mode by using the
-developer onprompt. - Ask a question like "List My Tasks". You should see the plugin triggered.
The following sample demonstrates the following concepts:
- Use Microsoft Graph API as an API plugin by using specific endpoint and instructions.
- Query the QnA content from Microsoft Search and use it for Copilot answers.
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.
You can try looking at issues related to this sample to see if anybody else is having the same issues.
If you encounter any issues using this sample, create a new issue.
Finally, if you have an idea for improvement, make a suggestion.
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.

