diff --git a/workflows/OCR Document Processing from LINE-Gmail using GPT-4o to Google Workspace-11413/ocr_document_processing_from_line_gmail_using_gpt-4o_to_google_workspace.json b/workflows/OCR Document Processing from LINE-Gmail using GPT-4o to Google Workspace-11413/ocr_document_processing_from_line_gmail_using_gpt-4o_to_google_workspace.json new file mode 100644 index 000000000..7a06d2289 --- /dev/null +++ b/workflows/OCR Document Processing from LINE-Gmail using GPT-4o to Google Workspace-11413/ocr_document_processing_from_line_gmail_using_gpt-4o_to_google_workspace.json @@ -0,0 +1 @@ +{"id":"ngm4AsJ13afYIPJX","meta":{"instanceId":"189dde98270e9ce0f006f0e9deb96aa5e627396fc6279cac8902c9b06936984d"},"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],"webhookId":"e01f1876-c4e1-4f31-801b-eb1064203315","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":"// 手前のノードからデータを受け取る\nconst item = $input.first();\nconst jsonData = item.json;\n\n// バイナリデータ(画像)があるかチェック\nlet binaryOutput = {};\n\n// もしバイナリデータが存在すれば引き継ぐ(通常Upload後は空です)\nif (item.binary && item.binary.data) {\n binaryOutput = {\n data: item.binary.data\n };\n}\n\n// JSONデータ(ファイルIDなど)はそのまま次に渡す\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],"webhookId":"240221af-c9c4-4e21-94ca-54207027cf62","parameters":{"message":"=Original Text (OCR):{{ $json['要約内容'] }}\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":{"要約内容":"={{ $json.message.content }}"},"schema":[{"id":"日時","type":"string","display":true,"required":false,"displayName":"日時","defaultMatch":false,"canBeUsedToMatch":true},{"id":"要約内容","type":"string","display":true,"required":false,"displayName":"要約内容","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":"// 入力データを取得\nconst item = $input.first();\n\n// バイナリデータ(添付ファイル)があるか確認\nif (item.binary) {\n // データにつけられている名前(キー)をすべて取得\n const keys = Object.keys(item.binary);\n \n // もしデータがあるなら\n if (keys.length > 0) {\n const firstKey = keys[0];\n // そのデータの中身を 'data' という名前にコピーする\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],"webhookId":"4f858b9e-a179-42d3-9f90-74f1dfa512fa","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 “Workflow Configuration” 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 – 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,"pinData":{},"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}]]}}} \ No newline at end of file