mirror of
https://github.com/khoaliber/n8nworkflows.xyz.git
synced 2026-04-19 17:14:37 +00:00
1 line
12 KiB
JSON
1 line
12 KiB
JSON
{"id":"eOgIRm4wzZec7jkD","meta":{"instanceId":"061ca141d020a6e1355b8c7fe05f92a699e37e92079ad2e150a506ee8bbe9e11","templateCredsSetupCompleted":true},"name":"AI Invoice Agent","tags":[],"nodes":[{"id":"a3c4602c-fde7-4fed-9f6b-71a08a51f9ce","name":"When clicking ‘Execute workflow’","type":"n8n-nodes-base.manualTrigger","position":[-2944,448],"parameters":{},"typeVersion":1},{"id":"89a82cb6-c972-4a06-9f7e-29e3f322ad89","name":"Google Sheets","type":"n8n-nodes-base.googleSheets","position":[-2752,448],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1d7CWcM_Ge6s2iaoGXOsxykLQFsDa_iyEFyP0qxJ9Qbs/edit#gid=0","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"list","value":"1d7CWcM_Ge6s2iaoGXOsxykLQFsDa_iyEFyP0qxJ9Qbs","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1d7CWcM_Ge6s2iaoGXOsxykLQFsDa_iyEFyP0qxJ9Qbs/edit?usp=drivesdk","cachedResultName":"Client Invoices"}},"typeVersion":4.6},{"id":"95b66133-04fe-42fd-b906-8e742efa1b27","name":"Filter","type":"n8n-nodes-base.filter","position":[-2528,448],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"afe0ae0a-9f88-4605-b064-223db0c34522","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.Status }}","rightValue":"Pending"}]}},"typeVersion":2.2},{"id":"2ab041df-a151-4eb7-b38d-b75b4c76fa91","name":"Edit Fields","type":"n8n-nodes-base.set","position":[-2304,448],"parameters":{"options":{},"assignments":{"assignments":[{"id":"eae2796d-a5bb-4bc1-a4f6-26abc64e2185","name":"\tInvoice ID","type":"string","value":"={{ $json['\tInvoice ID'] }}"},{"id":"72f18799-575f-4c4c-9f67-02a9dc9a45ab","name":"Client Name","type":"string","value":"={{ $json['Client Name'] }}"},{"id":"66338ec2-a287-4319-b0a2-89c6e2915d07","name":"Client Address","type":"string","value":"={{ $json['Client Address'] }}"},{"id":"9e9dceea-5fe0-4be8-8ddb-826b9e569dea","name":"Project Name\t","type":"string","value":"={{ $json['Project Name\t'] }}"},{"id":"82d90cd2-1075-41d0-a251-242498884069","name":"Amount (USD)","type":"number","value":"={{ $json['Amount (USD)'] }}"},{"id":"b84b6393-bfc2-494a-b8e1-3f918734088f","name":"Invoice Date","type":"string","value":"={{ $now.format('yyyy-MM-dd') }}"},{"id":"889bc329-2802-4670-8d0e-88e97f25be65","name":"Due Date","type":"string","value":"={{ $now.plus({day: 7}).format('yyyy-MM-dd') }}"}]}},"typeVersion":3.4},{"id":"bab29942-290c-43f0-940f-0a6a2553ba97","name":"Loop Over Items","type":"n8n-nodes-base.splitInBatches","position":[-2080,448],"parameters":{"options":{}},"typeVersion":3},{"id":"fe9ce649-2590-4569-879e-1933f32ddf57","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[-1760,208],"parameters":{"text":"=You are a professional invoicing assistant for a creative agency called \"Upward Engine\". Generate a polite, professional email to a client who has received an invoice as a PDF attachment. Include the client name, project name, invoice amount, invoice ID, invoice date, and due date.\n\nThe tone should be friendly but business-oriented, and the purpose is to inform the client that the invoice is attached, and to kindly request timely payment. End with a thank-you message and sign off as \"Upward Engine Team\".\n\nHere is the invoice data:\n- Client name: {{ $json['Client Name'] }}\n- Project Name: {{ $json['Project Name\t'] }}\n- Invoice Amount: {{ $json['Amount (USD)'] }}\n- Invoice ID: {{ $json['\tInvoice ID'] }}\n- Invoice Date: {{ $json['Invoice Date'] }}\n- Due Date: {{ $json['Due Date'] }}","options":{},"promptType":"define"},"typeVersion":2},{"id":"f6d889e9-5bf0-48a7-8562-bd45ced618fc","name":"Information Extractor","type":"@n8n/n8n-nodes-langchain.informationExtractor","position":[-1424,208],"parameters":{"text":"={{ $json.output }}","options":{},"attributes":{"attributes":[{"name":"email subject","description":"subject of the mail"},{"name":"email body","description":"email body without the subject"}]}},"typeVersion":1.2},{"id":"012075eb-1e97-4d49-9b36-2a2e22ccdbdc","name":"CraftMyPDF","type":"n8n-nodes-craftmypdf.craftMyPdf","position":[-1072,352],"parameters":{"data":"={\n\"company_name\": \"Upward Engine\",\n \"company_address\": \"Silicon Valey, USA\",\n \"company_email\": \"admin@upwardengine.com\",\n \"bill_to\": \"{{ $('Edit Fields').item.json['Client Name'] }}\",\n \"bill_to_address\": \"{{ $('Edit Fields').item.json['Client Address'] }}\",\n \"invoice_no\": \"{{ $('Edit Fields').item.json['\tInvoice ID'] }}\",\n \"invoice_date\": \"{{ $('Edit Fields').item.json['Invoice Date'] }}\",\n \"invoice_due_date\": \"{{ $('Edit Fields').item.json['Due Date'] }}\",\n \"footer\": \"Thank you for working with Upward Engine\",\n \"balance\": \"{{ $('Edit Fields').item.json['Amount (USD)'] }}\",\n \"project_name\": \"{{ $('Edit Fields').item.json['Project Name\t'] }}\",\n \"currency\": \"$\"\n\n}","resource":"pdf","templateId":"YOUR_TEMPLATE_ID","export_type":"file"},"typeVersion":1},{"id":"8f9cbcf4-0162-41ba-8934-3a2490e213bb","name":"Gmail","type":"n8n-nodes-base.gmail","position":[-848,352],"webhookId":"85f9cc55-4019-4f9f-a7b8-852ba7f38d1b","parameters":{"sendTo":"={{ $('Google Sheets').item.json['Client Email'] }}","message":"={{ $('Information Extractor').item.json.output['email body'] }}","options":{"attachmentsUi":{"attachmentsBinary":[{"property":"output.pdf"}]},"appendAttribution":false},"subject":"={{ $('Information Extractor').item.json.output['email subject'] }}","emailType":"text"},"typeVersion":2.1},{"id":"d2249aba-b9ef-451b-9646-e529836c38aa","name":"Google Sheets1","type":"n8n-nodes-base.googleSheets","position":[-608,448],"parameters":{"columns":{"value":{"Status":"Completed","Due Date":"={{ $('Edit Fields').item.json['Due Date'] }}","\tInvoice ID":"={{ $('Edit Fields').item.json['\tInvoice ID'] }}","Invoice Date":"={{ $('Edit Fields').item.json['Invoice Date'] }}"},"schema":[{"id":"\tInvoice ID","type":"string","display":true,"removed":false,"required":false,"displayName":"\tInvoice ID","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Client Name","type":"string","display":true,"required":false,"displayName":"Client Name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Client Email","type":"string","display":true,"required":false,"displayName":"Client Email","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Client Address","type":"string","display":true,"required":false,"displayName":"Client Address","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Project Name\t","type":"string","display":true,"required":false,"displayName":"Project Name\t","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Amount (USD)","type":"string","display":true,"required":false,"displayName":"Amount (USD)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Status","type":"string","display":true,"required":false,"displayName":"Status","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Invoice Date","type":"string","display":true,"required":false,"displayName":"Invoice Date","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Due Date","type":"string","display":true,"required":false,"displayName":"Due Date","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":["\tInvoice ID"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"appendOrUpdate","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1d7CWcM_Ge6s2iaoGXOsxykLQFsDa_iyEFyP0qxJ9Qbs/edit#gid=0","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"list","value":"1d7CWcM_Ge6s2iaoGXOsxykLQFsDa_iyEFyP0qxJ9Qbs","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1d7CWcM_Ge6s2iaoGXOsxykLQFsDa_iyEFyP0qxJ9Qbs/edit?usp=drivesdk","cachedResultName":"Client Invoices"}},"typeVersion":4.6},{"id":"499dbf0b-3c1a-4a86-930e-d792834635d2","name":"GPT - 4.1 mini","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-1584,480],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4.1-mini"},"options":{}},"credentials":{"openAiApi":{"id":"YmJZYHbn92LbB3C0","name":"OpenAi account"}},"typeVersion":1.2},{"id":"81872408-4ad6-4bf7-8f45-aecfd9dadddd","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-4000,-320],"parameters":{"color":2,"width":912,"height":1152,"content":"✅ Make sure **CraftMyPDF** node is installed in your n8n otherwise it will show error. If first time it doesn't shows the **CraftMyPDF** node then install it then delete the complete workflow and reuse/reupload the workflow again:\n\n---\n\n# 🛠 Setup Guide\n\nFollow these steps to get started:\n\n1. **Prepare your Google Sheet**\n\n * Connect your **Client Invoices** sheet in the **Google Sheets** node.\n * Make sure the sheet has columns like: *Invoice ID, Client Name, Client Email, Client Address, Project Name, Amount (USD), Status, Invoice Date, Due Date*.\n * This sheet will store invoice data and track payment status.\n\n2. **Filter pending invoices**\n\n * The **Filter** node only processes rows where `Status = Pending`.\n * Update invoice data accordingly before running the workflow.\n\n3. **Edit invoice fields**\n\n * The **Edit Fields** node automatically sets the `Invoice Date` to today and calculates a `Due Date` (7 days later).\n * It also maps client info and project details from the sheet.\n\n4. **Generate the client email draft**\n\n * The **AI Agent** creates a polite, professional email using your invoice details.\n * The **Information Extractor** separates the subject and body for structured email sending.\n\n5. **Create the invoice PDF**\n\n * Connect your [CraftMyPDF](https://craftmypdf.com/) account and replace `YOUR_TEMPLATE_ID` with your template.\n * The invoice includes company info, client details, project name, invoice amount, and payment due date.\n\n6. **Send the invoice email**\n\n * Connect your **Gmail** account in the **Gmail** node.\n * It sends the AI-generated email with the invoice PDF attached to the client’s email.\n\n7. **Update invoice status in Google Sheets**\n\n * After sending, the **Google Sheets1** node updates the row by marking the invoice `Status` as **Completed** along with invoice and due dates.\n\nOnce set up, this workflow will **automatically generate invoices, send them via email with PDFs attached, and update your sheet** 📩📊\n\n---\n"},"typeVersion":1},{"id":"a036c3db-df20-49a6-a42d-93559a8f245a","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-2992,-304],"parameters":{"color":2,"width":480,"height":448,"content":"## Start here: Step-by Step Youtube Tutorial :star:\n[](https://youtu.be/r8Cg7hTMFdg)"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"71a433b1-d1c0-432b-942d-a7c45cf021e4","connections":{"Gmail":{"main":[[{"node":"Google Sheets1","type":"main","index":0}]]},"Filter":{"main":[[{"node":"Edit Fields","type":"main","index":0}]]},"AI Agent":{"main":[[{"node":"Information Extractor","type":"main","index":0}]]},"CraftMyPDF":{"main":[[{"node":"Gmail","type":"main","index":0}]]},"Edit Fields":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Google Sheets":{"main":[[{"node":"Filter","type":"main","index":0}]]},"GPT - 4.1 mini":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0},{"node":"Information Extractor","type":"ai_languageModel","index":0}]]},"Google Sheets1":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Loop Over Items":{"main":[[],[{"node":"AI Agent","type":"main","index":0}]]},"Information Extractor":{"main":[[{"node":"CraftMyPDF","type":"main","index":0}]]},"When clicking ‘Execute workflow’":{"main":[[{"node":"Google Sheets","type":"main","index":0}]]}}} |