{
  "name": "Generate invoices and send AI-powered reminders with Jotform and Xero",
  "nodes": [
    {
      "id": "d7858d88-bccd-4bbb-8de0-c7ba96d74263",
      "name": "Receive form submission",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -464,
        0
      ]
    },
    {
      "id": "267003ec-6e40-4a33-bacc-2244c8e43b64",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        -112
      ],
      "parameters": {
        "width": 256,
        "height": 320,
        "content": "## Receive Submission\nReceives the product/service form submission from Jotform"
      }
    },
    {
      "id": "8ee7dc1e-86bf-4bec-b8b6-7b97889eab6b",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        64,
        -112
      ],
      "parameters": {
        "width": 288,
        "height": 320,
        "content": "## Create/Update Contact\nCreates or updates the contact"
      }
    },
    {
      "id": "a14a8305-8c22-4213-9414-861019d3ae69",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        -112
      ],
      "parameters": {
        "width": 256,
        "height": 320,
        "content": "## Create The Invoice\nCreates a new invoice for that contact"
      }
    },
    {
      "id": "77f6b18b-004e-4e00-8de2-54194fdd9a47",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1488,
        -400
      ],
      "parameters": {
        "width": 896,
        "height": 1200,
        "content": "## Generate Invoices and Send Reminders for Customers with Jotform and Xero\nThis workflow automates the entire process of receiving a product/service order, checking or creating a customer in **Xero**"
      }
    },
    {
      "id": "79c58923-f8c3-4054-93ca-c2de89ff7306",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -112
      ],
      "parameters": {
        "width": 256,
        "height": 320,
        "content": "## Format Data\nFormats the data thus making it easier to be used in other nodes"
      }
    },
    {
      "id": "e495d2d4-3f6d-482a-bb95-7a4dfdbd5dba",
      "name": "Format data",
      "type": "n8n-nodes-base.code",
      "position": [
        -160,
        0
      ]
    },
    {
      "id": "9153a6f7-10d8-44f6-976b-b0abdaf5fd20",
      "name": "Create/Update the contact",
      "type": "n8n-nodes-base.xero",
      "position": [
        160,
        0
      ]
    },
    {
      "id": "15e1d23a-3c96-4037-83cd-97004e6aebe8",
      "name": "Create the invoice",
      "type": "n8n-nodes-base.xero",
      "position": [
        480,
        0
      ]
    },
    {
      "id": "2831fd4c-313c-4b63-b6d0-6b36428ae778",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        816,
        -432
      ]
    },
    {
      "id": "3436d1ca-18bf-4929-982a-89fa802ff015",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        816,
        -224
      ]
    },
    {
      "id": "5dbc3862-69b4-4174-8952-635f386cb81c",
      "name": "Sticky Note19",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        -560
      ],
      "parameters": {
        "width": 592,
        "height": 480,
        "content": "## Send The Invoice\nSends the newly created invoice for that customer(via email)"
      }
    },
    {
      "id": "8add409c-adb4-4d9b-9e6a-0db66e17093e",
      "name": "Send email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1088,
        -432
      ]
    },
    {
      "id": "d5ebc764-96f4-41e5-a5dd-ecc8b69470c5",
      "name": "Add reminders config",
      "type": "n8n-nodes-base.set",
      "position": [
        800,
        320
      ]
    },
    {
      "id": "f40da212-3f17-426d-bc58-5348b4488d9d",
      "name": "Send reminder email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2768,
        688
      ]
    },
    {
      "id": "e220b58d-04f9-483a-90b0-e196b8088bd1",
      "name": "Insert invoice id to DB",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1504,
        128
      ]
    },
    {
      "id": "ae2c88cb-764a-48be-bec0-c172dcf1732e",
      "name": "Get Invoices",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1504,
        496
      ]
    },
    {
      "id": "56a479b9-6fc2-4ad8-8a09-7bfd76c5da81",
      "name": "If2",
      "type": "n8n-nodes-base.if",
      "position": [
        1152,
        320
      ]
    },
    {
      "id": "fc86c9e1-0f12-47a8-893c-4a2479207702",
      "name": "Send reminders sent summary",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2848,
        160
      ]
    },
    {
      "id": "a1b465b8-6884-4878-ab45-81731cc11306",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        2512,
        736
      ]
    },
    {
      "id": "90f88e6b-c967-4ac7-b11a-4e86be5b9e40",
      "name": "Schedule reminders trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        384,
        544
      ]
    },
    {
      "id": "5a708503-da01-49d5-af64-5b190f61bcb3",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        416
      ],
      "parameters": {
        "width": 304,
        "height": 320,
        "content": "## Schedule Trigger\nSchedules reminders trigger daily at 8 AM"
      }
    },
    {
      "id": "8f75c160-2d8e-4391-8d73-166a96fc7566",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        144
      ],
      "parameters": {
        "width": 304,
        "height": 368,
        "content": "## Add Reminders Config\nAdds reminders config details like `intervals in days` so first reminder will be sent after 2 days, second one after 3 days and final one after 5 days"
      }
    },
    {
      "id": "9fbe84fe-3ed0-479c-ab9d-fc7d2a7bfff0",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1056,
        144
      ],
      "parameters": {
        "width": 304,
        "height": 368,
        "content": "## Check Trigger\nChecks if the previous node has been executed by the above workflow or by the schedule trigger"
      }
    },
    {
      "id": "362c4c03-bd7f-4130-8e0c-060ad5e6957e",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1408,
        -32
      ],
      "parameters": {
        "width": 304,
        "height": 336,
        "content": "## Insert Invoice To DB\nInserts newly created invoice needed details to DB so customer will be notified later on about the invoice"
      }
    },
    {
      "id": "6703f7ec-7901-4d28-9330-ef2ec277df60",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1408,
        352
      ],
      "parameters": {
        "width": 304,
        "height": 336,
        "content": "## Get All Invoices\nGets all the invoices from DB"
      }
    },
    {
      "id": "aa2278cb-85aa-4038-b837-bbf085b9b245",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1760,
        368
      ],
      "parameters": {
        "width": 304,
        "height": 320,
        "content": "## Loop Over Invoices\nLoops over invoices one by one"
      }
    },
    {
      "id": "2620e88d-9c4a-418a-b378-f81aad2f991f",
      "name": "Loop over invoices",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1856,
        496
      ]
    },
    {
      "id": "67f18351-969d-4489-89c7-b77a2d4ff283",
      "name": "Sticky Note17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2112,
        160
      ],
      "parameters": {
        "width": 304,
        "height": 352,
        "content": "## Get Sent Reminders\nGets today's sent reminders from DB"
      }
    },
    {
      "id": "1c001fdd-4d76-4243-94f0-a93ed84b2cfa",
      "name": "Sticky Note18",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2112,
        560
      ],
      "parameters": {
        "width": 304,
        "height": 368,
        "content": "## Get Invoice Details\nGets the invoice details from Xero so we know whether or not any changes have been made or not"
      }
    },
    {
      "id": "5949d37a-037b-4292-bbd4-722efc81d0a6",
      "name": "Get today's sent reminders",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        2208,
        304
      ]
    },
    {
      "id": "f55fd793-3299-4ca7-ab12-6b73a2df3706",
      "name": "Increase sent reminders",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        2976,
        688
      ]
    },
    {
      "id": "6bb0af0e-dc3d-438e-b811-ee897ccddd74",
      "name": "Delete invoice",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3456,
        848
      ]
    },
    {
      "id": "ad8ba6c6-d1f4-4329-90ea-b5f39ee7e37f",
      "name": "If3",
      "type": "n8n-nodes-base.if",
      "position": [
        3184,
        688
      ]
    },
    {
      "id": "1e7c11be-4898-4d65-bec2-836d6d769849",
      "name": "Sticky Note20",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2464,
        560
      ],
      "parameters": {
        "width": 1184,
        "height": 480,
        "content": "## Send Reminders Logic\nThe logic that decides whether or not to send a reminder email now, skip it and send it later or delete the invoice/s from DB (because all the reminders have been sent or the i"
      }
    },
    {
      "id": "54b8f2b7-c849-48cb-9483-0d0a614575df",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2576,
        160
      ]
    },
    {
      "id": "a8aeb3a0-f1fd-4038-9899-a7debeb396a3",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2576,
        368
      ]
    },
    {
      "id": "73ba208d-4c77-47f7-8a6c-b8d8d7e89ed8",
      "name": "Sticky Note21",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2464,
        32
      ],
      "parameters": {
        "width": 592,
        "height": 480,
        "content": "## Summarize Sent Reminders & Send An Email\nSummarizes today's sent reminders using AI and send a summery email to the team like sales team or finance team"
      }
    },
    {
      "id": "a603f1f4-ca24-4c3d-b2bb-0209d999c05f",
      "name": "Get the invoice",
      "type": "n8n-nodes-base.xero",
      "position": [
        2208,
        720
      ]
    }
  ],
  "connections": {
    "If2": {
      "main": [
        [
          {
            "node": "Insert invoice id to DB",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If3": {
      "main": [
        [
          {
            "node": "Delete invoice",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop over invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Send reminder email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Delete invoice",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop over invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Send reminders sent summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format data": {
      "main": [
        [
          {
            "node": "Create/Update the contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Invoices": {
      "main": [
        [
          {
            "node": "Loop over invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete invoice": {
      "main": [
        [
          {
            "node": "Loop over invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get the invoice": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Create the invoice": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          },
          {
            "node": "Add reminders config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop over invoices": {
      "main": [
        [
          {
            "node": "Get today's sent reminders",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get the invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Send reminder email": {
      "main": [
        [
          {
            "node": "Increase sent reminders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add reminders config": {
      "main": [
        [
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Increase sent reminders": {
      "main": [
        [
          {
            "node": "If3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive form submission": {
      "main": [
        [
          {
            "node": "Format data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create/Update the contact": {
      "main": [
        [
          {
            "node": "Create the invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get today's sent reminders": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule reminders trigger": {
      "main": [
        [
          {
            "node": "Add reminders config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}