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 / Search share point for...
Copilot Studio
Unanswered

Search share point for document

(0) ShareShare
ReportReport
Posted on by 271

Hi,

 

I have built a bot with several topics, but I am trying to implement a function where the user can request a process document and either get the file itself, or a share point link to access this.

 

I am really struggling to even get started on this.

 

does anybody know if this is possible?

  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Gwill1983,


    I would either use the REST API of SharePoint or the Graph API in a flow. You can call this flow from your Power Virtual Agent.

     

    Below is an example setup. Let me know if you need more instructions/explanation.

     

    1. The FindFile topic.

    It uses an entire response question. That question stores the answer of the user in a VarUserkeywords variable which is used to call the Power Automate flow and search for files.

     

    pvasearchfile_topic.png

     

    2. An example Power Automate flow which uses the _api/search/query to search for items in SharePoint search. The relevant results are returned in a FilesFound variable as a comma separated string.

     

     

    pvasearchfile.png

  • Gwill1983 Profile Picture
    271 on at

    thanks for this.

     

    An afwul lot of this doesn't make sense to me.

     

    In your select connector you are using dynamic content labelled 'cells'. That isnt an option for me.

     

    I have tried to use your example but am struggling to follow as the options arent there for me....

     

    Any ideas why that would be?

     

     

     

     

  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Gwill1983,

     

    Most fields were not listed in the dynamic content list because the response of the REST API is pretty complex with a lot of nested properties. So in most cases I used expressions.

     

    Below is a step by step explanation with a bit more details. Hopefully that clarifies a couple of things 🙂

     

    1. Add a Power Virtual Agents trigger action. Add a Text Input field. Call it Keywords.

     

    addinput_pva.png

     

    2. Add a Send an HTTP request to SharePoint action. Use a Get method. Use the following URI:

     

    _api/search/query?querytext='@{triggerBody()['text']}'

     

     

    Also use the application/json;odata=nometadata value for both the Accept & Content-Type headers.

     

    getitems_keywords.png

     

    3. Add a Select action. Use the following expression in the From

     

    body('Send_an_HTTP_request_to_SharePoint')['PrimaryQueryResult']['RelevantResults']['Table']['Rows']

     

     

    selectaction_searchapi.png

     

    4. Switch the Map field to text mode

     

    switchtotextmode.png

     

    5. Add an expression in the Map field

     

    item()['Cells']

     

     

    itemcells.png

     

    6. Add a Filter Array action. Use the following expression in the From field:

     

    body('Select')[0]

     

     

    In the criteria use Keywords is equal to Path

     

    filterarray_firstitem.png

     

    7. Add a second Select action. Use the following expression in the from.

     

    body('Filter_array')

     

     

    body_filterarray.png

     

    8. Switch the Map field to text mode.

     

    9. Add the following expression in the Map field:

     

    item()['Value']

     

     

    itemvalue_select2.png

     

     

    10. Add a Return value(s) to Power Virtual Agents action. Use a Text Output and call it Files Found. Add the following expression to the value field.

     

    join(body('Select_-_Path'), ', ')

     

     

    returnvaluetopva.png

     

  • Gwill1983 Profile Picture
    271 on at

    Thanks for breaking this down.

     

    I have used this step by step and it is saying that it is running successfully, but isnt actually returning anything 

    Gwill1983_0-1650632771324.png

    Do the keywords need to be exact, cause they wont be. 


    Also, is there a way of narrowing down the folder location this searches in?


    Thanks for all of your help so far

     

  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Gwill1983,

     

    Can you check the flow history and see if the Send an HTTP request to SharePoint actually has results or if that is already empty?

     

    It would be possible to refine search results or add more criteria query. 

     

    But just to double check. Are all items you are searching for in a single folder location?

     

    If that is that case using the Search API might be a bit of an overkill. In that instance maybe even a Get Items or a Send an HTTP request with $filter on items could be sufficient 😁

  • Gwill1983 Profile Picture
    271 on at

    Just had a look at the results of the HTTP and there is ALOT of information in there!!

     

    The search is to find a process document so I only really want the search to happen in the process folder. This folder will however have sub folders split by department or function so won't be a single folder full of PFD / Word docs. 

     

  • Gwill1983 Profile Picture
    271 on at

    Just wanted to flag this one again to see if anybody could help? 

  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Gwill1983,

     

    Sorry, I missed this in my notifications.

     

    I understand in another thread you were trying different approach. Have you already decided which approach you want to use?

     

    I would say that one from @renatoromao with the get files is easier and better for your situation because all the files are located in one folder:

    https://powerusers.microsoft.com/t5/Calling-Actions-from-PVA/PVA-in-teams-Find-a-file-in-sharepoint-library/m-p/1549499/highlight/true#M751

     

    If you do want to keep on using the approach I shared (with the Search API) you could use an refinement filter in your query. That should give you less results.

     

    Below is an example.

    refinementfilterlistid.png

  • Gwill1983 Profile Picture
    271 on at

    Thanks. Couldn't find that I had already submitted a request for this and put the new one on. That one didnt work and then you responded to this one (hence there being 2). Apologies!

     

    Thanks for all of your help. If you think that the other thread is a better solution then I will try to get a response to repair the error on there.

     

     

  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Gwill1983,

     

    You do not have to apologize 😀. I was just curious which approach you would prefer. This way we can focus on making that approach work for you.

     

    With that other approach you won't have to deal with nested json in the response, so that's why I thought that other one was probably a bit easier.

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Copilot Studio

#1
11manish Profile Picture

11manish 115 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 83

#3
anirudhev Profile Picture

anirudhev 74

Last 30 days Overall leaderboard