CRM to QuickBooks Closed-Won Invoice Automation (n8n)

Streamline financial operations by automatically syncing CRM deals to QuickBooks Invoices using n8n's workflow engine.

Tools: CRMQuickBooks

Platform: n8n

Short Answer

A fully automated pipeline where a 'Closed-Won' deal in your CRM instantly verifies customer existence in QuickBooks, creates or updates the record, and generates a detailed invoice with correct line items, reducing DSO (Days Sales Outstanding).

The Problem

Manual entry of invoices from a CRM to QuickBooks leads to data silos, human error, and delayed billing. Businesses often struggle with duplicate customer records and mismatched tax or currency data when moving data between sales and accounting tools.

The Outcome

A fully automated pipeline where a 'Closed-Won' deal in your CRM instantly verifies customer existence in QuickBooks, creates or updates the record, and generates a detailed invoice with correct line items, reducing DSO (Days Sales Outstanding).

Step-by-Step Guide

1. **Initialize Webhook**: Add a 'Webhook' node in n8n. Set the HTTP Method to POST. Copy the 'Test URL' and paste it into your CRM's webhook settings for the 'Deal Won' event. 2. **Define Credentials**: In n8n, go to Credentials > Add Credential. Search for 'QuickBooks Online OAuth2'. Follow the OAuth flow to authorize n8n to access your QBO company data. 3. **Search for Existing Customer**: Add a 'QuickBooks Online' node. Set Resource to 'Customer' and Operation to 'Get All'. Use the 'Filters' parameter to search by Email or Name using an n8n expression like `{{ $json.customer_email }}`. 4. **Branch Logic (IF Node)**: Add an 'IF' node after the search. Set the condition to check if the search result array is empty (`{{ $json.length === 0 }}`). 5. **Create/Update Customer**: On the 'true' path (Not Found), add a QuickBooks node to 'Create' a Customer. On the 'false' path (Found), use the 'Update' operation, passing the `id` and `SyncToken` found in Step 3. 6. **Data Transformation (Edit Fields/Set Node)**: Use an 'Edit Fields' node to map CRM Deal attributes to QBO Invoice fields. Crucially, format the 'Line Items' array here. Use n8n expressions to map `{{ $json.deal_value }}` to the `Amount` field. 7. **Handle Line Items**: If your CRM provides multiple products, use the 'Split Out' node to iterate through them or an 'Aggregate' node to format them into the specific JSON structure QuickBooks requires for `Line` items. 8. **Generate Invoice**: Add a final QuickBooks node. Set Resource to 'Invoice' and Operation to 'Create'. Map the Customer ID from the previous steps and the Line Items array from the Edit Fields node. 9. **Configure Error Handling**: Create a separate workflow or use an 'Error Trigger' node. Connect it to a Slack or Email node to notify the admin if the QuickBooks API returns a 400 error (common for duplicate names or invalid tax codes).