n8n recipe · ai
Gmail → AI Agent
An AI Agent reads each new Gmail message and decides by itself: log it as a Google Sheets row, or post it to Slack.
지메일에 새 메일이 오면 AI 에이전트가 읽고, 구글 시트에 적을지 슬랙에 올릴지 스스로 정해요.
Steps
- When when a new email arrives in gmail — Gmail node
- Then decide whether to add a row to google sheets or post in slack — AI Agent node · may use: Google Sheets, Slack
Fields to fill (10)
The file has every node wired up. These are the blanks only you can fill (your form, your sheet, your words).
| Node | What to do |
|---|---|
| OpenAI Chat Model | check model: OpenAI Chat Model chosen by default (most used) — swap for Gemini, Anthropic, Ollama … if you like |
| OpenAI Chat Model | fill model (The model) |
| Google Sheets tool | fill documentId (Document) |
| Google Sheets tool | fill sheetName (Sheet) |
| Google Sheets tool | fill columns (Columns) |
| Google Sheets tool | decide per field: a fixed value, or let the agent fill it with {{ $fromAI('field') }} |
| Slack tool | check select = 'channel' (first option; pick yours) |
| Slack tool | fill channelId (The Slack channel to send to) — only if select = channel |
| Slack tool | fill text (The message text to post) |
| Slack tool | decide per field: a fixed value, or let the agent fill it with {{ $fromAI('field') }} |
Accounts to connect (4)
In n8n, pick or add a credential on each node — one of the types below.
- Gmail:
googleApiorgmailOAuth2 - OpenAI Chat Model:
openAiApi - Google Sheets tool:
googleApiorgoogleSheetsOAuth2Api - Slack tool:
slackApiorslackOAuth2Api
Get the n8n file
Download gmail-agent-sheets-or-slack.json
- Open a new, empty workflow in n8n.
- Open the workflow menu (⋯) and choose Import from File — or copy the JSON below and paste it onto the canvas (Ctrl/Cmd+V).
- Connect the accounts, fill the fields above, run one test, then turn the workflow on.
Or copy the JSON
{
"name": "An AI Agent reads each new Gmail message and decides by itself: log it as a Google Sheets row",
"nodes": [
{
"id": "n1",
"name": "Gmail Trigger",
"type": "n8n-nodes-base.gmailTrigger",
"typeVersion": 1.4,
"parameters": {
"event": "messageReceived"
},
"position": [
240,
300
],
"notes": "step: when a new email arrives in gmail"
},
{
"id": "n2",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"parameters": {
"promptType": "define",
"text": "=Decide whether to add a row to google sheets or post in slack:\n\n{{ JSON.stringify($json) }}"
},
"position": [
460,
300
],
"notes": "step: decide whether to add a row to google sheets or post in slack"
},
{
"id": "n3",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.3,
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": ""
}
},
"position": [
460,
500
]
},
{
"id": "n4",
"name": "Google Sheets tool",
"type": "n8n-nodes-base.googleSheetsTool",
"typeVersion": 4.7,
"parameters": {
"resource": "sheet",
"operation": "append",
"documentId": {
"__rl": true,
"mode": "list",
"value": ""
},
"sheetName": {
"__rl": true,
"mode": "list",
"value": ""
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {},
"matchingColumns": [],
"schema": []
}
},
"position": [
640,
500
]
},
{
"id": "n5",
"name": "Slack tool",
"type": "n8n-nodes-base.slackTool",
"typeVersion": 2.7,
"parameters": {
"resource": "message",
"operation": "post",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": ""
},
"text": ""
},
"position": [
820,
500
]
}
],
"connections": {
"Gmail Trigger": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Google Sheets tool": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Slack tool": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"active": false
}