Declarative Agent

Trey Research Python Auth

This sample demonstrates how to create a Python-based agent that interacts with a protected consulting API to provide information about consultants and projects.

Demonstration of Trey Research Auth Python sample
Sample type
Declarative Agent
Last updated
Contributors
1
License
MIT

About this sample

This sample demonstrates how to create a Python-based agent that interacts with a protected consulting API to provide information about consultants and projects. The agent can answer questions about consultants and their projects

Setup and usage

Sample documentation

Summary

Trey Research is a fictitious consulting company that supplies talent in the software and pharmaceuticals industries.

The solution consists of an API plugin that calls a set of Azure Functions (Python), which store the consulting data in Azure Table Storage (it uses the Azurite storage emulator when running locally).

A declarative agent is provided to converse with users and to call the API plugin, as well as to reference the correct SharePoint document library.

Trey Research

Features

The sample showcases the following features:

  1. Declarative agent with branding and instructions, with access to relevant documents and an API
  2. API based plugin works with any platform that supports REST requests
  3. Copilot will construct queries for specific data using GET requests
  4. Copilot updates and adds data using POST requests
  5. Multi-parameter queries to filter results
  6. Show a confirmation card before POSTing data; capture missing parameters
  7. Display rich adaptive cards
  8. Authenticate the user using Entra ID and OAuth 2.0
  9. Token validation in Python using PyJWT (without Easy Auth)

Contributors

Version history

Version Date Comments
1.0 May 15, 2026 Initial release

Prerequisites

drop

Minimal path to awesome

1. Setup document repository

For this sample, we will use OneDrive to store the documents that the agent will reference.

![NOTE] You can also use SharePoint document libraries, the URL will be slightly different, but the process is the same.

  1. Go to OneDrive
  2. Go to My files
  3. Create a new folder called Legal
  4. Upload documents from the sampleDocs folder in this repository to the Legal folder
  5. Navigate to the Legal folder
  6. Expand the Details tab on the right
  7. Expand the More details tab
  8. Copy the Path to the Legal folder using the Copy button

2. Test the agent

  1. In the .env folder, create a new file called .env.local.

  2. Add the following line to the .env.local file:

    DOCUMENTS_URL=<paste the path you copied from OneDrive>
    

    For example, if you copied the path https://contoso-my.sharepoint.com/personal/user_contoso_com/Documents/Legal, it should look like this:

    DOCUMENTS_URL=https://contoso-my.sharepoint.com/personal/user_contoso_com/Documents/Legal
    
  3. Install Python dependencies:

    pip install -r requirements.txt
    
  4. Press F5 to start a debug session. If prompted, sign in with your Microsoft 365 account. Wait for the provisioning to complete and the browser to open.

  5. In the browser, if prompted, sign in with your Microsoft 365 account. The browser will open the declarative agent in Microsoft 365 Copilot after signing in.

![IMPORTANT] Microsoft 365 Copilot can cache the agent definition, so if you make changes to the agent, you may need to clear the browser cache for changes to be persisted. After the agent is loaded, use Hard Refresh (Ctrl+Shift+R) to ensure the latest version is loaded.

Try the following prompts:

  • do we have any consultants with azure certifications?
  • what projects are we doing for relecloud?
  • which consultants are working with woodgrove bank?
  • how many hours has avery delivered this month?
  • please find a consultant with python skills who is available immediately
  • are any consultants available who are AWS certified?
  • does trey research have any architects with javascript skills?
  • what designers are working at woodgrove bank?
  • please charge 10 hours to woodgrove bank
  • please add sanjay to the contoso project
  • find my hours spreadsheet and get the hours for woodgrove, then bill the client
  • make a list of my projects, then write a summary of each based on the statement of work.

Troubleshooting and feature requests

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.