{
  "id": "pJ2Te2kUFfhWNb9A",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Translate and auto-reply to Gmail messages with human approval via Slack",
  "tags": [],
  "nodes": [
    {
      "id": "c1a5ba21-c74b-404a-bc72-af5329eb2d96",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "notes": "Set your specific Gmail label here (e.g., 'To_Process')",
      "position": [
        192,
        848
      ],
      "parameters": {
        "filters": {
          "labelIds": [
            "INBOX"
          ]
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "c45f19d1-0c2c-4102-b8c7-bf925c3ac604",
      "name": "Configuration",
      "type": "n8n-nodes-base.set",
      "notes": "Enter your Slack Channel ID here",
      "position": [
        416,
        848
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "slackChannel",
              "type": "string",
              "value": "YOUR_SLACK_CHANNEL_ID_HERE"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "92fb5d5c-d0b5-4cf9-9881-de0311e7866b",
      "name": "Translate Email",
      "type": "n8n-nodes-base.deepL",
      "position": [
        640,
        848
      ],
      "parameters": {
        "text": "={{ $json.snippet }}",
        "translateTo": "EN",
        "additionalFields": {}
      },
      "typeVersion": 1
    },
    {
      "id": "d9c943cf-4a6b-40d7-ba42-8640b89f9675",
      "name": "Generate AI Response",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        864,
        848
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4o-mini"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are a professional email assistant. Based on the following translated email content:\n\n{{ $('Translate Email').item.json.translatedText }}\n\nPlease:\n1. Create a concise summary (3 bullet points)\n2. Draft a professional and polite reply\n\nFormat your response as:\n\u3010Summary\u3011\n\u2022 Point 1\n\u2022 Point 2\n\u2022 Point 3\n\n\u3010Draft Reply\u3011\n[Your professional reply here]"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "416e8388-fc58-4785-9af8-6d81e1deed3a",
      "name": "Request Approval",
      "type": "n8n-nodes-base.slack",
      "position": [
        1184,
        848
      ],
      "parameters": {
        "text": "=\ud83d\udce7 **New Email Requiring Approval**\n\n**From:** {{ $('Gmail Trigger').item.json.from }}\n**Subject:** {{ $('Gmail Trigger').item.json.subject }}\n\n\ud83d\udcdd **AI Analysis:**\n{{ $json.message.content }}\n\n-----------------------------\n\n\u2705 **Action Required:**\nClick the link below to approve and send the reply:\n{{ $execution.resumeUrl }}\n\n\u26a0\ufe0f *Note: If no action is taken, the email will remain unanswered.*",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Configuration').item.json.slackChannel }}"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "id": "679dd134-f1d1-4698-b04b-8fe01bd72a7b",
      "name": "Wait for Approval",
      "type": "n8n-nodes-base.wait",
      "position": [
        1392,
        848
      ],
      "parameters": {
        "resume": "webhook",
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "997f7385-b66b-4e04-ac9d-574842b8bfea",
      "name": "Send Email Reply",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1616,
        848
      ],
      "parameters": {
        "message": "={{ $('Generate AI Response').item.json.message.content.split('\u3010Draft Reply\u3011')[1].trim() }}\n\n---\nSent via n8n automation",
        "options": {},
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "operation": "reply"
      },
      "typeVersion": 2.1
    },
    {
      "id": "5334a474-dbe0-4a50-a783-70a497da92df",
      "name": "Mark as Processed",
      "type": "n8n-nodes-base.gmail",
      "notes": "Removes label to prevent reprocessing",
      "position": [
        1840,
        848
      ],
      "parameters": {
        "labelIds": "={{ $('Gmail Trigger').item.json.labelIds[0] }}",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "operation": "removeLabels"
      },
      "typeVersion": 2.1
    },
    {
      "id": "f43b85f6-e8cb-4864-810a-e082604c5258",
      "name": "\ud83d\udccb Template Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -336,
        496
      ],
      "parameters": {
        "width": 450,
        "height": 676,
        "content": "## \ud83d\udca1 How to Use This Template\n\nThis workflow creates an intelligent email assistant that:\n- **Translates** incoming emails to your preferred language\n- **Generates** AI-powered summaries and draft replies\n- **Requests** human approval before sending\n- **Automates** the entire response process\n\n### Setup Instructions:\n1. **Gmail**: Create a label (e.g., 'To_Process') and configure OAuth2\n2. **DeepL**: Add your API key for translation\n3. **OpenAI**: Configure API key for AI responses\n4. **Slack**: Set up OAuth2 and enter channel ID in Configuration node\n\n### Important Notes:\n- n8n must be accessible via webhook (use tunnel for testing or deploy to production)\n- The workflow pauses at the approval step until you click the Slack link\n- Processed emails have their labels removed to prevent loops\n\n### Customization Options:\n- Change translation language in DeepL node\n- Adjust AI prompt for different response styles\n- Modify Slack message format\n- Add conditions for selective processing"
      },
      "typeVersion": 1
    },
    {
      "id": "00a54c3e-c863-451f-988c-c3a8e3e1590b",
      "name": "Step 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        144,
        1024
      ],
      "parameters": {
        "color": 7,
        "width": 200,
        "height": 96,
        "content": "### 1\ufe0f\u20e3 Email Detection\nMonitors Gmail for emails with your specified label"
      },
      "typeVersion": 1
    },
    {
      "id": "08fa9fac-4c89-4308-80c3-8425c2b38aeb",
      "name": "Step 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        1024
      ],
      "parameters": {
        "color": 7,
        "width": 200,
        "height": 80,
        "content": "### 2\ufe0f\u20e3 Configuration\nSet your Slack channel ID for notifications"
      },
      "typeVersion": 1
    },
    {
      "id": "9b8c3f04-a90e-43a8-b203-bc331bc39663",
      "name": "Step 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        592,
        1024
      ],
      "parameters": {
        "color": 7,
        "width": 200,
        "height": 112,
        "content": "### 3\ufe0f\u20e3 Translation\nAutomatically translates email content using DeepL"
      },
      "typeVersion": 1
    },
    {
      "id": "0c1565c4-2b3b-4195-b7d5-445821a784ae",
      "name": "Step 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        1040
      ],
      "parameters": {
        "color": 7,
        "width": 200,
        "height": 80,
        "content": "### 4\ufe0f\u20e3 AI Processing\nGenerates summary and professional reply draft"
      },
      "typeVersion": 1
    },
    {
      "id": "ab1ecdfc-f613-4abb-9016-8b5964f3696a",
      "name": "Step 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        1040
      ],
      "parameters": {
        "color": 7,
        "width": 200,
        "height": 80,
        "content": "### 5\ufe0f\u20e3 Human Approval\nSends approval request to Slack with one-click link"
      },
      "typeVersion": 1
    },
    {
      "id": "b41a1a15-4054-4306-b43f-8e1e4037a899",
      "name": "Step 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        1040
      ],
      "parameters": {
        "color": 7,
        "width": 200,
        "height": 80,
        "content": "### 6\ufe0f\u20e3 Send Reply\nAutomatically sends the approved email response"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "c0409ac5-c884-4b62-8d21-c32b8f6a38d9",
  "connections": {
    "Configuration": {
      "main": [
        [
          {
            "node": "Translate Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Translate Email": {
      "main": [
        [
          {
            "node": "Generate AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Request Approval": {
      "main": [
        [
          {
            "node": "Wait for Approval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email Reply": {
      "main": [
        [
          {
            "node": "Mark as Processed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Approval": {
      "main": [
        [
          {
            "node": "Send Email Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate AI Response": {
      "main": [
        [
          {
            "node": "Request Approval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}