Auto tagging documents in SharePoint using Microsoft AI / Text Analytics

The following Flow will demonstrate how to extract the text layer from a file, send to the 'Key Phrases' text analytics action for analysis before using the results to automatically tag the SharePoint document.

Please note: You will require an Azure subscription and a cognitive services account to utilise the Flow Text Analytics connector, you can create a free account here.

Flow Creation Steps

1. Create a new Flow from a blank template

2.png

2. Add the ‘When a file is created or modified (Properties Only)’ SharePoint trigger and configure to point to the library / folder where the Flow should be triggered from. 

2.png

3. Add a 'Get File Content' SharePoint action

3a. Site Address: Set as per the 'Site Address' value of step #2.

3b. File Identifier: Insert the 'Identifier' parameter from the 'When a file is created or modified (properties only)' action result

3.png

4. Add an Encodian 'Convert to PDF' action

4a. File Content: Insert the 'File Content' parameter from the 'Get file content' action result

8.png

4b. PDF Filename: Insert the 'File name with extension' parameter from the 'When a file is created or modified (properties only)' action result

9.png

Note: The Encodian 'Convert to PDF' action will automatically check the 'PDF Filename' value  and change the file extension provided to '.pdf' if required.

4c. Filename: Insert the 'File name with extension' parameter from the 'When a file is created or modified (properties only)' action result

10.png

5. Checkpoint: Your new Flow should look similar to the following:

27.png

6. Add an Encodian 'Get PDF Text Layer' action

6a. Filename: Insert the 'Filename' parameter from the 'Convert to PDF' action result

28.png

6b. File Content: Insert the 'File Content' parameter from the 'Convert to PDF' action result

29.png

7. Add a Text Analytics 'Key Phrases' action

NOTE: If you have not already created a connection you will be prompted to create a new Text Analytics connection utilising a cognitive services account hosted within an Azure subscription, you can create a free account here.

If you need to create a new connection please follow these additional steps:

7a. Connection Name: Enter a name for your connection

7b. Account Key: Enter the key obtained from your Cognitive Services account

7c. Site Url: Enter the endpoint obtained from your Cognitive Services account

7d. Click 'Create'

25.png

Once your connection is created or if your connection was previously created, follow these steps:

7e. Text: Insert the 'Text Layer' parameter from the 'Get PDF Text Layer' action result

30.png

8. Add an 'Initialise variable' action

8a. Name: Set to 'KeyPhrases'

8b. Type: Select 'String'

33.png 

9. Add a 'Append to string variable' action

9a. Name: Set to 'KeyPhrases'

9b. Type: Insert the 'keyPhrases - Item' parameter from the 'Key Phrases' action result

34.png

9c. This will dynamically insert an 'Apply to each' loop action
 
35.png
 
9d. To correctly format the results, remove the default value and add the following expression to the 'Value' parameter.
concat(items('Apply_to_each'), ', ')

9e. Click 'OK'

10. Add an 'Update File Properties' SharePoint action

10a. Site Address: Set as per the 'Site Address' value of step #2.

10b. Library Name: Set as per the 'Library Name' value of step #2.

10c. Id: Insert the 'ID' parameter from the 'When a file is created or modified (properties only)' action result

31.png

The next step is to utilise the data returned from the 'Text Analytics' action and write to a metadata field associated with the source item. We have added a 'Key Phrases' column to the library to store the data.

10d. Key Phrases: Insert the 'KeyPhrases' variable

11. Completed: Your flow should appear as follows

12. Test the flow

13. Validate the results

41.png

Please note: The 'Text Analytics' action is limited to process 5120 characters per request. It is likely that you will exceed this limit by sending an entire document, however the Encodian 'Get PDF Text Layer' action allows you to target specific pages which can help keep within this limit.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk