View Categories

Documents to SharePoint backup via Power Automate

 Objective #

Automate the backup of workflow information from Legale.io to SharePoint using Power Automate and the built-in callback functions of the Legale.io platform.

1. Prerequisites #

– Administrator access to Legale.io

– An account with permissions to use Microsoft Power Automate

– A SharePoint Online site to store the backups

– Basic knowledge of Power Automate

2. Configure Power Automate #

2.1 Create a new flow #

  1. Go to https://make.powerautomate.com
  2. Click ‘Create > Automated cloud flow’
  3. Name the flow: Legale Callback Finished Backup
  4. Choose the trigger: ‘When an HTTP request is received’

2.2 Define the trigger schema #

  1. Use ‘Use sample payload to generate schema’
  2. Use this sample payload:

{

  “workflow_id”: “1234567890”,

  “event”: “workflow_finished”,

  “document_name”: “signed_contract.pdf”,

  “signed_at”: “2024-05-14T16:32:00Z”,

  “signed_by”: [“user1@company.com”],

  “download_url”: “https://legale.io/api/files/download/1234567890”

}

2.3 Add SharePoint create file action #

  1. Click ‘New step’ > ‘Create file’ (SharePoint)
  2. Configure:

– Site Address: Your SharePoint site

– Folder Path: /Documents/Legale-Backups/

– File Name: @{triggerBody()?[‘document_name’]}

– File Content: will be obtained in the next step

2.4 Download the document from Legale.io #

  1. Add an ‘HTTP’ action (premium)
  2. Configure:

– Method: GET

– URI: @{triggerBody()?[‘download_url’]}

– Header Authorization: Bearer <your-token-if-required>

3. Get the webhook URL #

  1. In the trigger ‘When an HTTP request is received’
  2. Save the flow and copy the generated URL

4. Configure callback in Legale.io #

  1. Log in to https://app.legale.io as an administrator
  2. On the left navigation menu, go to: Integration > Callback
  3. In the ‘Callback when Workflow finished’ section:

   – Enable the toggle to ON

   – Paste the Power Automate URL into the ‘Callback URL’ field

   – Click Save

  1. (Optional) Do the same for ‘Callback when Workflow started’ if needed

5. Optional: headers or filters #

– Use a secret token in headers for authentication

– Validate the workflow_id

– Add custom headers in the ‘Request headers’ section of Legale.io

Expected result #

When a workflow starts or finishes:

– The callback is triggered automatically

– Power Automate processes metadata and downloads the document

– The document is saved in SharePoint

Security recommendations #

– Use a secret token in the callback headers

– Validate IP origin or domain in Power Automate

– Avoid exposing endpoints without authentication

Powered by BetterDocs

Scroll to Top