|
| 1 | +--- |
| 2 | +title: SharePoint event triggers |
| 3 | +--- |
| 4 | + |
| 5 | +You can use SharePoint events, such as adding new files to—or updating existing files within—SharePoint document libraries, to automatically run Unstructured ETL+ workflows |
| 6 | +that rely on those document libraries as sources. This enables a no-touch approach to having Unstructured automatically process new and updated files in SharePoint document libraries as they are added or updated. |
| 7 | + |
| 8 | +This example shows how to automate this process by adding a custom [Power Automate](https://www.microsoft.com/power-platform/products/power-automate) flow to your Microsoft 365 or Office 365 account. This flow runs |
| 9 | +whenever a new or updated file is detected in the specified SharePoint document library. This flow then calls the [Unstructured Workflow Endpoint](/api-reference/workflow/overview) to automatically run the |
| 10 | +specified corresponding Unstructured ETL+ workflow within your Unstructured account. |
| 11 | + |
| 12 | +<Note> |
| 13 | + This example uses a custom Power Automate flow that you create and maintain. |
| 14 | + Any issues with file detection, timing, or flow invocation could be related to your custom flow, |
| 15 | + rather than with Unstructured. If you are getting unexpected or no results, be sure to check your custom |
| 16 | + flow's run history first for any informational and error messages. |
| 17 | +</Note> |
| 18 | + |
| 19 | +## Requirements |
| 20 | + |
| 21 | +import GetStartedSimpleApiOnly from '/snippets/general-shared-text/get-started-simple-api-only.mdx' |
| 22 | + |
| 23 | +To use this example, you will need the following: |
| 24 | + |
| 25 | +- A Microsoft 365 or Office 365 Business or enterprise plan that includes SharePoint Online, OneDrive, and Power Automate. |
| 26 | + [Shop for business plans](https://www.microsoft.com/microsoft-365/business/compare-all-microsoft-365-business-products). |
| 27 | + [Shop for enterprise plans](https://www.microsoft.com/microsoft-365/enterprise/microsoft365-plans-and-pricing). |
| 28 | + |
| 29 | +- A Power Automate Premium license. [Learn how](https://learn.microsoft.com/power-platform/admin/power-automate-licensing/buy-licenses). |
| 30 | + |
| 31 | +- An Unstructured account, and an Unstructured API key for your account, as follows: |
| 32 | + |
| 33 | + <GetStartedSimpleApiOnly /> |
| 34 | + |
| 35 | +- The Unstructured Workflow Endpoint URL for your account, as follows: |
| 36 | + |
| 37 | + 1. In the Unstructured UI, click **API Keys** on the sidebar.<br/> |
| 38 | + 2. Note the value of the **Unstructured Workflow Endpoint** field. |
| 39 | + |
| 40 | +- A SharePoint source connector in your Unstructured account. [Learn how](/ui/sources/sharepoint). |
| 41 | +- Some available [destination connector](/ui/destinations/overview) in your Unstructured account. |
| 42 | +- A workflow that uses the preceding source and destination connectors. [Learn how](/ui/workflows). |
| 43 | + |
| 44 | +## Step 1: Create an app registration |
| 45 | + |
| 46 | +In this step, you create an app registration in Microsoft Entra ID to access the Azure key vault that you will create in the next step. |
| 47 | + |
| 48 | +1. Sign in to your [Azure portal](https://portal.azure.com). |
| 49 | +2. In the **Search resources, services, and docs** box, enter **App registrations**, and then in the list of **Services**, click **App registrations**. |
| 50 | +3. Click **+ New registration**. |
| 51 | +4. Enter some **Name** for the app registration. |
| 52 | +5. For **Supported account types**, select **Accounts in this organizational directory only**. |
| 53 | +6. For **Redirect URI**, select **Web**, and then enter `https://localhost`. |
| 54 | +7. Click **Register**. |
| 55 | +8. In the sidebar, click **Overview**. |
| 56 | +9. Expand **Essentials**, and note the values of the **Application (client) ID** and **Directory (tenant) ID** fields. |
| 57 | +10. Click **Client credentials**. |
| 58 | +11. On the **Client secrets** tab, click **+ New client secret**. |
| 59 | +12. (Optional) Enter some **Description** for the client secret. |
| 60 | +13. (Optional) Enter some non-default **Expires** value. |
| 61 | +14. Click **Add**. |
| 62 | +15. Note the value of the **Value** field. This is the app registration's client secret value. (Do not use the **Secret ID** value.) |
| 63 | + |
| 64 | +## Step 2: Create an Azure key vault |
| 65 | + |
| 66 | +In this step, you store your Unstructured API key in an Azure key vault for your Power Automate flow to access later. |
| 67 | + |
| 68 | +1. With your Azure portal still open from the previous step, in the **Search resources, services, and docs** box, enter **Key vaults**, and then in the list of **Services**, click **Key vaults**. |
| 69 | +2. Click **Create**. |
| 70 | +3. On the **Basics** tab, set the following key vault settings: |
| 71 | + |
| 72 | + | Setting | Suggested value | Description | |
| 73 | + |---|---|---| |
| 74 | + | **Subscription** | Your subscription | The Azure subscription within which to create your new key vault. | |
| 75 | + | **Resource Group** | **Create new** | After you click **Create new**, enter some name for the new resource group within which to create your new key vault. | |
| 76 | + | **Key vault name** | Some globally unique name | Some name that identifies your new key vault. Valid characters are `A`-`Z`, `a`-`z`, `0`-`9`, and `-`. | |
| 77 | + | **Region** | Your preferred region | Select a region that's near you or near other services that your key vault can access. | |
| 78 | + | **Pricing tier** | **Standard** | Choose the pricing tier for your key vault. | |
| 79 | + |
| 80 | +4. Click **Review + create**. |
| 81 | +5. Click **Create**. |
| 82 | +6. After the deployment is complete, click **Go to resource**. |
| 83 | +7. In the sidebar, click **Access control (IAM)**. |
| 84 | +8. Click **+ Add > Add role assignment**. |
| 85 | +9. On the **Role** tab, in the **Job function roles** list, select **Key Vault Administrator**. |
| 86 | +10. Click **Next**. |
| 87 | +11. On the **Members** tab, with **Assign access to** set to **User, group, or service principal**, click **+ Select members**. |
| 88 | +12. Search for and select the name of the app registration that you created earlier in Step 1. |
| 89 | +13. Search also for and select your user account. |
| 90 | +14. Click **Select**. |
| 91 | +15. Click **Review + assign** twice. |
| 92 | +16. In the sidebar, expand **Objects**, and then click **Secrets**. |
| 93 | +17. Click **+ Generate/import**. |
| 94 | +18. Enter some **Name** for the secret. |
| 95 | +19. For **Secret value**, enter your Unstructured API key value. |
| 96 | +20. Click **Create**. |
| 97 | + |
| 98 | +## Step 3: Create a Power Automate flow |
| 99 | + |
| 100 | +1. Sign in to [Power Automate](https://make.powerautomate.com). |
| 101 | +2. On the sidebar, click **Create**. |
| 102 | +3. In the **Start from blank** area, click **Automated cloud flow**. |
| 103 | +4. Enter some **Flow name** for your new flow. |
| 104 | +5. For **Search all triggers**, enter `When a file is created or modified (properties only)`, and then click |
| 105 | + **When a file is created or modified (properties only) (SharePoint)**. |
| 106 | +6. Click **Create**. |
| 107 | +7. In the flow designer, click the **When a file is created or modified (properties only)** node. |
| 108 | +8. On the **Parameters** tab, set the following node properties: |
| 109 | + |
| 110 | + - For **Site Address**, enter the **Site URL** value of the SharePoint source connector for your workflow. |
| 111 | + - For **Library Name**, enter the **Documents Library** value of the SharePoint source connector for your workflow. |
| 112 | + - (Optional) If you specified a **Path** value for the SharePoint source connector for your workflow, select **Folder** in the **Advanced parameters** list and then select the corresponding folder name. |
| 113 | + |
| 114 | +9. Below the **When a file is created or modified (properties only)** node, click the plus (**Insert a new action...**) button. |
| 115 | +10. In the **Search for an action or connector** box, enter `Get secret`, and then under **Azure Key Vault**, select **Get secret**. |
| 116 | +11. Set the following node properties: |
| 117 | + |
| 118 | + - Enter some **Connection name** for the connection. |
| 119 | + - For **Authentication type**, select **Service principal authentication**. |
| 120 | + - For **Client ID**, enter the **Application (client) ID** value of the app registration that you created earlier in Step 1. |
| 121 | + - For **Client secret**, enter the client secret value of the app registration that you created earlier in Step 1. |
| 122 | + - For **Tenant ID**, enter the **Directory (tenant) ID** value of the app registration that you created earlier in Step 1. |
| 123 | + - For **Key vault name**, enter the name of the key vault that you created earlier in Step 2. |
| 124 | + |
| 125 | +12. Click **Create new**. |
| 126 | +13. Below the **Get secret** node, click the plus (**Insert a new action...**) button. |
| 127 | +14. In the **Search for an action or connector** box, enter `HTTP`, and then under **HTTP**, select **HTTP**. |
| 128 | +15. On the **Parameters** tab, set the following node properties: |
| 129 | + |
| 130 | + - For **URI**, enter `<unstructured-api-url>/workflows/<workflow-id>/run`, and replace the following placeholders: |
| 131 | + |
| 132 | + - Replace `<unstructured-api-url>` with your Unstructured Worfklow Endpoint value. |
| 133 | + - Replace `<workflow-id>` with the ID of your Unstructured workflow. |
| 134 | + |
| 135 | + The **URI** should now look similar to the following: |
| 136 | + |
| 137 | + ```text |
| 138 | + https://platform.unstructuredapp.io/api/v1/workflows/11111111-1111-1111-1111-111111111111/run |
| 139 | + ``` |
| 140 | + |
| 141 | + - For **Method**, select **POST**. |
| 142 | + - For **Headers**, enter the following: |
| 143 | + |
| 144 | + - `accept`, set to `application/json` |
| 145 | + - `unstructured-api-key`, set to your Unstructured API key value. |
| 146 | + |
| 147 | +16. In the top navigation bar, click the disk (**Save**) button. |
| 148 | +17. Click **Back** to go to the flow's home page. |
| 149 | +18. In the top navigation bar, click the power (**Turn on**) button. |
| 150 | + |
| 151 | +## Step 4: Trigger the flow and view results |
| 152 | + |
| 153 | +1. On a separate tab in your web browser, go to the SharePoint document library that corresponds to both your Unstructured workflow's |
| 154 | + SharePoint source connector and the Power Automate flow's **When a file is created or modified (properties only)** node. |
| 155 | +2. Add or update a file in the document library. |
| 156 | +3. On a separate tab in your web browser, in the Unstructured user interface for your account, click **Jobs** on the sidebar. |
| 157 | +4. In the list of jobs, click the newly running job for your workflow. It might take a minute or so for the new job to appear in the list. |
| 158 | +5. After the job status shows **Finished**, go to your destination location to see the results. |
| 159 | + |
| 160 | +## Step 5 (Optional): Turn off the flow |
| 161 | + |
| 162 | +To stop the Power Automate flow from running automatically, go back to the web browser tab from earlier in Step 3. Then, |
| 163 | +with the flow's home page still open, in the top navigation bar, click the power (**Turn off**) button. |
0 commit comments