A fully automated pipeline where Dext-extracted data is validated, filtered by value, and uploaded to Xero with binary attachments. High-value items are routed for approval, and all errors are caught by n8n’s Error Trigger system.
The Problem
Manual data entry from receipts into Xero is error-prone and time-consuming. While Dext has a native sync, businesses often need custom logic—such as approval gates for high-value invoices or automated tracking category assignment—that standard integrations cannot provide.
The Outcome
A fully automated pipeline where Dext-extracted data is validated, filtered by value, and uploaded to Xero with binary attachments. High-value items are routed for approval, and all errors are caught by n8n’s Error Trigger system.
Step-by-Step Guide
1. **Establish Credentials**: In n8n, go to 'Credentials' and create 'Xero OAuth2 API' credentials. For Dext, use the 'HTTP Request' node with a 'Header Auth' (API Key) or OAuth2 if available for your region.
2. **Configure Trigger**: Add an 'HTTP Request' node to poll the Dext `GET /items/ready` endpoint on a Cron schedule (e.g., every 15 minutes) or use a Webhook node if your Dext plan supports outbound webhooks.
3. **Extract Item Details**: Use a 'Set' or 'Edit Image' node to isolate key fields: `supplier_name`, `total_amount`, `tax_amount`, and `image_url`.
4. **Handle Item Binary**: Dext provides a URL for the image. Use an 'HTTP Request' node set to 'Response Format: File' to download the original PDF/Image into n8n's memory.
5. **Duplicate Check**: Add a 'Xero' node with the 'Get Many' operation for Bills. Use an expression to filter by `Reference` (using the Dext Invoice ID) to ensure the bill hasn't already been created.
6. **Contact Logic**: Add a 'Xero' node set to 'Contact: Get' by name. Follow this with an 'IF' node; if no contact exists, use a second 'Xero' node to 'Contact: Create'.
7. **Conditional Logic (Approval)**: Add an 'IF' node to check `{{$json.total_amount}} > 1000`. If true, route to a 'Wait for Webhook' or 'Slack' node for human approval before proceeding.
8. **Create Transaction**: Add a 'Xero' node to 'Bill: Create'. Map the extracted fields using n8n expressions (e.g., `{{ $node["Transform"].json["net"] }}`).
9. **Attach Document**: Immediately following the Bill creation, add a 'Xero' node with 'File: Upload'. Use the Binary data from Step 4 and the `invoice_id` returned from Step 8.
10. **Error Handling**: Create a separate workflow or a 'Sticky' Error Trigger node. Use this to notify the team if the Xero API returns a validation error (e.g., locked accounting period).