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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Dynamically assign a d...
Copilot Studio
Answered

Dynamically assign a document as a knowledge source

(2) ShareShare
ReportReport
Posted on by 33
Hi, 
 
Relatively new to Copilot Studio however getting stuck on a scenario and looking for advice.
 
We have a number of documents stored in SharePoint - for argument sake say 10.  We need to create a row in an Excel spreadsheet for each of those documents. The content in the row needs to be based on a generative answer similar to the below table.
 
Filename Summary 1 Summary 2
Filename1 GenAnswer GenAnswer
Filename2 GenAnswer GenAnswer
 
What we have tried is to get a list of all the files and cycle through each record. For each record we then have a "Create generative answers" action.
 
The problem we are facing is to get the topic to only use the current file as a knowledge source. We don't want the answer to use any of the other files for reference. The knowledge source section doesn't seem to allow for programmatically setting the source.
 
Any ideas?
I have the same question (0)
  • Suggested answer
    Arild Aarnes Profile Picture
    363 on at
    Hi,

    I think I would look into doing this in a Agent Flow. There you could use a prompt and use each document as an input when you cycle through them.
    You can call the agent flow from a Topic if that's where you are doing this.
    Maybe you could use a Prompt tool directly in the Topic as well, without going through a Agent Flow
     
     
    Regards
    Arild
  • Suggested answer
    LukeB Profile Picture
    33 on at
    Hi Arild,
     
    The problem, as far as I can see, with using an agent flow would be that, while easier to cycle through documents I can't see a way to get the flow to create a generative answer only from the document. There seems to be issues passing a file from Copilot Studio to Flow (even though they both have file as an output/input) and then if you call an agent within a flow you seem to only get the conversation ID back.
     
    I need to look at prompts in AI Builder in more detail. It looks like it might be an option that would work. Not 100% sure what the cost involved is.
     
    I did however come across a setting on the Create Generative Answers that theoretically allows you to change the data source dynamically using a formula. So far I have been unable to determine the correct formula to use (it is looking for a table) however have opened a ticket with Microsoft to see if I can get further details.
     
  • Suggested answer
    Romain The Low-Code Bearded Bear Profile Picture
    2,124 Super User 2025 Season 2 on at
    hello :) Copilot Studio is not design to have "dynamics adding knowledge" , there is no option to passe the file as a KB.
     
    The only way wich i will not recommand is : take the content, send it in the prompt of a gen answer node. BUT this have a size limit, so it's not a real life solution.
     
    Real solution 
     
    Create a power automate or agent flow (depend on how you will use licences)
     
    - loop on you r document
    - for each document call the folowing action
    - AI Builder prompt (call prompt inside of copilot studio) -> inside choose input variable "document" and ask for you answer.
    - the action have a system output for prompt answer in string : take it -> store it in what you want like the excel row :)
     
    This is the way , at the moment , i will do it my self :)
     
    i hope this help, feel free to check "answer" checkbox if you think it s you'r answer to solve you'r case :) it's important for the community :)
  • Verified answer
    LukeB Profile Picture
    33 on at
    Hi,
     
    I was able to achieve this only using a topic within Copilot Studio. The issue I was having came down to the formula being used. In the end the topic flow looks like the diagram below
     
     
    The things to note:
    1.  I needed to use a variable to set the file path from the loop variable. It did not like referencing the variable directly within the "Create generative answers" node
    2. The SharePoint output "FullPath" only returns the path from the library so I needed to concatenate the site path to get the complete path to the file
    3.  You need to wait for SharePoint indexing to complete before it will return answers
    4.  The formula to set the classic data field was then set to [File_Path_Variable]. Ie add [ ] around the variable. See screen shot below. 
     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Copilot Studio

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 261 Super User 2025 Season 2

#2
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 198 Super User 2025 Season 2

#3
S-Venkadesh Profile Picture

S-Venkadesh 93 Moderator

Last 30 days Overall leaderboard