AutomationFlowsAI & RAG › Gmail Email Processing with OpenAI & Sheets

Gmail Email Processing with OpenAI & Sheets

Original n8n title: Gmail受信メール処理ワークフロー(step4)

Gmail受信メール処理ワークフロー(Step4). Uses googleDocs, gmailTrigger, openAi, googleSheets. Event-driven trigger; 11 nodes.

Event trigger★★★★☆ complexityAI-powered11 nodesGoogle DocsGmail TriggerOpenAIGoogle Sheets
AI & RAG Trigger: Event Nodes: 11 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow follows the Gmail Trigger → Google Sheets 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 →

Download .json
{
  "name": "Gmail\u53d7\u4fe1\u30e1\u30fc\u30eb\u51e6\u7406\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\uff08Step4\uff09",
  "nodes": [
    {
      "parameters": {
        "folderId": "1cCiiz5tMpoGxzVRAWFgJNKPJ3tvzPyDN",
        "title": "{{ $('Gmail Trigger').item.json.payload.headers.find(h => h.name === 'From').value.split('<')[0].trim() }} - \u30e1\u30fc\u30eb\u8a18\u9332"
      },
      "id": "035b03e6-5a77-41c4-a1ad-c43441d2fd96",
      "name": "Google Docs\u4f5c\u6210",
      "type": "n8n-nodes-base.googleDocs",
      "typeVersion": 2,
      "position": [
        2416,
        656
      ],
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {
          "labelIds": [
            "Label_3"
          ]
        },
        "options": {}
      },
      "id": "a095dedd-5af3-4a02-a9e8-e27d8e80f1e7",
      "name": "Gmail Trigger1",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [
        1536,
        656
      ],
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "sender_name",
              "value": "={{ $('\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa').item.json.sender_clean }}"
            },
            {
              "name": "summary_content",
              "value": "={{ $json.data.choices[0].message.content }}"
            },
            {
              "name": "summary_extract",
              "value": "={{ $json.data.choices[0].message.content.split('\u3010\u8981\u7d04\u3011')[1] ? $json.data.choices[0].message.content.split('\u3010\u8981\u7d04\u3011')[1].split('\u3010\u9001\u4fe1\u8005\u3011')[0].trim() : '\u8981\u7d04\u306a\u3057' }}"
            },
            {
              "name": "next_action",
              "value": "={{ $json.data.choices[0].message.content.includes('\u3010\u6b21\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3011') ? $json.data.choices[0].message.content.split('\u3010\u6b21\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3011')[1].split('\u3010\u7de0\u5207/\u65e5\u4ed8\u3011')[0].trim() : '\u306a\u3057' }}"
            },
            {
              "name": "deadline",
              "value": "={{ $json.data.choices[0].message.content.includes('\u3010\u7de0\u5207/\u65e5\u4ed8\u3011') ? $json.data.choices[0].message.content.split('\u3010\u7de0\u5207/\u65e5\u4ed8\u3011')[1].trim() : '\u306a\u3057' }}"
            }
          ]
        },
        "options": {}
      },
      "id": "560a619f-41a1-436a-9740-41dfa84dcd5d",
      "name": "\u8981\u7d04\u7d50\u679c\u7d71\u5408",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2208,
        656
      ]
    },
    {
      "parameters": {
        "model": "chatgpt-4o-latest",
        "prompt": "\u4ee5\u4e0b\u306e\u30e1\u30fc\u30eb\u5185\u5bb9\u3092\u8981\u7d04\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u5f62\u5f0f\u3067\u65e5\u672c\u8a9e\u3067\u8fd4\u3057\u3066\u304f\u3060\u3055\u3044\uff1a\n\n\u3010\u8981\u7d04\u3011\n\u30fb[\u7b87\u6761\u66f8\u304d\u3067\u8981\u7d04]\n\n\u3010\u9001\u4fe1\u8005\u3011{{ $json.payload.headers.find(h => h.name === 'From').value.split('<')[0].trim() }}\n\u3010\u4ef6\u540d\u3011{{ $json.payload.headers.find(h => h.name === 'Subject').value }}\n\u3010\u65e5\u6642\u3011{{ new Date($json.internalDate * 1).toISOString() }}\n\u3010\u30b9\u30c6\u30fc\u30bf\u30b9\u3011\u672a\u5bfe\u5fdc\n\u3010\u6b21\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3011\n\u30fb[\u5fc5\u8981\u306a\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u3042\u308c\u3070\u8a18\u8f09\u3001\u306a\u3051\u308c\u3070\u300c\u306a\u3057\u300d]\n\u3010\u7de0\u5207/\u65e5\u4ed8\u3011\n\u30fb[\u671f\u9650\u3084\u91cd\u8981\u306a\u65e5\u4ed8\u304c\u3042\u308c\u3070\u8a18\u8f09\u3001\u306a\u3051\u308c\u3070\u300c\u306a\u3057\u300d]\n\n\u3010\u30e1\u30fc\u30eb\u672c\u6587\u3011\n{{ $json.snippet }}",
        "options": {},
        "requestOptions": {}
      },
      "id": "1ccac75e-bbd1-4834-a13d-41b3a599f45c",
      "name": "OpenAI\u8981\u7d04\u51e6\u74061",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.1,
      "position": [
        1984,
        656
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "sender",
              "value": "={{ $json.payload.headers.find(h => h.name === 'From').value }}"
            },
            {
              "name": "subject",
              "value": "={{ $json.payload.headers.find(h => h.name === 'Subject').value }}"
            },
            {
              "name": "body",
              "value": "={{ $json.snippet }}"
            },
            {
              "name": "received_time",
              "value": "={{ new Date($json.internalDate * 1).toISOString() }}"
            },
            {
              "name": "sender_clean",
              "value": "={{ $json.payload.headers.find(h => h.name === 'From').value.split('<')[0].trim() }}"
            }
          ]
        },
        "options": {}
      },
      "id": "5f3ddfac-fc74-44f8-844c-954d81870743",
      "name": "\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1760,
        656
      ]
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {
          "labelIds": [
            "Label_3"
          ]
        },
        "options": {}
      },
      "id": "4f05ba45-26f1-4437-abde-04280760c87a",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [
        1184,
        1056
      ],
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "14C-p5DuT2Bumx_MxtJ1mLBF3P0J2u377mBzMXOdaw-E",
          "mode": "list",
          "cachedResultName": "Gmail-Dashboard",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/14C-p5DuT2Bumx_MxtJ1mLBF3P0J2u377mBzMXOdaw-E/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "\u30b7\u30fc\u30c81",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/14C-p5DuT2Bumx_MxtJ1mLBF3P0J2u377mBzMXOdaw-E/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [
            "\u76f8\u624b\u5148"
          ],
          "schema": [
            {
              "id": "\u76f8\u624b\u5148",
              "displayName": "\u76f8\u624b\u5148",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "\u6700\u7d42\u66f4\u65b0\u65e5\u6642",
              "displayName": "\u6700\u7d42\u66f4\u65b0\u65e5\u6642",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "\u6700\u65b0\u8981\u7d04",
              "displayName": "\u6700\u65b0\u8981\u7d04",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "\u30b9\u30c6\u30fc\u30bf\u30b9",
              "displayName": "\u30b9\u30c6\u30fc\u30bf\u30b9",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "\u6b21\u306e\u30a2\u30af\u30b7\u30e7\u30f3",
              "displayName": "\u6b21\u306e\u30a2\u30af\u30b7\u30e7\u30f3",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "\u7de0\u5207/\u65e5\u4ed8",
              "displayName": "\u7de0\u5207/\u65e5\u4ed8",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "\u8a73\u7d30\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30ea\u30f3\u30af",
              "displayName": "\u8a73\u7d30\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30ea\u30f3\u30af",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "cellFormat": "USER_ENTERED"
        }
      },
      "id": "efe0d4c3-5a89-43d8-af50-ecd4363e50a1",
      "name": "Google Sheets\u66f4\u65b0",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        2064,
        1200
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "sender",
              "value": "={{ $json.payload.headers.find(h => h.name === 'From').value }}"
            },
            {
              "name": "subject",
              "value": "={{ $json.payload.headers.find(h => h.name === 'Subject').value }}"
            },
            {
              "name": "body",
              "value": "={{ $json.snippet }}"
            },
            {
              "name": "received_time",
              "value": "={{ new Date($json.internalDate * 1).toISOString() }}"
            },
            {
              "name": "sender_clean",
              "value": "={{ $json.payload.headers.find(h => h.name === 'From').value.split('<')[0].trim() }}"
            }
          ]
        },
        "options": {}
      },
      "id": "af18820e-9f79-45f0-99a6-b0367e9178e6",
      "name": "\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1408,
        1056
      ]
    },
    {
      "parameters": {
        "folderId": "1cCiiz5tMpoGxzVRAWFgJNKPJ3tvzPyDN",
        "title": "{{ $('Gmail Trigger').item.json.payload.headers.find(h => h.name === 'From').value.split('<')[0].trim() }} - \u30e1\u30fc\u30eb\u8a18\u9332"
      },
      "id": "266acec2-d804-4de3-9d4f-265a870f9230",
      "name": "Google Docs\u4f5c\u62101",
      "type": "n8n-nodes-base.googleDocs",
      "typeVersion": 2,
      "position": [
        2064,
        992
      ],
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "sender_name",
              "value": "={{ $('\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa1').item.json.sender_clean }}"
            },
            {
              "name": "summary_content",
              "value": "={{ $json.content }}"
            },
            {
              "name": "summary_extract",
              "value": "={{ $json.content.split('\u3010\u8981\u7d04\u3011')[1] ? $json.content.split('\u3010\u8981\u7d04\u3011')[1].split('\u3010\u9001\u4fe1\u8005\u3011')[0].trim() : '\u8981\u7d04\u306a\u3057' }}"
            },
            {
              "name": "next_action",
              "value": "={{ $json.content.includes('\u3010\u6b21\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3011') ? $json.content.split('\u3010\u6b21\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3011')[1].split('\u3010\u7de0\u5207/\u65e5\u4ed8\u3011')[0].trim() : '\u306a\u3057' }}"
            },
            {
              "name": "deadline",
              "value": "={{ $json.content.includes('\u3010\u7de0\u5207/\u65e5\u4ed8\u3011') ? $json.content.split('\u3010\u7de0\u5207/\u65e5\u4ed8\u3011')[1].trim() : '\u306a\u3057' }}"
            }
          ]
        },
        "options": {}
      },
      "id": "83702bd0-fab2-40e2-a1ef-5805395ddb79",
      "name": "\u8981\u7d04\u7d50\u679c\u7d71\u54081",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1856,
        1056
      ]
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-5-mini",
          "mode": "list",
          "cachedResultName": "GPT-5-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "\u4ee5\u4e0b\u306e\u30e1\u30fc\u30eb\u5185\u5bb9\u3092\u8981\u7d04\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u5f62\u5f0f\u3067\u65e5\u672c\u8a9e\u3067\u8fd4\u3057\u3066\u304f\u3060\u3055\u3044\uff1a\n\n\u3010\u8981\u7d04\u3011\n\u30fb[\u7b87\u6761\u66f8\u304d\u3067\u8981\u7d04]\n\n\u3010\u9001\u4fe1\u8005\u3011{{ $json.payload.headers.find(h => h.name === 'From').value.split('<')[0].trim() }}\n\u3010\u4ef6\u540d\u3011{{ $json.payload.headers.find(h => h.name === 'Subject').value }}\n\u3010\u65e5\u6642\u3011{{ new Date($json.internalDate * 1).toISOString() }}\n\u3010\u30b9\u30c6\u30fc\u30bf\u30b9\u3011\u672a\u5bfe\u5fdc\n\u3010\u6b21\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3011\n\u30fb[\u5fc5\u8981\u306a\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u3042\u308c\u3070\u8a18\u8f09\u3001\u306a\u3051\u308c\u3070\u300c\u306a\u3057\u300d]\n\u3010\u7de0\u5207/\u65e5\u4ed8\u3011\n\u30fb[\u671f\u9650\u3084\u91cd\u8981\u306a\u65e5\u4ed8\u304c\u3042\u308c\u3070\u8a18\u8f09\u3001\u306a\u3051\u308c\u3070\u300c\u306a\u3057\u300d]\n\n\u3010\u30e1\u30fc\u30eb\u672c\u6587\u3011\n{{ $json.snippet }}"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        1424,
        1296
      ],
      "id": "9a6f1d70-ae94-4e89-b8d5-ac96868df7f6",
      "name": "Message a model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Gmail Trigger1": {
      "main": [
        [
          {
            "node": "\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u8981\u7d04\u7d50\u679c\u7d71\u5408": {
      "main": [
        [
          {
            "node": "Google Docs\u4f5c\u6210",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI\u8981\u7d04\u51e6\u74061": {
      "main": [
        [
          {
            "node": "\u8981\u7d04\u7d50\u679c\u7d71\u5408",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa": {
      "main": [
        [
          {
            "node": "OpenAI\u8981\u7d04\u51e6\u74061",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa1": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u8981\u7d04\u7d50\u679c\u7d71\u54081": {
      "main": [
        [
          {
            "node": "Google Docs\u4f5c\u62101",
            "type": "main",
            "index": 0
          },
          {
            "node": "Google Sheets\u66f4\u65b0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "\u8981\u7d04\u7d50\u679c\u7d71\u54081",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f23c6e7d-d65e-44b9-a791-c91222e3e365",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "1y35KXgIoSjYFZyY",
  "tags": [
    {
      "createdAt": "2025-09-29T09:08:04.735Z",
      "updatedAt": "2025-09-29T09:08:04.735Z",
      "id": "CoueiOmq51e8qA0q",
      "name": "Gmail\u81ea\u52d5\u5316"
    }
  ]
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Gmail受信メール処理ワークフロー(Step4). Uses googleDocs, gmailTrigger, openAi, googleSheets. Event-driven trigger; 11 nodes.

Source: https://github.com/omksds/sandbox/blob/0fd8c76d36d3411b3d119fba17bd68dde0abe9a4/20250929_mail-to-dashboard/gmail_workflow_step4.json — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Gmail受信メール処理ワークフロー. Uses gmailTrigger, openAi, googleDocs, googleSheets. Event-driven trigger; 10 nodes.

Gmail Trigger, OpenAI, Google Docs +3
AI & RAG

This workflow converts emailed timesheets into structured invoice rows in Google Sheets and stores them in the correct Google Drive folder structure.

Gmail Trigger, OpenAI, Google Sheets +2
AI & RAG

Complete AI-powered sales system Automates lead capture, qualification, and follow-up from multiple channels. AI INTELLIGENCE:

Gmail Trigger, Google Sheets, OpenAI +3
AI & RAG

This n8n workflow — HRMate — streamlines your entire recruitment process by automatically parsing incoming job applications, evaluating candidate fit using AI, and sending personalized acceptance or r

HTTP Request, Gmail Trigger, OpenAI +2
AI & RAG

Overview

Gmail Trigger, Google Drive, OpenAI +4