web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details
Copilot Studio - General
Answered

To fetch documents from sharepoint library

Like (0) ShareShare
ReportReport
Posted on 4 Sep 2023 07:44:28 by

I've created a PVA for SharePoint now I wanted to fetch files and documents from SharePoint library when asked by the bot, I've tried to create a flow but unable to do it. Please help with it.

Categories:
I have the same question (0)
  • Verified answer
    Expiscornovus Profile Picture
    32,891 Most Valuable Professional on 07 Sep 2023 at 11:05:16
    Re: To fetch documents from sharepoint library

    Hi @Anonymous,

     

    Below is another example. It is based on the samples shared earlier.

     

    The flow setup.

     

    1. The Get File (properties only) action uses the Filter Query to search for the words from the Chatbot in the FileLeafRef property (the file name). It also uses a top 5 count, to only retrieve a maximum of 5 items.

    substringof( '@{triggerBody()['text']}',FileLeafRef)

     

    2. The Select is used to only retrieve specific details of the files, in this case Created on and File Name and Link to Item. Below is what I used in the example for the Map field.

    {
     "Created": @{formatdatetime(item()['Created'], 'dd MMM yyyy')},
     "Link": "[@{item()?['{FilenameWithExtension}']}](@{item()?['{Link}']})"
    }

     

    3. A HTML table is temporary created via a HTML table action

     

    4. The outputs is converted into a Results variable and uses a Markdown table as value, which is created with several replace functions via one expression:

    replace(replace(replace(replace(replace(replace(replace(body('Create_HTML_table'), '<table><thead><tr><th>', '| '), '</th></tr></thead><tbody>', concat(' |',decodeUriComponent('%0A%0D'),'|-----------|:-----------:|',decodeUriComponent('%0A%0D'))), '</th><th>', ' | '), '<tr><td>', '| '), '</td><td>', ' | '), '</td></tr>', concat(' |',decodeUriComponent('%0A%0D'))), '</tbody></table>', '')

     

    Btw, if you don't feel comfortable with this type expression feel free to use the apply to each with append to variable approach instead, I have a blog about thathttps://powerusers.microsoft.com/t5/Power-Virtual-Agents-Community/How-to-use-mark-down-to-format-a-table-for-the-bot-response/ba-p/1190942

     

    keywords_search.png

     

    For completion, this is the setup of the Topic of the bot

     

    findbooks.png

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Copilot Studio

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 424 Super User 2025 Season 2

#2
Romain The Low-Code Bearded Bear Profile Picture

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

#3
CU15090955-0 Profile Picture

CU15090955-0 46

Last 30 days Overall leaderboard
Loading complete