AutomationFlowsAI & RAG › Automate Invoice Generation & Email Delivery with Jotform, Xero & Gpt-4o-mini

Automate Invoice Generation & Email Delivery with Jotform, Xero & Gpt-4o-mini

ByAppUnits AI @appunitsai on n8n.io

This workflow automates the entire process of receiving a product/service order, checking or creating a customer in Xero, generating an invoice, emailing it, and notifying the sales team for example (via Slack) — all triggered by a form submission (via Jotform). Receive…

Webhook trigger★★★★☆ complexityAI-powered20 nodesXeroAgentOpenAI ChatEmail SendSlack
AI & RAG Trigger: Webhook Nodes: 20 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #9796 — we link there as the canonical source.

This workflow follows the Agent → Emailsend recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "X2u0Wnuo2Yp8dSaq",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Generate Invoices for Customers with Jotform, Xero and Slack",
  "tags": [],
  "nodes": [
    {
      "id": "5153a36b-decc-4145-bfb5-903123d3ed32",
      "name": "Receive form submission",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -464,
        0
      ],
      "parameters": {
        "path": "dac28968-ec17-41da-b720-c579c1a7169b",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "a4e41795-f814-4f53-ae06-c004d9f2fe61",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 320,
        "content": "## Receive Submission\nReceives the product/service form submission from Jotform"
      },
      "typeVersion": 1
    },
    {
      "id": "5d0f264c-57ab-4aa8-93a9-4a45a2ffe060",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        80
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 320,
        "content": "## Create Contact\nCreates a new contact"
      },
      "typeVersion": 1
    },
    {
      "id": "601c08b9-547d-4883-bdc0-c0e2725fb5c9",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        -96
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 320,
        "content": "## Create The Invoice\nCreates a new invoice for that contact"
      },
      "typeVersion": 1
    },
    {
      "id": "87296102-7ff7-4a22-a451-40749a219450",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1328,
        -480
      ],
      "parameters": {
        "width": 736,
        "height": 992,
        "content": "## Generate Invoices for Customers with Jotform, Xero and Slack\nThis workflow automates the entire process of receiving a product/service order, checking or creating a customer in **Xero**, generating an invoice, emailing it, and notifying the sales team for example (via **Slack**)  \u2014 all triggered by a form submission (via **Jotform**).\n\n## How It Works\n### 1- Receive Submission\n* Triggered when a user submits a form.\n* Collects data like customer details, selected product/service, etc.\n\n### 2- Check If Customer Exists\n* Searches Xero to determine if the customer already exists.\n* \u2705 **If Customer Exists:** **Update** customer details.\n* \u274c **If Customer Doesn\u2019t Exist:** **Create** a new customer in Xero.\n\n### 3- Create The Invoice\n* Generates a new invoice for the customer using the item selected.\n\n### 4- Send The Invoice\n* Automatically sends the invoice via email to the customer.\n\n### 5- Notify The Team\n* Notifies the sales team for example via Slack about the new invoice.\n\n## Who Can Benefit from This Workflow?\n* **Freelancers**\n* **Service Providers**\n* **Consultants & Coaches**\n* **Small Businesses**\n* **E-commerce or Custom Product Sellers**\n\n## Requirements\n- Jotform webhook setup, more info [here](https://www.jotform.com/help/245-how-to-setup-a-webhook-with-jotform/)\n- Xero credentials, more info [here](https://docs.n8n.io/integrations/builtin/credentials/xero)\n- Make sure that products/services values in Jotform are exactly the same as your item `Code` in your Xero account\n- Email setup, update email node (`Send email`)\n- LLM model credentials\n- Slack credentials, more info [here](https://docs.n8n.io/integrations/builtin/credentials/slack)"
      },
      "typeVersion": 1
    },
    {
      "id": "bea06527-f4fb-4c06-acec-80e540753990",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 320,
        "content": "## Format Data\nFormats the data thus making it easier to be used in other nodes"
      },
      "typeVersion": 1
    },
    {
      "id": "6f8c1525-ee7e-4d10-a0c0-641abe512e47",
      "name": "Format data",
      "type": "n8n-nodes-base.code",
      "position": [
        -160,
        0
      ],
      "parameters": {
        "jsCode": "function extractAddressData(text) {\n  const regex = /Street Address:\\s*([^<]+)<br>Street Address Line 2:\\s*([^<]+)<br>City:\\s*([^<]+)<br>State \\/ Province:\\s*([^<]+)<br>Postal \\/ Zip Code:\\s*([^<]+)<br>Country:\\s*([^<]+)<br>/;\n  const matches = text.match(regex);\n  \n  if (matches) {\n    return {\n      line1: matches[1].trim(),\n      line2: matches[2].trim(),\n      city: matches[3].trim(),\n      stateProvince: matches[4].trim(),\n      postalZipCode: matches[5].trim(),\n      country: matches[6].trim()\n    };\n  }\n  \n  return {\n    line1: null,\n    line2: null,\n    city: null,\n    stateProvince: null,\n    postalZipCode: null,\n    country: null\n  }\n}\n\nreturn {\n  address: extractAddressData($input.first().json.body.billingAddress),\n  customer: {\n    name: $input.first().json.body.name,\n    email: $input.first().json.body.email,\n    phone: $input.first().json.body.phone\n  },\n  item: {\n    name: $input.first().json.body.itemName\n  }\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "57002967-0cc2-416a-9b2d-5e0d7425e173",
      "name": "Create the invoice",
      "type": "n8n-nodes-base.xero",
      "position": [
        928,
        16
      ],
      "parameters": {
        "type": "ACCREC",
        "contactId": "={{ $json.ContactID }}",
        "lineItemsUi": {
          "lineItemsValues": [
            {
              "taxType": "INPUT",
              "itemCode": "={{ $('Format data').item.json.item.name }}",
              "unitAmount": "10",
              "accountCode": "200"
            }
          ]
        },
        "organizationId": "bc9a44a6-eb14-4f81-b24c-ca676c506446",
        "additionalFields": {}
      },
      "credentials": {
        "xeroOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "606e45ad-d5b6-4a96-ac41-d2fd73bad8d3",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1280,
        -352
      ],
      "parameters": {
        "text": "={{ $json }}",
        "options": {
          "systemMessage": "=You are an AI assistant that generates a professional invoice email that you get from an Xero response (newly created invoice), so you will recive an Xero invoice response and thus your job is to create a professional html email content because this html email content will be sent to the customer."
        },
        "promptType": "define"
      },
      "executeOnce": false,
      "typeVersion": 2.2
    },
    {
      "id": "486a7fee-acd9-46ad-bf2b-1bc815bfb2a4",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1280,
        -144
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "da747ce1-ddcf-4c40-a78d-452d68cac37b",
      "name": "Sticky Note19",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1168,
        -480
      ],
      "parameters": {
        "color": 7,
        "width": 592,
        "height": 480,
        "content": "## Send The Invoice\nSends the newly created invoice for that customer(via email)"
      },
      "typeVersion": 1
    },
    {
      "id": "0873e856-7c8a-46cf-b7d1-c7a75afb0c6a",
      "name": "Send email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1552,
        -352
      ],
      "parameters": {
        "html": "={{ $json.output }}",
        "options": {},
        "subject": "=New Invoice",
        "toEmail": "={{ $('Create the invoice').item.json.Contact.EmailAddress }}",
        "fromEmail": "user@example.com"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "1af9a24d-7ac1-47b4-a17a-2774f01c860c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        64,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 320,
        "content": "## Check If Contact exists \nChecks if the contact exists in Xero or not"
      },
      "typeVersion": 1
    },
    {
      "id": "994373c3-4f87-48cc-a30e-d34b0b345f12",
      "name": "Check if the customer exists",
      "type": "n8n-nodes-base.xero",
      "position": [
        128,
        0
      ],
      "parameters": {
        "limit": 1,
        "options": {
          "where": "=EmailAddress=\"{{ $json.customer.email }}\""
        },
        "resource": "contact",
        "operation": "getAll",
        "organizationId": "bc9a44a6-eb14-4f81-b24c-ca676c506446"
      },
      "credentials": {
        "xeroOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "14c4b4df-ce15-4e52-a89e-5a92db87b86b",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        304,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "bfa24559-7702-4ebf-909d-c5c2a60ad817",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json }}",
              "rightValue": 0
            },
            {
              "id": "b4301cfe-a22a-490f-a72b-50d266bc1c5e",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.ContactID }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b6eb0744-cb7e-4676-91d5-6272ceb21924",
      "name": "Create new contact",
      "type": "n8n-nodes-base.xero",
      "position": [
        608,
        192
      ],
      "parameters": {
        "name": "={{ $('Format data').item.json.customer.name }}",
        "resource": "contact",
        "organizationId": "bc9a44a6-eb14-4f81-b24c-ca676c506446",
        "additionalFields": {
          "phonesUi": {
            "phonesValues": [
              {
                "phoneType": "MOBILE",
                "phoneNumber": "={{ $('Format data').item.json.customer.phone }}"
              }
            ]
          },
          "addressesUi": {
            "addressesValues": [
              {
                "city": "={{ $('Format data').item.json.address.city }}",
                "type": "STREET",
                "line1": "={{ $('Format data').item.json.address.line1 }}",
                "line2": "={{ $('Format data').item.json.address.line2 }}",
                "region": "={{ $('Format data').item.json.address.stateProvince }}",
                "country": "={{ $('Format data').item.json.address.country }}",
                "postalCode": "={{ $('Format data').item.json.address.postalZipCode }}"
              }
            ]
          },
          "emailAddress": "={{ $('Format data').item.json.customer.email }}"
        }
      },
      "credentials": {
        "xeroOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c035f5c2-0822-4b73-b553-4a06c39bc867",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        -304
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 320,
        "content": "## Update Contact\nUpdates the contact"
      },
      "typeVersion": 1
    },
    {
      "id": "bc245137-a2fa-4817-bf79-e6bd0bcd4688",
      "name": "Update contact",
      "type": "n8n-nodes-base.xero",
      "position": [
        608,
        -192
      ],
      "parameters": {
        "resource": "contact",
        "contactId": "={{ $json.ContactID }}",
        "operation": "update",
        "updateFields": {
          "name": "={{ $('Format data').item.json.customer.name }}",
          "phonesUi": {
            "phonesValues": [
              {
                "phoneType": "MOBILE",
                "phoneNumber": "={{ $('Format data').item.json.customer.phone }}"
              }
            ]
          }
        },
        "organizationId": "bc9a44a6-eb14-4f81-b24c-ca676c506446"
      },
      "credentials": {
        "xeroOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ecf29c2f-7e91-41d1-a99b-8a2de86b7ce0",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1168,
        112
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 320,
        "content": "## Notify The Team\nNotifies the team (sales team for example) about the new invoice"
      },
      "typeVersion": 1
    },
    {
      "id": "09ccbef2-8aa7-4b19-8e8b-86d6aa647298",
      "name": "Notify the team",
      "type": "n8n-nodes-base.slack",
      "position": [
        1264,
        240
      ],
      "parameters": {
        "text": "=<!channel> A new invoice with the below details have bene created:\n*Invoice Number:* {{ $json.InvoiceNumber }}\n*Amount Due:* {{ $json.AmountDue }} ({{ $json.CurrencyCode }})\n*Status:* {{ $json.Status }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#test"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f403ca7a-cd06-4122-ab76-c7cbc0f93d93",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Update contact",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create new contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format data": {
      "main": [
        [
          {
            "node": "Check if the customer exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update contact": {
      "main": [
        [
          {
            "node": "Create the invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Create new contact": {
      "main": [
        [
          {
            "node": "Create the invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create the invoice": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          },
          {
            "node": "Notify the team",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive form submission": {
      "main": [
        [
          {
            "node": "Format data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if the customer exists": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow automates the entire process of receiving a product/service order, checking or creating a customer in Xero, generating an invoice, emailing it, and notifying the sales team for example (via Slack) — all triggered by a form submission (via Jotform). Receive…

Source: https://n8n.io/workflows/9796/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This n8n workflow orchestrates a powerful suite of AI Agents and automations to manage and optimize various aspects of an e-commerce operation, particularly for platforms like Shopify. It leverages La

Google Sheets, HTTP Request, Slack +10
AI & RAG

This workflow transforms natural language queries into research reports through a five-stage AI pipeline. When triggered via webhook (typically from Google Sheets using the companion [](https://gist.g

Redis, Agent, Output Parser Structured +7
AI & RAG

This workflow automates the entire process of receiving a product/service order, checking or creating a customer in Xero, generating an invoice, emailing it — all triggered by a form submission (via J

Xero, Agent, OpenAI Chat +2
AI & RAG

This workflow automates customer feedback processing by analyzing sentiment, identifying key issues, generating personalized responses, and escalating critical cases to support teams when required. De

Redis, Postgres, Agent +7
AI & RAG

This workflow automates inventory management and customer engagement for e-commerce businesses and retail operations managing multiple product categories. It solves the critical challenge of maintaini

Agent, OpenAI Chat, Output Parser Structured +3