Power Automate SharePoint Connector — Unique AI Documentation

Power Automate SharePoint Connector

The current Power Automate–based SharePoint connector is being replaced by our new cloud-native SharePoint Connector.

Overview

The SharePoint Connector connects Microsoft SharePoint Online to Unique AI via Microsoft PowerAutomate.

The Unique SharePoint connector consists of a series of Power Automate flows bundled in a solution that will be provided by Unique (ZIP file).

Clients need to import and setup the Solution in their own environment’s Power Automate.

As the solution uses environment variables, only one solution can be deployed per environment.

Files and site pages to sync are identified by an ad hoc boolean column (Unique AI in this documentation) whose name can be customised.

The solution runs globally and is able to sync all SharePoint sites and libraries at once.

Requirements

Current Export of the Solution

v. 1.0.0.9 (update: file type validation)

CSVUnique_SP_Connector_Configuration_List.csv

ZIPUniqueFinanceGPTSharepointConnector_1_0_0_9.zip

Architecture

The architecture of the SharePoint connector with the scheduled sync approach makes the SharePoint integration more scalable and more stable compared to an event based approach, as per the current state of SP events that show unreliability and inconsistency (Aug 2024).

The benefits of following the scheduled approach are:

The solution is a collection of flows that scan the files to ingest, detect the changes, and trigger ingestion, changes of folder, or deletion where needed.

The synchronisation flows are called sequentially and the whole synchronisation process cannot run in parallel to ensure consistency.

This means that no matter how high the synchronisation frequency is set, no new synchronisation will be triggered until the ongoing synchronisation is done sending all files to be ingested to Unique.

Overview Diagram

The Logic of the scheduled SharePoint Flow

Scheduler flow

The “Scheduler” flow in the solution is responsible for triggering the sync of the files from SharePoint to Unique’s knowledge base.

The flow triggers the synchronisation process by calling the Sharepoint Files Scan flow.

Sharepoint Files Scan flow

The flow holds the main logic part and loops through the sites and their libraries. In the process it calls the child flows IDP Get Access Token to get the Unique token, and Ingest Content.

A list of SharePoint Sites that contain content to synchronise in some or all of their libraries must be provided as a configuration list. The main logic in the flow uses this input and executes a series of nested loops.

Within the listed sites, the flow identifies the libraries that have the Unique AI column set, and fetches the set of files that have been marked for ingestion.

We filter for the published documents and Site Pages with OData__ModerationStatus properties on the file. Field values are as follows:

0 = Approved
1 = Rejected
2 = Pending
3 = Draft

A diff is calculated by calling Unique file-diff endpoint on the ingestion service:

Ingest Content flow

The flow is responsible for handling the calls to the Unique ingestion API and uploading the file content to the blob storage for ingestion. IDP Get Access Token flow is called as well in this flow to get a token for the API calls.

Calls to the flow are library based: the flow loops through the provided file id list of new and modified files within a single library and sends them for ingestion.

IDP Get Access Token flow

The flow is responsible for getting an access token that can be used to call the Unique APIs. Unique sets up a service user for each client that has the necessary permissions to call the ingestion APIs.

The service user’s client credentials will be provided to the clients and are used to get a token in this flow.

username + password flow (deprecated)

If you are not using a key vault you can use the IDP Get Access Token - username + password flow. You will need to configure the related environment variables.

You will need to modify the child flow called in the Get Access Token actions in both Sharepoint Files Scan and Ingest Content flows to select the proper child flow to get the token.

Delete Flows

Two flows are responsible for deleting all files belonging to a site and to its libraries.

Delete Library

Deletes the library by sending an empty array to file-diff. Ingested files are deleted in Unique by Unique’s backend.

Delete Site

Loops through all site libraries and call Delete Library for each one. The flow is called when a site is marked for deletion in the configuration list.

Setup

Add custom column in SharePoint

A custom boolean column needs to be added to a SharePoint library to control the ingestion of the files.

To set the custom column:

  1. In SharePoint, add a custom column by clicking the “+ Add column” button. Select the column type “Yes/No”.

  2. Name the custom column. This will be the name you need to use when setting up the Power Automate Flow variables. Also set a default value for new files.

  3. After saving and creating the column, you can optionally format the column to make the selected values more obvious to the users in SharePoint. Select the column’s dropdown > Column settings > Format this column. There select “Format yes and no” (you can also choose the colors by editing the styles).

Setting up the SharePoint Connector’s Power Automate flows

The setup process for the Unique SharePoint Connector consists of the following steps:

  1. Import the Power Automate Solution provided by Unique

  2. Configure the environment variables while or after having imported the solution

Import the Power Automate Solution

Unique provides the Unique SharePoint connector to Customers as an exported Power Automate solution, which is a ZIP file. Along with the ZIP file, the Customers receive client credentials and all necessary values for configuring the environment variables.

In Power Automate navigate to the Solutions tab on the left side. You should see an overview of all existing solutions. On the top, click the Import solution button and you will be prompted to provide a file. Upload and import the ZIP file that Unique provided containing the Power Automate solution for the Unique SharePoint connector.

Set Up the Configuration list

The Sharepoint sites to synchronise are stored in a Sharepoint list that needs to be accessible from the Power Automate Flow.

The site hosting the list does not have to be synchronised but it must be accessible by the user running the flow.

The list must contain the following columns:

⚠ Any other set of scope values will fail the ingestion calls ⚠

Configure environment variables

There are two logical sets of environment variables with the global prefix ufgpt like the rest of the objects within the solution:

The SharePoint variables must be configured as such:

The Unique variables must be configured as such:

Power Automate does not like empty environment variables so if they are not used, these variables should be left to the default empty string value "".

Scopes Considerations

Scope types

3 types of scopes are available:

SP Service User Scope Access

The connector is in charge of creating the needed scopes in the case of scope set to PATH. The service user is automatically granted READ/WRITE permission on all the scopes it creates, and only on those.

Known Limitations & Issues

Ingestion of linked content in SharePoint Pages

What can be ingested from SharePoint pages has limitations.

What works:

What does not work:

The limitation stems from the fact that we fetch the content of the SharePoint page from SharePoint’s API via Power Automate flow and what we receive there is the actual content on the page.

Other Known Limitations

Note that most known limitations can be overcome by adapting the flows to your needs. The SharePoint Inline - Power Automate connector is designed to serve as a general purpose connector for the Unique chat ingestion.

It mostly serves as a basis for further configurations that match your specific needs.