The purpose of this self-hosted n8n workflow is to automate the process of invoice creation and PDF formatting. In simple terms, this workflow use the Gmail API to check for new emails, the OpenAI API to extract and process hand-written work log entries, Google Sheets API to update an invoice template with formatted invoice data, Google Drive to create and download a PDF report, and lastly, it sends the final invoice PDF to the a specific recipient.
- When a new email that meets your criteria arrives, the Gmail Trigger is activated.
- OpenAI Node: Transforms email content into structured JSON invoice entries by sending it to GPT-4.1-NANO with a predefined configuration prompt.
- Code Node: Parses text string from the ChatGPT node to JSON format.
- Clear + Update in Google Sheets: Clears out an invoice template in Google Drive before updating it with new parsed data entries.
- Google Drive (Download): Gets a Google Sheet formatted to PDF sent to the the recipient that meeets your criteria.
- OpenAI API Key
- Google Sheets, Drive, and Gmail (OAuth2 or App Passwords)
- Google Sheet ID (in Sheets node)
- Gmail “To” and “From” fields (in Send and trigger nodes)
- This workflow runs fully on a self-hosted n8n instance.
- You can host this workflow on the cloud for free. I used this tutorial: Setting up a free n8n server on Oracle Cloud