OpenAIとGoogleテーブルを使ったPDF請求書処理と承認プロセスの自動化
これはFinance, AI分野の自動化ワークフローで、17個のノードを含みます。主にIf, Gmail, FormTrigger, GoogleDrive, GmailTriggerなどのノードを使用、AI技術を活用したスマート自動化を実現。 PDF請求書の自動処理と承認フロー、OpenAIおよびGoogleスプレッドシートを使用
- •Googleアカウント + Gmail API認証情報
- •Google Drive API認証情報
- •Google Sheets API認証情報
- •OpenAI API Key
使用ノード (17)
{
"meta": {
"instanceId": "d1786ab0d745a7498abf13a9c2cdabb1374c006e889b79eef64ce0386b8f8a41",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "32dec238-615e-461d-ac9b-e09bdcb2a73f",
"name": "OpenAI チャットモデル",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
560,
200
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "MGwGMKEkdcjzlYCw",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "4cb973bc-385f-42db-b79e-942c75d97a84",
"name": "構造化出力パーサー",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
780,
200
],
"parameters": {
"jsonSchemaExample": "{\n \"invoice_number\": \"\",\n \"invoice_date\": \"\",\n \"due_date\": \"\",\n \"vendor_name\": \"\",\n \"total_amount\": \"\",\n \"currency\": \"\",\n \"items\": [\n {\n \"description\": \"\",\n \"amount\": \"\"\n }\n ],\n \"tax\": \"\",\n \"category\": \"\"\n}"
},
"typeVersion": 1.2
},
{
"id": "b7ed6cf6-e965-43e0-abab-919ab598e62a",
"name": "Invoice Folder Monitor",
"type": "n8n-nodes-base.googleDriveTrigger",
"position": [
-100,
-220
],
"parameters": {
"event": "fileCreated",
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"triggerOn": "specificFolder",
"folderToWatch": {
"__rl": true,
"mode": "id",
"value": "1KJ4fvXcKVMGJunsKvPYf8PkX5K9SVwFk"
}
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "SEUhrgz30NMJS3cH",
"name": "Google Drive account"
}
},
"typeVersion": 1
},
{
"id": "d2a0d543-1ee3-4852-9751-69aae3b9864a",
"name": "Download Invoice PDF",
"type": "n8n-nodes-base.googleDrive",
"position": [
100,
-220
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.id }}"
},
"options": {},
"operation": "download"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "SEUhrgz30NMJS3cH",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "80345f83-02fa-47ab-86f0-1e01bd3429e7",
"name": "Invoice Parser AI エージェント",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
580,
0
],
"parameters": {
"text": "=You are an intelligent invoice parser. I will give you raw text extracted from a PDF invoice. \n\n========================\nSTART OF RAW INVOICE TEXT\n\n{{ $json.text }}\n\nEND OF RAW INVOICE TEXT\n========================\n\nYour job is to:\n\n1. Extract key information from the invoice such as:\n - invoice_number\n - invoice_date\n - due_date (if available)\n - vendor_name\n - total_amount\n - currency (e.g., USD, IDR, etc.)\n - items (as a list of item descriptions and their amounts)\n - tax (if available)\n\n2. Detect the invoice **category**, such as:\n - Utilities\n - Office Supplies\n - Travel\n - Software\n - Food & Beverage\n - Others (if unknown)\n\n3. Return the result in this exact JSON format:\n\n```json\n{\n \"invoice_number\": \"\",\n \"invoice_date\": \"\",\n \"due_date\": \"\",\n \"vendor_name\": \"\",\n \"total_amount\": \"\",\n \"currency\": \"\",\n \"items\": [\n {\n \"description\": \"\",\n \"amount\": \"\"\n }\n ],\n \"tax\": \"\",\n \"category\": \"\"\n}\n",
"options": {},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 1.9
},
{
"id": "57649f6a-2d4d-4072-92bd-ffea26fdd4dd",
"name": "Insert Invoice Data",
"type": "n8n-nodes-base.googleSheets",
"position": [
1460,
0
],
"parameters": {
"columns": {
"value": {
"Tax": "={{ $('Invoice Parser AI Agent').item.json.output.tax }}",
"Items": "={{ $('Invoice Parser AI Agent').item.json.output.items }}",
"Approved": "={{ $json.data['Approve Invoice?'] }}",
"Category": "={{ $('Invoice Parser AI Agent').item.json.output.category }}",
"Currency": "={{ $('Invoice Parser AI Agent').item.json.output.currency }}",
"Due Date": "={{ $('Invoice Parser AI Agent').item.json.output.due_date }}",
"Reviewed By": "={{ $json.data['Reviewed By'] }}",
"Vendor Name": "={{ $('Invoice Parser AI Agent').item.json.output.vendor_name }}",
"Invoice Date": "={{ $('Invoice Parser AI Agent').item.json.output.invoice_date }}",
"Total Amount": "={{ $('Invoice Parser AI Agent').item.json.output.total_amount }}",
"Approval Notes": "={{ $json.data['Approval Notes'] }}",
"Invoice Number": "={{ $('Invoice Parser AI Agent').item.json.output.invoice_number }}"
},
"schema": [
{
"id": "Invoice Number",
"type": "string",
"display": true,
"required": false,
"displayName": "Invoice Number",
"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
},
{
"id": "Vendor Name",
"type": "string",
"display": true,
"required": false,
"displayName": "Vendor Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Total Amount",
"type": "string",
"display": true,
"required": false,
"displayName": "Total Amount",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Currency",
"type": "string",
"display": true,
"required": false,
"displayName": "Currency",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Items",
"type": "string",
"display": true,
"required": false,
"displayName": "Items",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Tax",
"type": "string",
"display": true,
"required": false,
"displayName": "Tax",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Category",
"type": "string",
"display": true,
"required": false,
"displayName": "Category",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Approved",
"type": "string",
"display": true,
"required": false,
"displayName": "Approved",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Approval Notes",
"type": "string",
"display": true,
"required": false,
"displayName": "Approval Notes",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Reviewed By",
"type": "string",
"display": true,
"required": false,
"displayName": "Reviewed By",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ueJfN5dFTXY3_AdvnYUL5_RjV9YwSFvbxwA_ivtqnJk/edit#gid=0",
"cachedResultName": "Invoices"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1ueJfN5dFTXY3_AdvnYUL5_RjV9YwSFvbxwA_ivtqnJk",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ueJfN5dFTXY3_AdvnYUL5_RjV9YwSFvbxwA_ivtqnJk/edit?usp=drivesdk",
"cachedResultName": "Copy of PDF Invoice Parser - n8n template"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "ypmzFxQFfAacuVVC",
"name": "Google Sheets account"
}
},
"typeVersion": 4.5
},
{
"id": "2993f865-d46c-489b-ab34-3c62b2c3cb1f",
"name": "付箋2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-460,
-220
],
"parameters": {
"color": 4,
"width": 280,
"height": 500,
"content": "## SETUP REQUIRED\n\nGoogle Sheets Structure:\nSheet: \"Invoices\"\n• Column A: Invoice Number \n• Column B: Invoice Date \n• Column C: Due Date \n• Column D: Vendor Name \n• Column E: Total Amount \n• Column F: Currency \n• Column G: Items \n• Column H: Tax \n• Column I: Category \n• Column J: Approved\n• Column K: Approval Notes\n• Column L: Reviewed By\n\nRequired Credentials:\n• Google Drive Credential \n• Gmail Credential \n• Google Sheets Credential \n• OpenAI API Key (GPT-4)\n"
},
"typeVersion": 1
},
{
"id": "691f4972-8d18-49fd-b8cd-0c6b2464b078",
"name": "付箋3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-120,
420
],
"parameters": {
"color": 5,
"width": 700,
"height": 560,
"content": "## 🧾 Automated PDF Invoice Processing & Approval Flow using OpenAI and Google Sheets\n\nWhat This Template Does:\n\n- Monitors **Google Drive**, **Gmail**, and a **web form** for incoming PDF invoices \n- Automatically downloads and extracts raw text from PDF attachments \n- Uses **GPT-4o-mini** to intelligently parse invoice data (invoice number, vendor, date, amount, tax, items, etc.) \n- Categorizes invoices into types such as *Utilities, Travel, Office Supplies, Food & Beverage, Others* \n- Sends a dynamic **approval request email** with an embedded decision form (Yes/No, reviewer name, notes) \n- Stores both approved and rejected invoice data into **Google Sheets** for recordkeeping \n- Sends rejection notifications to the finance team for follow-up \n- Provides a complete, automated approval pipeline with human oversight \n- Includes a structured JSON schema for consistent and error-free AI output \n- Polls input sources every minute to ensure timely and responsive processing \n- Ideal for businesses seeking to **automate their invoice approval and bookkeeping workflows** with AI\n\n"
},
"typeVersion": 1
},
{
"id": "2463666d-8c40-4821-b907-9741e62ce1e7",
"name": "付箋4",
"type": "n8n-nodes-base.stickyNote",
"position": [
620,
420
],
"parameters": {
"color": 5,
"width": 620,
"height": 620,
"content": "## 📋 WORKFLOW PROCESS OVERVIEW\n\n1. **Invoice Collection** \nInvoices are captured through three triggers: new PDFs in a Google Drive folder, incoming Gmail messages with PDF attachments, or direct uploads via a web form.\n\n2. **File Handling** \nIf uploaded via Drive, the PDF is downloaded using its file ID; if via Gmail or form, the PDF is already available as binary data.\n\n3. **Text Extraction** \nThe system extracts raw text from the PDF using the appropriate method based on its source (Drive, Email, or Form).\n\n4. **AI Data Parsing** \nGPT-4 processes the extracted text into structured JSON, identifying invoice details like vendor, date, amount, and categorizing the invoice.\n\n5. **Approval Request** \nAn email is sent to the reviewer with an approval form asking for a Yes/No decision along with optional notes.\n\n6. **Decision Routing** \nIf approved, the data moves forward for storage; if rejected, a notification is sent to the finance team.\n\n7. **Save Invoice Data** \nAll extracted and reviewed invoice data is saved into a Google Sheet, maintaining a full record of each invoice and its status.\n"
},
"typeVersion": 1
},
{
"id": "8483b8ef-83d7-4b3f-ad54-b9ec23efc911",
"name": "Send Invoice for Approval",
"type": "n8n-nodes-base.gmail",
"position": [
920,
0
],
"webhookId": "a23938a4-fc6c-4445-8dee-17e501e92e06",
"parameters": {
"sendTo": "replace_with_approver_email@yopmail.com",
"message": "=A new invoice has been submitted and requires your review and approval:",
"options": {},
"subject": "=[Action Required] Invoice Approval Request – {{ $json.output.vendor_name }}",
"operation": "sendAndWait",
"formFields": {
"values": [
{
"fieldType": "dropdown",
"fieldLabel": "Approve Invoice?",
"fieldOptions": {
"values": [
{
"option": "Yes"
},
{
"option": "No"
}
]
},
"requiredField": true
},
{
"fieldLabel": "Reviewed By",
"requiredField": true
},
{
"fieldType": "textarea",
"fieldLabel": "Approval Notes"
}
]
},
"responseType": "customForm"
},
"credentials": {
"gmailOAuth2": {
"id": "sWl7FFMkEUYBj0zM",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "0fece28b-13c8-4b0d-9c1b-84047a3503f6",
"name": "Monitor メール Attachments",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
100,
0
],
"parameters": {
"simple": false,
"filters": {},
"options": {
"downloadAttachments": true,
"dataPropertyAttachmentsPrefixName": "attachment_"
},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "sWl7FFMkEUYBj0zM",
"name": "Gmail account"
}
},
"typeVersion": 1.2
},
{
"id": "d210d1c5-865f-494e-a69c-d25ac462869b",
"name": "Upload Invoice (PDF) Form",
"type": "n8n-nodes-base.formTrigger",
"position": [
100,
200
],
"webhookId": "e033bea9-70e8-41e2-aea4-1b95714ea257",
"parameters": {
"options": {},
"formTitle": "Upload Invoice (PDF)",
"formFields": {
"values": [
{
"fieldType": "file",
"fieldLabel": "Upload",
"multipleFiles": false,
"requiredField": true,
"acceptFileTypes": ".pdf"
}
]
},
"formDescription": "Upload your invoice PDF using this form."
},
"typeVersion": 2.2
},
{
"id": "4703ddb5-1e07-43b9-a465-c9aced0ac9d8",
"name": "Extract Text from Drive PDF",
"type": "n8n-nodes-base.extractFromFile",
"position": [
300,
-220
],
"parameters": {
"options": {},
"operation": "pdf"
},
"typeVersion": 1
},
{
"id": "7ca78f71-8c1e-42e2-8686-08f2a9bfc009",
"name": "Extract Text from Email PDF",
"type": "n8n-nodes-base.extractFromFile",
"position": [
300,
0
],
"parameters": {
"options": {},
"operation": "pdf",
"binaryPropertyName": "attachment_0"
},
"typeVersion": 1
},
{
"id": "0b4aff7d-8c92-4964-a38c-996b546ed23a",
"name": "Extract Text from Form PDF",
"type": "n8n-nodes-base.extractFromFile",
"position": [
300,
200
],
"parameters": {
"options": {},
"operation": "pdf",
"binaryPropertyName": "Upload"
},
"typeVersion": 1
},
{
"id": "eef8e5e5-2b01-4ddd-8ea2-312fb41356de",
"name": "Check Approval Decision",
"type": "n8n-nodes-base.if",
"position": [
1180,
0
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "451bfdfc-f645-4e3c-91cc-895558f45b11",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.data['Approve Invoice?'] }}",
"rightValue": "Yes"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "ac5dd79d-9d32-44f9-8a9b-2cc45757110b",
"name": "Send Rejection Alert",
"type": "n8n-nodes-base.gmail",
"position": [
1320,
260
],
"webhookId": "1c33c42a-0d8e-466f-a424-faba306c56af",
"parameters": {
"sendTo": "finance_team@yopmail.com",
"message": "=Hi Finance Team,\n\nAn invoice from {{ $('Invoice Parser AI Agent').item.json.output.vendor_name }} has been disapproved during the approval process.\n\nReviewed By: {{ $('Send Invoice for Approval').item.json.data['Reviewed By'] }}\nApproval Notes: {{ $('Send Invoice for Approval').item.json.data['Approval Notes'] }}\n\nPlease review and follow up as needed.\n\nThank you,\nAutomated Invoice System\n\n",
"options": {
"appendAttribution": false
},
"subject": "=[Alert] Invoice Disapproved – {{ $('Invoice Parser AI Agent').item.json.output.vendor_name }}",
"emailType": "text"
},
"credentials": {
"gmailOAuth2": {
"id": "sWl7FFMkEUYBj0zM",
"name": "Gmail account"
}
},
"typeVersion": 2.1
}
],
"pinData": {
"Invoice Parser AI Agent": [
{
"output": {
"tax": "8.50",
"items": [
{
"amount": "85.00",
"description": "Web Design - This is a sample description..."
}
],
"category": "Others",
"currency": "USD",
"due_date": "January 31, 2016",
"vendor_name": "DEMO - Sliced Invoices",
"invoice_date": "January 25, 2016",
"total_amount": "93.50",
"invoice_number": "INV-3337"
}
}
],
"Send Invoice for Approval": [
{
"data": {
"Reviewed By": "jack",
"Approval Notes": "notes approval",
"Approve Invoice?": "Yes"
}
}
]
},
"connections": {
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Invoice Parser AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"d2a0d543-1ee3-4852-9751-69aae3b9864a": {
"main": [
[
{
"node": "4703ddb5-1e07-43b9-a465-c9aced0ac9d8",
"type": "main",
"index": 0
}
]
]
},
"ac5dd79d-9d32-44f9-8a9b-2cc45757110b": {
"main": [
[
{
"node": "57649f6a-2d4d-4072-92bd-ffea26fdd4dd",
"type": "main",
"index": 0
}
]
]
},
"b7ed6cf6-e965-43e0-abab-919ab598e62a": {
"main": [
[
{
"node": "d2a0d543-1ee3-4852-9751-69aae3b9864a",
"type": "main",
"index": 0
}
]
]
},
"eef8e5e5-2b01-4ddd-8ea2-312fb41356de": {
"main": [
[
{
"node": "57649f6a-2d4d-4072-92bd-ffea26fdd4dd",
"type": "main",
"index": 0
}
],
[
{
"node": "ac5dd79d-9d32-44f9-8a9b-2cc45757110b",
"type": "main",
"index": 0
}
]
]
},
"Invoice Parser AI Agent": {
"main": [
[
{
"node": "8483b8ef-83d7-4b3f-ad54-b9ec23efc911",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Invoice Parser AI Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Monitor Email Attachments": {
"main": [
[
{
"node": "7ca78f71-8c1e-42e2-8686-08f2a9bfc009",
"type": "main",
"index": 0
}
]
]
},
"8483b8ef-83d7-4b3f-ad54-b9ec23efc911": {
"main": [
[
{
"node": "eef8e5e5-2b01-4ddd-8ea2-312fb41356de",
"type": "main",
"index": 0
}
]
]
},
"d210d1c5-865f-494e-a69c-d25ac462869b": {
"main": [
[
{
"node": "0b4aff7d-8c92-4964-a38c-996b546ed23a",
"type": "main",
"index": 0
}
]
]
},
"0b4aff7d-8c92-4964-a38c-996b546ed23a": {
"main": [
[
{
"node": "Invoice Parser AI Agent",
"type": "main",
"index": 0
}
]
]
},
"4703ddb5-1e07-43b9-a465-c9aced0ac9d8": {
"main": [
[
{
"node": "Invoice Parser AI Agent",
"type": "main",
"index": 0
}
]
]
},
"7ca78f71-8c1e-42e2-8686-08f2a9bfc009": {
"main": [
[
{
"node": "Invoice Parser AI Agent",
"type": "main",
"index": 0
}
]
]
}
}
}このワークフローの使い方は?
上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。
このワークフローはどんな場面に適していますか?
上級 - 財務, 人工知能
有料ですか?
このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。
関連ワークフロー
Billy Christi
@billyI'm a professional software engineer and n8n expert with a passion for building scalable, no-code and low-code automation workflows. I specialize in creating seamless integrations between APIs, CRMs, and everyday tools to help businesses save time, reduce manual work, and operate smarter. Whether it's automating marketing pipelines, backend systems, or approval processes, I turn complex logic into simple, powerful workflows with n8n.
このワークフローを共有