All Templates
Revenue Operations • Advanced • 1 n8n workflow

Won Deal to Draft Invoice System

Create one Xero draft invoice from the products on a won Pipedrive deal. The workflow maps enabled one-time products, uses a deterministic invoice number, asks the designated finance reviewer in Slack, and gates authorization and email behind explicit settings.

By Luka Salagishvili at Uptune

Last updated:

0

One system, 1 connected workflow

Start with the complete package and setup directions. The preview below shows the entry workflow. Import every listed workflow separately, then connect their references in your n8n instance.

Get the workflow Read the setup directions

Entry workflow preview

Powered by n8n.io

Read the architecture, decision rules, and exception handling in the source blueprint .

Continue with the related architecture guide .

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:

  • pipedriveSubdomain and xeroTenantId
  • xeroAccountCode, xeroTaxType, and taxBasis (exclusive, inclusive, or none)
  • A unique invoicePrefix and paymentTermsDays
  • financeReviewerId and 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.

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.

By Luka Salagishvili at Uptune

Luka shares practical workflow templates and automation guides at Uptune, covering connected business tools, implementation steps, and testing before launch.

Luka on LinkedIn · Book a consultation

Get the complete automation system

Download the workflow and the supporting files together. Extract the ZIP, then import the workflow JSON listed below separately. Configuration, source code, and other supporting files are not n8n workflow imports.

Download complete package (ZIP)

1 connected n8n workflow

It imports inactive. Follow the package setup directions before activating schedules or delivery.

  1. Won deal to Xero draft invoice workflow

    One authenticated webhook verifies a won Pipedrive deal, maps supported products into a Xero draft, asks the finance reviewer in Slack, and rechecks the deal and draft before authorization or email.

    won-deal-draft-invoice.n8n.json
    Download workflow 01

Setup, integration, and validation files

  • Complete setup guide

    Pipedrive and Xero credentials, tax mapping, invoice numbering, Slack approval setup, authorization gates, and recovery guidance.

    README.md
  • Test payloads

    A won deal intake, Pipedrive deal and product examples, and a finance approval response.

    test-payloads.json
  • Supplied validation report

    Isolated n8n 2.47.4 import, sample-path result, structural checks, and file hashes. Live provider authentication and calls were not executed.

    validation-report.txt