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 #
- Go to https://make.powerautomate.com
- Click ‘Create > Automated cloud flow’
- Name the flow: Legale Callback Finished Backup
- Choose the trigger: ‘When an HTTP request is received’
2.2 Define the trigger schema #
- Use ‘Use sample payload to generate schema’
- 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 #
- Click ‘New step’ > ‘Create file’ (SharePoint)
- 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 #
- Add an ‘HTTP’ action (premium)
- Configure:
– Method: GET
– URI: @{triggerBody()?[‘download_url’]}
– Header Authorization: Bearer <your-token-if-required>
3. Get the webhook URL #
- In the trigger ‘When an HTTP request is received’
- Save the flow and copy the generated URL
4. Configure callback in Legale.io #
- Log in to https://app.legale.io as an administrator
- On the left navigation menu, go to: Integration > Callback
- In the ‘Callback when Workflow finished’ section:
– Enable the toggle to ON
– Paste the Power Automate URL into the ‘Callback URL’ field
– Click Save
- (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