AI-Powered Invoice and Email Generation System - n8n Workflow

Automate your client invoicing process using this powerful n8n workflow. It reads pending invoice data from Google Sheets, uses an AI agent to craft professional emails, generates PDF documents via CraftMyPDF, and sends them via the Gmail n8n node, saving hours of manual work.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Small business owners or freelancers needing to automate billing.

  • Administrative staff looking to streamline invoice distribution and tracking.

  • Users searching for robust n8n templates integrating AI, PDF generation, and core business services.

  • Developers interested in leveraging the LangChain n8n node for structured email content creation.

Overview

Manually tracking pending invoices, drafting personalized emails, and generating PDFs is time-consuming and prone to errors. This comprehensive n8n workflow template eliminates manual effort by fully automating the invoice delivery cycle. The system starts by querying your 'Client Invoices' Google Sheet for items marked 'Pending'. It then uses dynamic data to power an AI Agent that writes a polite, professional payment request email. Simultaneously, the workflow generates a professional PDF invoice attachment. The final steps involve sending the compiled email and PDF via Gmail and automatically updating the Google Sheet record to 'Completed'. This powerful integration showcases how sophisticated n8n automation can transform back-office operations.

How it Works

The entire process is initiated by an n8n trigger and operates on a per-item basis for reliability.


  1. Trigger and Data Extraction: The workflow starts with a manual n8n trigger. It immediately connects to the primary Google Sheets n8n node to retrieve all records from the 'Client Invoices' spreadsheet.

  2. Filtering Pending Invoices: The Filter n8n node isolates only those rows where the 'Status' column is marked 'Pending', ensuring only outstanding invoices are processed.

  3. Data Enrichment: The Edit Fields n8n node calculates the current 'Invoice Date' and a future 'Due Date' (set 7 days ahead) and prepares all necessary client data for subsequent AI and PDF steps.

  4. Batch Processing: The Loop Over Items n8n node splits the filtered list into single batches, allowing the downstream steps (AI, PDF, Email) to process each invoice sequentially.

  5. AI Email Drafting: The AI Agent n8n node receives the specific invoice details (client name, amount, ID, project) and uses a predefined system prompt (powered by the connected GPT-4.1 mini n8n node) to generate a complete, professional email draft.

  6. Structured Content Extraction: The Information Extractor n8n node processes the AI agent's raw text output and cleanly separates it into dedicated 'email subject' and 'email body' variables.

  7. PDF Generation: The CraftMyPDF n8n node uses the rich invoice data from the workflow context to populate a designated PDF template, generating the binary invoice file.

  8. Email Delivery: The Gmail n8n node sends the email, using the extracted subject and body, and attaching the newly generated PDF file to the specified 'Client Email'.

  9. Status Update: Finally, the second Google Sheets n8n node updates the original row, matching by the Invoice ID, and sets the 'Status' to 'Completed' to prevent reprocessing in the next run of the n8n workflow.

Installation Guide

To deploy and utilize this n8n workflow template effectively, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON data and import it directly into your n8n instance via the 'Workflows' section.

  2. Google Sheets Setup: Configure both Google Sheets n8n nodes (the initial read node and the final update node). Ensure they point to your correct 'Client Invoices' spreadsheet and that your credentials are set up for read/write access.

  3. OpenAI/LLM Configuration: Update the credentials for the GPT - 4.1 mini n8n node (or equivalent large language model). This is necessary for the AI Agent to function.

  4. CraftMyPDF Integration: Install the CraftMyPDF community n8n node if it's not already present. You must obtain an API key and replace the placeholder YOURTEMPLATEID with the ID of your invoice template on the CraftMyPDF platform. This is crucial for successful PDF generation.

  5. Gmail Connection: Set up the credentials for the Gmail n8n node so that the workflow can send emails on your behalf.

  6. Activation: Once all credentials and external IDs are updated, activate the n8n workflow. Use the Manual Trigger n8n node to test the initial execution.

Node Details

Manual Trigger (n8n trigger): Starts the n8n workflow execution, typically used for testing or scheduled runs.
Google Sheets (Initial Read): Reads data from the 'Client Invoices' sheet. Key configuration: Reads all rows to find pending status.
Filter (n8n node): Filters items to retain only those where Status is 'Pending'. This is essential for controlling the data flow of the n8n workflow.
Edit Fields (Set n8n node): Dynamically sets the Invoice Date to $now and Due Date to 7 days after the invoice date.
Loop Over Items (n8n node): Ensures that the AI and PDF generation steps are run individually for each pending invoice item.
AI Agent (LangChain n8n node): Generates the full, professional email text based on a detailed prompt and dynamically injected invoice data. It utilizes the connected OpenAI LLM.
Information Extractor (LangChain n8n node): A powerful LangChain n8n node that structures the raw email output into specific JSON fields: email subject and email body.
CraftMyPDF (n8n node): Generates the PDF invoice binary file using the collected client and financial data against a configured template ID.
Gmail (n8n node): Sends the final email to the client, utilizing the AI-generated subject and body, and attaching the binary PDF file.
Google Sheets1 (Update): An essential final step in this n8n workflow. It uses the appendOrUpdate operation, matching by Invoice ID, to mark the processed invoice status as 'Completed'.

Related n8n Workflows

Free

Nodes: 11 Nodes
Updated: December 26 2025
View all
Created by

Featured*