Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Use the Microsoft Graph API as a Copilot plugin for a declarative agent

Summary

This sample demonstrates how to use the Microsoft Graph API as a Copilot plugin in a declarative agent. The agent only retrieves data from QnAs content defined in Microsoft Search using the /search/query endpoint of the Microsoft Graph API so users can ask questions based on it.

The following blog post describes the complete solution setup: https://blog.franckcornu.com/post/copilot-graph-api-qna-plugin/

"Graph API QnA Plugin - Data "

"Graph API QnA Plugin - Confirm with request"

"Graph API QnA Plugin - Output"

Contributors

Version history

Version Date Comments
1.0 January 16, 2025 Initial solution

Prerequisites

Minimal path to awesome

  • Clone this repository (or download this solution as a .ZIP file then unzip it)

  • Import QnA samples using the sample_qnas.csv file into your Microsoft Search admin center (or use your own):

    "QnAs import

  • Open the mssearchplugin-openapi.yml file, look for the securitySchemes property and replace tenantid by your own ID:

    securitySchemes:
        azureaadv2:
        type: oauth2
        flows:
            authorizationCode:
            authorizationUrl: https://login.microsoftonline.com/tenantid/oauth2/v2.0/authorize
            tokenUrl: https://login.microsoftonline.com/tenantid/oauth2/v2.0/token
            scopes: 
                QnA.Read.All: Read QnAs from Microsoft Search
  • Register an Entra ID application in Azure and add the API permissions QnA.Read.All (delegated). Add the https://teams.microsoft.com/api/platform/v1.0/oAuthRedirect as a redirect URL for web platform in the Authentication settings.

  1. In the Teams developer portal, add a new OAuth client registration and register a new client with the following information (replace tenantid by your own value):

    App settings

    • Registration name: MicrosoftSearch
    • 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

    Save the information. A new OAuth registration key will be generated.

  2. 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.dev file:

    "auth": {
        "type": "OAuthPluginVault",
        "reference_id": "ZTRhNDM5YjQtM2..."
    },
  3. From Teams Toolkit, sign-in to your Microsoft 365 account.

  4. From Teams Toolkit, provision the solution to create the Teams app.

  5. Go to https://www.office.com/chat?auth=2 URL and enable the developer mode by using the -developer on prompt.

  6. Ask a question like "Is Microsoft Search in Bing secure?". You should see the plugin triggered.

Features

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.

Help

Search for: da-qna-graphapi-plugin

Search for: @FranckyC

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.

Disclaimer

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.