Skip to main content


Building Copilot Studio Chatbots in Microsoft T...

Search share point for document

Posted on by 52



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?

  • Yaswini24 Profile Picture
    Yaswini24 2 on at
    Re: Search share point for document

    Hi there I am having an issue where it is leaving a blank space, i want it to complete the shared documents and not just stop at shared. What do i do? @Expiscornovus would you be able to assists 🙂 i just want to know how to get the full link out 🙂




  • Expiscornovus Profile Picture
    Expiscornovus 1,708 on at
    Re: Search share point for document

    Hi @Cydman2023,


    I would first double check if the Rows property in the outputs of your Send an HTTP request to SharePoint action contains any results?


    That property should be nested within the below structure.



  • CydmanSG Profile Picture
    CydmanSG 10 on at
    Re: Search share point for document

    Hi @Expiscornovus and @Gwill1983 and @SShAl249 


    Guys, would please help help me to check my flow from PWA to Power Automate? I am able to fix all the error and it is running now but result returning to my pva. Hope someone guide me to see what is the problem why there is no result. here is my flow.





















    The Flow is running but no result





    I am not sure what is missing. Can you please help me guys on this one? I need your advise badly.


  • Cydman2023 Profile Picture
    Cydman2023 2 on at
    Re: Search share point for document

    Hi @GlennBullion thanks for this concept and I am trying to mimic your solution here. I completed all nodes but I am getting this error. "The input parameter(s) of action 'Return_value(s)_to_Power_Virtual_Agents' contain an invalid reference to 'Compose_1'. Correct to include a valid reference to 'Compose_1' for the input parameter(s) of action 'Return_value(s)_to_Power_Virtual_Agents'."

    Any idea? Any help you can extend would be highly appreciated because your requirements are exactly what I am looking for.


    Please anyone could help me please? I am trying to fix this for almost 3days now 😄


    Please see below my flow.














    When I copy and paste "The Title and Path are expressions: items('Drawings_Loop')['Title'] and items('Drawings_Loop')['Path'] ." It shows different on my flow













  • SShAl249 Profile Picture
    SShAl249 6 on at
    Re: Search share point for document

    Do you mean in the site address section? I have tried it and it gives this error in the bot chat window.


    Sorry, the bot can't talk for a while. It's something the bot's owner needs to address. Error code: 2003. Conversation ID: 3R592OiSpnLD1FvKynU2aN-uk. Time (UTC): 2/7/2023 6:10:24 AM.


    The sub folder url is working in the browser, when added to 'site address' and 'uri' section, it doesn't work. Below screenshot shows how I have added the site address in both sections.





    If I use the site address from the drop down (parent link) and keep the sub folder link in the compose section the error goes away although I get no results.


    I need to restrict the search to a sub folder only. Please can you try at your end if it works.

  • GlennBullion Profile Picture
    GlennBullion 16 on at
    Re: Search share point for document

    That's how I search as well. My Compose statement is just the root of a document library. I've never tried a sub folder.


    Just a guess, but you might be able to pass a subfolder in the "Send HTTP request to Sharepoint" step?

  • SShAl249 Profile Picture
    SShAl249 6 on at
    Re: Search share point for document

    Hi @GlennBullion Thanks for sharing this method. I tried the it and it worked well except for the SharePoint sub folder links, its only working for the parent folder for me.(shows blank result when sub folder is selected) 


    Below is the format of the link https://sharepoint/com/sites/site1/Shared Documents/General


    It only works when I put https://sharepoint/com/sites/site1/ in the compose step.


    Please can you help out with this. Thanks.

    Also, is there a way to obtain Name of the file instead of the Title ?



  • GlennBullion Profile Picture
    GlennBullion 16 on at
    Re: Search share point for document

    Okay, will break this down for what I ended up doing. Keep in mind, I'm no expert. 🙂 But this worked for me, for my needs. All I'm looking to do is get some keywords from the user in the bot, pass it to flow to do a Sharepoint Search, then pass those results back to the bot. A lot of joy is in here, namely due to the fun of working with the search results, markdown language, etc.


    Here we go.


    Overview below, I'll go through the steps as well. (Forgive my naming. I try to rename many steps so that I can look at it later and know what I was doing).


    Bot Flow Overview.png


    The first few steps:


    Bow Flow Setup.png


    The Power Virtual Agents is the input from the bot, of course.


    The "Compose Folder" (grayed out for privacy) statement is just the full Sharepoint path name of the folder (and subfolders) I want the Sharepoint Search API to search. You see it being used in the Send an HTTP Request step.


    The Send an HTTP Request statement (Site Address grayed out for privacy) was discussed in previous messages. The only thing I added to it was the "Compose Folder" to limit the search location, a RowLimit of 100, and I also limited the returned properties to Title and Path, as they were the only two fields I cared about.


    I ultimately used two select statements to get the Title and Path.


    Bot Flow Select Steps.png


    The first Select statement is again a lift from earlier in this thread. It grabs the "Cells" from the JSON search results.


    The second Select statement grabs the Title and Path from the previous Select statement. Those two "Item" statements are, in order:





    Since I only grabbed the Title and Path from the API above, Items 0 and 1 in the array turn out to be Title and Path.


    Below is just setting up a String Variable. It will end up holding all of the search results.


    Bot Flow Variable.png


    Here is the Apply to Each that builds the search results.


    Bot Flow Loop.png


    The "Output" statement is from the second Select statement.


    The "Append to varResults" is just an Append to String, and you can see how the Value is built. That is all Markdown language (which I had to look up quite a bit 🙂 ), in order to get it looking pretty for the bot. The "Title" goes in brackets. The Path goes in parenthesis and greater than/less than, which puts together a nice URL link. the "\n" I use for a new line (which I'll talk about below).


    The Title and Path are expressions: items('Drawings_Loop')['Title'] and items('Drawings_Loop')['Path'] .


    Below is the last stretch, a Compose statement to create a line break, and the Return to PVA.


    Bot Flow Line Break.png


    The Compose Line Break statement is: uriComponentToString(replace(variables('varResults'),'\n','%0A%0A'))


    What I found is that without that statement, the results that go back to the user don't have any line breaks. It's all just mashed together. So, this replaces all of the "\n" with two "spaces", which triggers a line break in Markdown. Makes the results look nice.


    And the last statement is to return that to PVA. Here is a sample of my results.


    Bot Flow Results.png


    This turned out well for me. I'm still fine tuning, but getting there.


    Note some "weirdness" with this:


    I can't figure out how to Sort the results alphabetically yet.  Adding a "sortlist" to the Search API statement for Title crashes the flow.  Not sure why.


    This also searches inside the document, which I myself like. But I can see my users saying "We want just the title only". So, will dig into that later as well.


    Thanks to Expiscornovus, (and all the other threads I went through 🙂 ), for getting me on the right track with this.

  • Gwill1983 Profile Picture
    Gwill1983 52 on at
    Re: Search share point for document

    I never managed to get this working fully and it was well and truly filed into the ‘too difficult’ column! If you have managed to find a work around then I would be keen to see it! 

  • GlennBullion Profile Picture
    GlennBullion 16 on at
    Re: Search share point for document

    I did get a working solution together. I'll post it tomorrow for thoughts.

Helpful resources

Quick Links

Exciting News for Copilot Studio Communi…

Get ready to experience a whole new level of engagement with the Copilot Studio…

Celebrating the May Super User of the…

LaurensM is an exceptional contributor to the Power Platform Community…

Check out the Copilot Studio Cookbook…

We are excited to announce our new Copilot Cookbook Gallery in the Community…


renatoromao Profile Picture

renatoromao 6,459

Pstork1 Profile Picture

Pstork1 1,995

Expiscornovus Profile Picture

Expiscornovus 1,708


Featured topics