How it works
What this workflow does
Turn the products on a won Pipedrive deal into one Xero draft invoice for finance review. An authenticated webhook verifies the deal and contact mapping, maps supported product lines into a Xero draft, and asks the designated finance reviewer to approve it in Slack. Authorization and email are separate opt-in steps with their own rechecks.
The workflow imports inactive with dryRun: true. Run with sample data uses a fictional deal and product, so the preview does not call Pipedrive, Xero, Slack, or Gmail.
This is the billing step in the Billing & Milestone-to-Invoice blueprint, with downstream collection handling covered by the Payment Recovery & Collections blueprint.
Build a predictable draft
Build Xero invoice accepts only enabled one-time products with the same currency as the deal, a matching tax basis, positive quantity and price, and either no discount or a percentage discount. Recurring products, amount-based discounts, mixed currencies, missing descriptions, and zero-value invoices stop before Xero.
The invoice number is deterministic: the configured prefix plus the Pipedrive deal ID. The due date uses paymentTermsDays and the line items use the configured revenue account and tax type. Xero receives the invoice with Status: "DRAFT"; the workflow never authorizes automatically from this step.
Review, authorize, email
Before creating the draft, the workflow verifies that the mapped Xero contact exists and is active. It then checks for an existing invoice with the same number; a replay stops instead of creating a second draft. The create request includes an Idempotency-Key, and the returned draft must match the expected contact, currency, number, total, and updated timestamp.
Slack sends an approval request to the configured finance reviewer and waits up to two days. Only that reviewer can approve. authorizeAfterApproval is false by default. When enabled, the workflow rechecks that the deal is still won in the same currency and that the draft's updated timestamp, total, contact, and status still match before authorizing.
emailAfterAuthorization is also false by default. Email requires the contact to remain active, the primary email to match the reviewed draft, and no additional included recipients. The send uses its own Idempotency-Key.
Validation scope
The supplied report confirms the isolated n8n 2.47.4 import, inactive state, and sample path. It also covers structural checks, supported and unsupported product handling, replay protection, reviewer binding, and changed-draft or changed-recipient blocking. Live Pipedrive, Xero, and Slack calls require a staging test with your accounts. If a write fails or an approval expires, look up the invoice number in Xero before rerunning.
How to use
Before you start
- A current n8n instance.
- A Pipedrive account with API access to deals and deal products.
- A Xero organization and an integration account that can read contacts and create invoices in the target tenant.
- A Slack app with signed approvals and Capture Who Responded support.
- A trusted won-deal relay or internal service.
1. Import and run the sample
Download the complete package, extract the ZIP, and read the full setup guide. Import won-deal-draft-invoice.n8n.json and keep it inactive.
Open Run with sample data and choose Test workflow. Build Xero invoice should return a draft payload with the expected line, invoice number, and due date.
2. Configure billing facts
In Setup, set:
pipedriveSubdomainandxeroTenantIdxeroAccountCode,xeroTaxType, andtaxBasis(exclusive, inclusive, or none)- A unique
invoicePrefixandpaymentTermsDays financeReviewerIdand the two delivery switches
Use a unique invoice prefix in the Xero organization. Have the finance owner verify the tax mappings in a demo organization before using a real one.
3. Connect credentials
Attach a Header Auth credential with x-api-token to the Pipedrive HTTP nodes. Attach Xero OAuth2 API to the Xero HTTP nodes. Use an integration account with access to invoices and contacts in the configured tenant.
Configure the Slack app for signed approvals and select the bot credential and signing secret on Ask finance in Slack. Put a separate private Header Auth credential on Receive event.
4. Send a test deal
Send dealId and the mapped xeroContactId from a trusted service. Use the supplied test payloads to check the intake, deal, products, and approval shapes. The webhook acknowledges receipt; the execution and Xero show the result.
In staging, set dryRun to false while leaving authorizeAfterApproval and emailAfterAuthorization false. Verify the draft, contact, line items, tax, currency, and terms in Xero before enabling either option.
5. Enable the reviewed actions
Enable authorization only after the finance reviewer accepts the draft. Enable email after confirming the primary contact address and checking Xero email delivery with an address you own.
The supported path covers one-time items with one currency and one tax basis. Amount-based discounts and recurring products need manual handling. If the same deal is replayed, the existing invoice is found and the flow stops. If a write fails or the approval expires, reconcile the existing draft and approval in Xero before rerunning.
Related automations
Use the Tender Bid Review System before the deal is won and the Proposal Draft & Slack Approval System for the reviewed commercial document. The Client Onboarding & Project Handoff Automation starts delivery after the deal is signed. Read the Billing & Milestone-to-Invoice blueprint for the wider billing process.
Use the HubSpot Ghosted Proposal Follow-Up & Recovery System before the deal closes and this invoice draft is created.