This workflow corresponds to n8n.io template #11413 — we link there as the canonical source.
This workflow follows the Gmail → Gmail Trigger recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "ngm4AsJ13afYIPJX",
"name": "Document OCR and Intelligent Summarization System",
"tags": [],
"nodes": [
{
"id": "a56e1337-516f-40ad-b6b3-cf8de4752fd0",
"name": "LINE Webhook",
"type": "n8n-nodes-base.webhook",
"position": [
320,
192
],
"parameters": {
"path": "line-webhook",
"options": {},
"httpMethod": "POST"
},
"typeVersion": 2.1
},
{
"id": "d61a681a-e601-47bc-8132-70bbffdde858",
"name": "Gmail IMAP Trigger",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
768,
384
],
"parameters": {
"simple": false,
"filters": {
"labelIds": [
"INBOX"
]
},
"options": {
"downloadAttachments": true
},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"notesInFlow": false,
"typeVersion": 1.3
},
{
"id": "6eb0dc27-4337-4ffb-8944-5facc305c23d",
"name": "Workflow Configuration",
"type": "n8n-nodes-base.set",
"position": [
544,
192
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "lineChannelAccessToken",
"type": "string",
"value": "YOUR_LINE_CHANNEL_ACCESS_TOKEN"
},
{
"id": "id-2",
"name": "googleDriveFolderId",
"type": "string",
"value": "YOUR_GOOGLE_DRIVE_FOLDER_ID"
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "da4dd82f-8713-407d-bc03-b9ad8544fdb7",
"name": "Tag Source - LINE",
"type": "n8n-nodes-base.set",
"position": [
1216,
192
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "source",
"type": "string",
"value": "LINE"
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "3704073e-0e45-45d3-a9a0-449eedfb8e55",
"name": "Tag Source - EMAIL",
"type": "n8n-nodes-base.set",
"position": [
992,
384
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "source",
"type": "string",
"value": "EMAIL"
},
{
"id": "2a828138-9583-4300-b84c-09e670df0e4a",
"name": "googleDriveFolderId",
"type": "string",
"value": "YOUR_GOOGLE_DRIVE_FOLDER_ID"
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "180d4949-f1da-467a-8cad-61c64af3f9f9",
"name": "Merge Triggers",
"type": "n8n-nodes-base.merge",
"position": [
1440,
288
],
"parameters": {},
"typeVersion": 3.2
},
{
"id": "1bfd6191-b884-4505-acab-fd252343de51",
"name": "Upload to Google Drive",
"type": "n8n-nodes-base.googleDrive",
"position": [
1664,
288
],
"parameters": {
"name": "={{ $binary.data.fileName || \"document\" }}",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "id",
"value": "YOUR_GOOGLE_DRIVE_FOLDER_ID"
}
},
"typeVersion": 3
},
{
"id": "bf8aaa1d-de30-4b27-93e7-788227c9a413",
"name": "Convert to Base64",
"type": "n8n-nodes-base.code",
"position": [
1888,
288
],
"parameters": {
"jsCode": "// \u624b\u524d\u306e\u30ce\u30fc\u30c9\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d7\u3051\u53d6\u308b\nconst item = $input.first();\nconst jsonData = item.json;\n\n// \u30d0\u30a4\u30ca\u30ea\u30c7\u30fc\u30bf\uff08\u753b\u50cf\uff09\u304c\u3042\u308b\u304b\u30c1\u30a7\u30c3\u30af\nlet binaryOutput = {};\n\n// \u3082\u3057\u30d0\u30a4\u30ca\u30ea\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3059\u308c\u3070\u5f15\u304d\u7d99\u3050\uff08\u901a\u5e38Upload\u5f8c\u306f\u7a7a\u3067\u3059\uff09\nif (item.binary && item.binary.data) {\n binaryOutput = {\n data: item.binary.data\n };\n}\n\n// JSON\u30c7\u30fc\u30bf\uff08\u30d5\u30a1\u30a4\u30ebID\u306a\u3069\uff09\u306f\u305d\u306e\u307e\u307e\u6b21\u306b\u6e21\u3059\nreturn {\n json: jsonData,\n binary: binaryOutput\n};"
},
"typeVersion": 2
},
{
"id": "2782bd67-2b73-458e-bb02-e94481b2ccc3",
"name": "Create Gmail Draft",
"type": "n8n-nodes-base.gmail",
"position": [
3360,
288
],
"parameters": {
"message": "=Original Text (OCR):{{ $json['\u8981\u7d04\u5185\u5bb9'] }}\n\n---\n\nSummary:\n\n---\n\nFile URL: ",
"options": {},
"subject": "=Document Processing Results - {{ $('Convert to Base64').item.json.name }}",
"resource": "draft"
},
"typeVersion": 2.1
},
{
"id": "95a9e91f-51a7-463f-ab00-24f4540b5a2e",
"name": "If",
"type": "n8n-nodes-base.if",
"position": [
768,
192
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "c431d328-6fab-4b12-ae3f-ac66241fbc56",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.body.events[0].message.type }}",
"rightValue": "image"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "d03f445a-3612-4533-bd2a-1ed9b88958e5",
"name": "Append row in sheet",
"type": "n8n-nodes-base.googleSheets",
"position": [
3136,
288
],
"parameters": {
"columns": {
"value": {
"\u8981\u7d04\u5185\u5bb9": "={{ $json.message.content }}"
},
"schema": [
{
"id": "\u65e5\u6642",
"type": "string",
"display": true,
"required": false,
"displayName": "\u65e5\u6642",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "\u8981\u7d04\u5185\u5bb9",
"type": "string",
"display": true,
"required": false,
"displayName": "\u8981\u7d04\u5185\u5bb9",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "Sheet1",
"cachedResultUrl": "https://docs.google.com/spreadsheets/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "YOUR_GOOGLE_SHEETS_DOCUMENT_ID",
"cachedResultUrl": "https://docs.google.com/spreadsheets/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit",
"cachedResultName": "OCR Log"
}
},
"typeVersion": 4.7
},
{
"id": "ac70a4ce-57a6-4531-96af-a6cadc504534",
"name": "Code in JavaScript",
"type": "n8n-nodes-base.code",
"position": [
1216,
384
],
"parameters": {
"jsCode": "// \u5165\u529b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\nconst item = $input.first();\n\n// \u30d0\u30a4\u30ca\u30ea\u30c7\u30fc\u30bf\uff08\u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\uff09\u304c\u3042\u308b\u304b\u78ba\u8a8d\nif (item.binary) {\n // \u30c7\u30fc\u30bf\u306b\u3064\u3051\u3089\u308c\u3066\u3044\u308b\u540d\u524d\uff08\u30ad\u30fc\uff09\u3092\u3059\u3079\u3066\u53d6\u5f97\n const keys = Object.keys(item.binary);\n \n // \u3082\u3057\u30c7\u30fc\u30bf\u304c\u3042\u308b\u306a\u3089\n if (keys.length > 0) {\n const firstKey = keys[0];\n // \u305d\u306e\u30c7\u30fc\u30bf\u306e\u4e2d\u8eab\u3092 'data' \u3068\u3044\u3046\u540d\u524d\u306b\u30b3\u30d4\u30fc\u3059\u308b\n item.binary.data = item.binary[firstKey];\n }\n}\n\nreturn item;"
},
"typeVersion": 2
},
{
"id": "d64235aa-ec71-471c-80fe-124a10fe2763",
"name": "HTTP Request2",
"type": "n8n-nodes-base.httpRequest",
"position": [
2112,
288
],
"parameters": {
"url": "=https://www.googleapis.com/drive/v3/files/{{ $json.id }}?alt=media",
"options": {},
"authentication": "predefinedCredentialType",
"nodeCredentialType": "googleDriveOAuth2Api"
},
"typeVersion": 4.2
},
{
"id": "357d6bad-241d-440d-838d-d0db67ea3376",
"name": "Analyze image",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
2336,
288
],
"parameters": {
"text": "Transcribe all content written in this image exactly, preserving all line breaks.",
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "GPT-4O-MINI"
},
"options": {},
"resource": "image",
"inputType": "base64",
"operation": "analyze"
},
"typeVersion": 1.8
},
{
"id": "bb8e593f-cc59-4ba6-80a0-d7ef45dd264f",
"name": "Message a model",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
2784,
288
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "GPT-4O-MINI"
},
"options": {},
"messages": {
"values": [
{
"content": "={{ $json.content }}"
}
]
}
},
"typeVersion": 1.8
},
{
"id": "2a2a05b9-4402-41db-b8ae-094edd17a793",
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"position": [
992,
192
],
"parameters": {
"url": "=https://api-data.line.me/v2/bot/message/{{ $json.body.events[0].message.id }}/content",
"options": {},
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth"
},
"typeVersion": 4.2
},
{
"id": "a6244112-3362-4cb3-a31b-a45be3eec10f",
"name": "Wait",
"type": "n8n-nodes-base.wait",
"position": [
2560,
288
],
"parameters": {
"amount": 60
},
"typeVersion": 1.1
},
{
"id": "c6359ece-e8a9-46ee-b783-e6813e93a84d",
"name": "Sticky Note - Overview",
"type": "n8n-nodes-base.stickyNote",
"position": [
-176,
-400
],
"parameters": {
"color": 6,
"width": 832,
"height": 552,
"content": "## Document OCR and Intelligent Summarization System\n\nThis workflow captures images or PDFs from LINE and Gmail, runs OCR and AI summarization, and stores the results so you never lose important information.\n\n### Who it's for\n- People who receive many documents as photos or email attachments \n- Anyone who wants an automatic archive of full text + short summaries in Google Sheets and Gmail\n\n### How it works\n1. Triggers on new LINE messages or Gmail inbox emails. \n2. Saves the received file to a Google Drive folder. \n3. Uses an OpenAI Vision model to extract all text from the image/PDF. \n4. Sends the text to an LLM to create a concise summary. \n5. Logs the summary in Google Sheets and prepares a Gmail draft with the OCR text and summary.\n\n### Setup notes\n- Add credentials for LINE, Gmail, Google Drive, Google Sheets, and OpenAI in your n8n instance. \n- Replace the placeholder IDs and tokens in the \u201cWorkflow Configuration\u201d node with your own values before enabling the workflow."
},
"typeVersion": 1
},
{
"id": "a9475ec4-fc0f-4a15-b486-ba43c46fca04",
"name": "Sticky Note - Triggers & Configuration",
"type": "n8n-nodes-base.stickyNote",
"position": [
160,
384
],
"parameters": {
"width": 544,
"height": 340,
"content": "## Triggers & configuration\n\n- **LINE Webhook** and **Gmail IMAP Trigger** start the workflow when a new message or email arrives.\n- **Workflow Configuration** stores shared settings like Drive folder IDs and tokens.\n- The **If** node makes sure we only call the LINE content API when the incoming message is an image.\n\nUse this section to connect your own LINE bot and Gmail account before moving on to the rest of the flow."
},
"typeVersion": 1
},
{
"id": "4ae78044-9169-49be-91a2-bab9650be735",
"name": "Sticky Note - Source tagging & merge",
"type": "n8n-nodes-base.stickyNote",
"position": [
1392,
-128
],
"parameters": {
"width": 352,
"height": 356,
"content": "## Source tagging & merge\n\n- **Tag Source \u2013 LINE / EMAIL** label each item with `source = \"LINE\"` or `\"EMAIL\"` and attach the Drive folder ID.\n- **Code in JavaScript** normalizes Gmail attachments so LINE and email files share the same binary format.\n- **Merge Triggers** combines both branches into a single stream so downstream nodes can treat them the same."
},
"typeVersion": 1
},
{
"id": "996c9593-8b3a-4ffc-bbde-43c79cd73c7a",
"name": "Sticky Note - File upload & OCR",
"type": "n8n-nodes-base.stickyNote",
"position": [
1808,
448
],
"parameters": {
"width": 576,
"height": 276,
"content": "## File upload & OCR\n\n- **Upload to Google Drive** saves the incoming image/PDF and outputs its file ID.\n- **HTTP Request** / **HTTP Request2** download binary content from LINE and Google Drive.\n- **Convert to Base64** and the vision node **Analyze image** turn the file into raw text.\n- **Wait** adds a small delay to avoid rate limits and keep external APIs stable."
},
"typeVersion": 1
},
{
"id": "92744582-9d8a-442a-a147-86e2989d608a",
"name": "Sticky Note - Summaries & outputs",
"type": "n8n-nodes-base.stickyNote",
"position": [
2896,
-32
],
"parameters": {
"width": 480,
"height": 260,
"content": "## Summaries & outputs\n\n- **Message a model** turns the OCR text into a concise, human-readable summary.\n- **Append row in sheet** logs each summary (and any metadata you choose) in Google Sheets.\n- **Create Gmail Draft** builds a ready-to-review email that contains the OCR text, the summary, and a link to the original file.\n\nThis section is where you review or share the processed document results."
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "86beb981-44a5-47c8-bfc7-d7bba1cb82f5",
"connections": {
"If": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"Wait": {
"main": [
[
{
"node": "Message a model",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request": {
"main": [
[
{
"node": "Tag Source - LINE",
"type": "main",
"index": 0
}
]
]
},
"LINE Webhook": {
"main": [
[
{
"node": "Workflow Configuration",
"type": "main",
"index": 0
}
]
]
},
"Analyze image": {
"main": [
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request2": {
"main": [
[
{
"node": "Analyze image",
"type": "main",
"index": 0
}
]
]
},
"Merge Triggers": {
"main": [
[
{
"node": "Upload to Google Drive",
"type": "main",
"index": 0
}
]
]
},
"Message a model": {
"main": [
[
{
"node": "Append row in sheet",
"type": "main",
"index": 0
}
]
]
},
"Convert to Base64": {
"main": [
[
{
"node": "HTTP Request2",
"type": "main",
"index": 0
}
]
]
},
"Tag Source - LINE": {
"main": [
[
{
"node": "Merge Triggers",
"type": "main",
"index": 0
}
]
]
},
"Code in JavaScript": {
"main": [
[
{
"node": "Merge Triggers",
"type": "main",
"index": 1
}
]
]
},
"Gmail IMAP Trigger": {
"main": [
[
{
"node": "Tag Source - EMAIL",
"type": "main",
"index": 0
}
]
]
},
"Tag Source - EMAIL": {
"main": [
[
{
"node": "Code in JavaScript",
"type": "main",
"index": 0
}
]
]
},
"Append row in sheet": {
"main": [
[
{
"node": "Create Gmail Draft",
"type": "main",
"index": 0
}
]
]
},
"Upload to Google Drive": {
"main": [
[
{
"node": "Convert to Base64",
"type": "main",
"index": 0
}
]
]
},
"Workflow Configuration": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
}
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Who this is for
Source: https://n8n.io/workflows/11413/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This n8n template automatically classifies incoming emails (Sales, Support, Internal, Finance, Promotions) and routes them to a dedicated OpenAI LLM Agent for processing. Depending on the category, th
This workflow automates document processing using LlamaParse to extract and analyze text from various file formats. It intelligently processes documents, extracts structured data, and delivers actiona
This workflow auto-generates a personalized research report on any prospect who books a call with you—using their LinkedIn profile and advanced web research.
Overview
Lead Research & Qualification - Phase 1. Uses httpRequest, openAi, googleSheets, gmail. Event-driven trigger; 22 nodes.