web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / How to Dynamically Sco...
Copilot Studio
Suggested Answer

How to Dynamically Scope Copilot Agent Knowledge to a Specific SharePoint Folder

(2) ShareShare
ReportReport
Posted on by 10

Hi everyone,

I’ve implemented an SPFx web part that captures the clicked element (folder name) on a SharePoint page and passes it to a Copilot agent via query string. The Copilot agent reads this value and stores it as a global variable.

The agent uses a SharePoint document library as its knowledge source, which contains multiple folders and subfolders. My requirement is:

When the SPFx web part sends a folder name, I want the Copilot agent to restrict its knowledge scope to only that folder—so all responses should be based solely on documents within that folder.

I’m looking for a way to implement this with minimal customization. Ideally, I’d like to avoid re-indexing the entire library or creating separate agents per folder.

Has anyone tackled a similar scenario? What’s the best way to dynamically filter the knowledge base in Copilot based on a folder name passed from SPFx?

Thanks in advance!

Categories:
I have the same question (2)
  • Suggested answer
    Romain The Low-Code Bearded Bear Profile Picture
    2,562 Super User 2026 Season 1 on at
    hello
     
    at my knowledge, using instruction to tell "use only this folder" as never worked.
     
    what i do "not dynamically" is that you can have a data source per folder in copilot studio : you can add a sharepoint libary with the folder in the url and it will target the url of the library, instead of full library, use this often to have good agent : not target full lib but use few topics to target folder.
     
    Doing this dynamically i m not sure it's possible :)
     
    hope this help
  • Luca-Bergmann Profile Picture
    8 on at
    Hey there,
     
    i have the exact same requirement and still having trouble to implement it.
    From what i found only the way to go is work with an individual topic and pass the selected folder url dynamicly to "create generative answers" and under classic data you can specify the sharepoint-url to the folder.
    Sadly for me the bot always response with "i cant find any data".
    You had success on this topic?
     
     
     
  • S-Venkadesh Profile Picture
    1,214 Super User 2026 Season 1 on at
     
    I tested this scenario using two folders—Bills and Prescription—within the SharePoint library Copilot Knowledge, and it produced the expected results.
    While adding the knowledge sources, I used the Browse option instead of pasting the URL to ensure better accuracy.
    Knowledge sources configured:
    • Knowledge source 1: SharePoint Library → Copilot Knowledge → Folder → Bills
    • Knowledge source 2: SharePoint Library → Copilot Knowledge → Folder → Prescription
    Instructions added to the agent:
    • If the user asks about bills, use the Bills knowledge source.
    • If the user asks about prescriptions, use the Prescription knowledge source.
    Please refer to the screenshot below for the test results.
     
    Note: For SPFx scenarios, customize the instructions based on your specific use case and application logic.
     
    Steps to add Knowledge Source:
     
     
    Instructions:
     
    Output:
     
     
     I hope this information helps! If it does, please consider giving a 👍.
    If this solved your issue, please mark it as  Verified Answer
    Best regards,
    S-Venkadesh
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Copilot Studio

#1
Valantis Profile Picture

Valantis 594

#2
chiaraalina Profile Picture

chiaraalina 170 Super User 2026 Season 1

#3
deepakmehta13a Profile Picture

deepakmehta13a 118

Last 30 days Overall leaderboard