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.
Announcements
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.
Hi @Expiscornovus,
Thank you so much for your help the bot is fetching the right documents. But in the bot response.
Title and Link not in an arranged manner in HTML Table how can be arranged in right format,Say In any documents iss searched then it should give as Title Link,Title contains name of the document and the link contain link of the document.
How Can I arrange it properly?
Regards,
@Anonymous
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 that: https://powerusers.microsoft.com/t5/Power-Virtual-Agents-Community/How-to-use-mark-down-to-format-a-table-for-the-bot-response/ba-p/1190942
For completion, this is the setup of the Topic of the bot
Hi @Expiscornovus,
Thank you for your help, can you help me with the flow creation.
My problem statement is to fetch files and documents from SharePoint library. Say, there is a document library which has multiple folders, my question is that when a user requested for certain files. PVA gives me 5 links related to that document. Please help me out.
Regards @Anonymous.
Hi @Anonymous,
Seems like some of your documents from the Get Files (properties only) outputs are missing a value in the Title column. You can add an not empty check in the Filter Array action as well.
The whole expression would be:
@and(not(empty(item()['Title'])), contains(item()['Title'], triggerBody()['text']))
Hi, @Anonymous .
Here's a pattern you can follow. After using "Get files (properties only)" as @Expiscornovus suggested, you can iterate through the links and append to a string variable (I called mine "Links" below) in markdown format so that you can output that variable into PVA and it will automatically output the list of links. This makes the title of the document the text you see but you can modify as needed to fit your needs.
Find this post helpful? Please mark it as the solution and/or provide kudos so that it will help others in the future.
Cheers,
Matt
Hi @Anonymous,
There are several ways of achieving this.
The easiest is probably using the Get files (properties) only action for this in Power Automate.
In that action you can a single library and by specifying a filter and use the input from the user in PVA to query that library. I would suggest to have a look at the video (with that approach) in this thread, created by @renatoromao, https://powerusers.microsoft.com/t5/Calling-Actions-from-PVA/PVA-in-teams-Find-a-file-in-sharepoint-library/m-p/1549499/highlight/true#M751
However, you can also try search driven type of approaches if the content is scattered around different sites and libraries:
- Search REST API approach: https://powerusers.microsoft.com/t5/Building-PVA-chatbots-in/Search-share-point-for-document/m-p/1549570/highlight/true#M710
- Graph API approach by @HenryJammes, https://powerusers.microsoft.com/t5/Calling-Actions-from-PVA/Calling-the-Graph-API-to-do-a-document-search-in-PVA/m-p/2101601#M1072
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.