{
  "id": "L3sf2JxKORGLf0Ou",
  "name": "Multi-Language Support Router",
  "tags": [],
  "nodes": [
    {
      "id": "89296639-2480-4713-acf6-3e91b2794bc9",
      "name": "Extract & Validate Form Data",
      "type": "n8n-nodes-base.code",
      "position": [
        432,
        3568
      ],
      "parameters": {
        "jsCode": "const formData = items[0].json;\nconst emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\n// Extract language code from dropdown selection (e.g., \"Spanish (ES)\" -> \"ES\")\nconst languageSelection = formData['Language'] || 'Spanish (ES)';\nconst langCodeMatch = languageSelection.match(/\\(([A-Z]{2})\\)/);\nconst langCode = langCodeMatch ? langCodeMatch[1] : 'ES';\n\nconst email = formData['Your Email'] || '';\nconst message = (formData['Your Question'] || '').trim();\n\nconst isValidEmail = emailRegex.test(email);\nconst hasMessage = message.length > 5;\n\nlet errorReason = null;\nif (!isValidEmail) errorReason = 'invalid_email';\nelse if (!hasMessage) errorReason = 'empty_message';\n\nreturn {\n  customerEmail: email,\n  customerMessage: message,\n  customerLanguage: langCode,\n  isValid: !errorReason,\n  errorReason: errorReason,\n  timestamp: new Date().toISOString()\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "4c533fb2-ec1a-4192-a156-667fcc4a91c4",
      "name": "Is Data Valid?",
      "type": "n8n-nodes-base.filter",
      "position": [
        656,
        3568
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ $json.isValid }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "409548a9-a310-4b52-a0e7-acef6ad65dec",
      "name": "Response: Validation Error",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        816,
        3840
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({\n  status: 'error',\n  reason: $json.errorReason,\n  message: $json.errorReason === 'invalid_email' ? 'Invalid email format. Must contain @ and domain.' : 'Message must be at least 5 characters long.'\n}) }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "c725a570-074b-402b-8a4e-5ff330bed86c",
      "name": "DeepL: Customer \u2192 English",
      "type": "n8n-nodes-base.deepL",
      "position": [
        880,
        3568
      ],
      "parameters": {
        "text": "={{ $json.customerMessage }}",
        "additionalFields": {}
      },
      "typeVersion": 1
    },
    {
      "id": "34d323b4-0283-479b-9442-9d927794e571",
      "name": "Translation Success?",
      "type": "n8n-nodes-base.filter",
      "position": [
        1104,
        3568
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "e5fd1809-f310-4ef7-b357-4c68e037e028",
      "name": "Response: Translation Error",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1328,
        3840
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={\n  \"status\": \"error\",\n  \"reason\": \"translation_to_english_failed\",\n  \"message\": \"DeepL API is temporarily unavailable or rate-limited. Please try again in 60 seconds.\",\n  \"retryAfter\": 60\n}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "311ddf29-897d-48cb-9ed8-2fe1a746685d",
      "name": "OpenAI: Generate Response",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1328,
        3568
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are a professional customer support agent. A customer has sent this message: \n\n    \"{{ $json.text }}\"\n\n    Generate a helpful, empathetic response in 2-3 paragraphs. Be professional but warm. Provide actionable next steps when possible. Do not make promises you cannot verify."
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.5
    },
    {
      "id": "8143074a-159d-405a-a9f5-39d78de1a742",
      "name": "AI Response Valid?",
      "type": "n8n-nodes-base.filter",
      "position": [
        1680,
        3568
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.response }}"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "2f4a9155-050c-4562-9f9b-023e53d67784",
      "name": "Response: AI Generation Error",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1872,
        3840
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={\n  \"status\": \"error\",\n  \"reason\": \"ai_generation_failed\",\n  \"message\": \"OpenAI failed to generate a response. This is rare. Please try again.\",\n  \"retryAfter\": 30\n}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "4c63f936-a2f5-4264-9bdf-058255310bdf",
      "name": "DeepL: English \u2192 Customer",
      "type": "n8n-nodes-base.deepL",
      "position": [
        1904,
        3568
      ],
      "parameters": {
        "text": "={{ $json.response }}",
        "translateTo": "target",
        "additionalFields": {}
      },
      "typeVersion": 1
    },
    {
      "id": "ecc1c68d-89ae-4513-be4f-efbef243a060",
      "name": "Back-Translation Success?",
      "type": "n8n-nodes-base.filter",
      "position": [
        2128,
        3568
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "1ffbc73b-bdad-4a1f-a9a7-59d00c919db7",
      "name": "Response: Back-Translation Error",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        2320,
        3840
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({\n  status: 'error',\n  reason: 'back_translation_failed',\n  message: 'Generated response but could not translate back to ' + $('Extract & Validate Form Data').first().json.customerLanguage + '. You can manually send the English version below.',\n  email: $('Extract & Validate Form Data').first().json.customerEmail,\n  originalMessage: $('Extract & Validate Form Data').first().json.customerMessage,\n  englishVersion: $('OpenAI: Generate Response').first().json.response,\n  instruction: 'Send the englishVersion to the customer manually, or retry in 60 seconds.'\n}) }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "d5e718b8-8dbb-46ed-a1dc-34603a2f8396",
      "name": "Package Final Response",
      "type": "n8n-nodes-base.set",
      "position": [
        2352,
        3568
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "name": "status",
              "type": "string",
              "value": "pending_review"
            },
            {
              "name": "email",
              "type": "string",
              "value": "={{ $('Extract & Validate Form Data').first().json.customerEmail }}"
            },
            {
              "name": "originalMessage",
              "type": "string",
              "value": "={{ $('Extract & Validate Form Data').first().json.customerMessage }}"
            },
            {
              "name": "translatedResponse",
              "type": "string",
              "value": "={{ $json.text }}"
            },
            {
              "name": "englishVersion",
              "type": "string",
              "value": "={{ $('OpenAI: Generate Response').first().json.response }}"
            },
            {
              "name": "customerLanguage",
              "type": "string",
              "value": "={{ $('Extract & Validate Form Data').first().json.customerLanguage }}"
            },
            {
              "name": "timestamp",
              "type": "string",
              "value": "={{ $('Extract & Validate Form Data').first().json.timestamp }}"
            },
            {
              "name": "upgradeUrl",
              "type": "string",
              "value": "https://your-lemonsqueezy.com/pro"
            },
            {
              "name": "upgradeMessage",
              "type": "string",
              "value": "PRO version auto-sends this response \u2014 no manual copy/paste needed. Save 2-3 minutes per ticket."
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5290768d-35c4-4210-a558-a9a1c4d5e94e",
      "name": "Send Success Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        2576,
        3568
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json) }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "67712f43-eccf-474b-98ee-6860329029a5",
      "name": "README1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        3440
      ],
      "parameters": {
        "width": 452,
        "height": 620,
        "content": "## Multi-Language Support Router\n\n**HOW IT WORKS:**\nCustomer submits form in 29 languages:\n- DeepL translates \u2192 English (auto-detect)\n- AI generates support response (GPT-3.5)\n- DeepL translates \u2192 Customer language\n- Manual review before sending\n\n**ERROR HANDLING:**\n- Validation fails \u2192 HTTP 400 (email/message)\n- Translation fails \u2192 HTTP 502 + retry 60s\n- AI fails \u2192 HTTP 502 + retry 30s\n- Back-translation fails \u2192 HTTP 502 + English fallback\n\n### SETUP CHECKLIST\n\n- [x] **DeepL API:**\n  \u2022 Sign up: deepl.com/pro-api (FREE: 500k chars/month)\n  \u2022 Copy API key\n  \u2022 n8n: Credentials \u2192 Add \u2192 \"DeepL API\"\n  \u2022 Connect to BOTH DeepL nodes\n\n- [ ] **OpenAI:**\n  \u2022 Get API key: platform.openai.com\n  \u2022 Connect to \"OpenAI: Generate Response\" node\n  \u2022 Model: GPT-3.5-turbo (default)\n- [ ] **Gmail OAuth2:**\n  \u2022 n8n: Credentials \u2192 Add \u2192 \"Gmail OAuth2\"\n  \u2022 Sign in with Google account\n  \u2022 Grant permissions\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0f3e10e4-ecc8-406b-9d1a-82518d1faef3",
      "name": "Translation Section1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        816,
        3456
      ],
      "parameters": {
        "color": 7,
        "width": 492,
        "height": 288,
        "content": "### TRANSLATE \u2192 ENGLISH\n\nDeepL auto-detects source language and translates customer message to English."
      },
      "typeVersion": 1
    },
    {
      "id": "a46fde7f-3a9b-41a9-8bad-4a2304f01a49",
      "name": "AI Section1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1328,
        3456
      ],
      "parameters": {
        "color": 7,
        "width": 492,
        "height": 288,
        "content": "### AI GENERATION\n\nGPT-3.5 generates professional support response in English (2-3 paragraphs)."
      },
      "typeVersion": 1
    },
    {
      "id": "f3c7c61b-6970-41de-be1b-4f6722874ff5",
      "name": "Back-Translation Section1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1856,
        3456
      ],
      "parameters": {
        "color": 7,
        "width": 428,
        "height": 288,
        "content": "###  TRANSLATE \u2192 CUSTOMER\n\nDeepL translates AI response back to customer's original language."
      },
      "typeVersion": 1
    },
    {
      "id": "3453033e-59f1-4134-8362-fb7542f12748",
      "name": "Output Section1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2304,
        3456
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 288,
        "content": "### PACKAGE & SEND\n\nBundles complete response (original + translated + English) for manual review."
      },
      "typeVersion": 1
    },
    {
      "id": "07977254-4c7b-4654-9f33-b4ea5b1b9f88",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        496,
        3792
      ],
      "parameters": {
        "color": 7,
        "width": 2224,
        "height": 224,
        "content": "## ERROR HANDLING\nAll error responses return proper \nHTTP codes (400/502) with clear messages"
      },
      "typeVersion": 1
    },
    {
      "id": "e7fac206-8c70-4440-b70f-0e641e84ea9d",
      "name": "Form: Customer Support",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        208,
        3568
      ],
      "parameters": {
        "path": "support-form",
        "options": {},
        "formTitle": "Customer Support Request",
        "formFields": {
          "values": [
            {
              "fieldType": "email",
              "fieldLabel": "Your Email",
              "requiredField": true
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Your Question",
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Language",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Spanish (ES)"
                  },
                  {
                    "option": "French (FR)"
                  },
                  {
                    "option": "German (DE)"
                  },
                  {
                    "option": "Italian (IT)"
                  },
                  {
                    "option": "Portuguese (PT)"
                  },
                  {
                    "option": "Dutch (NL)"
                  },
                  {
                    "option": "Polish (PL)"
                  },
                  {
                    "option": "Russian (RU)"
                  },
                  {
                    "option": "Japanese (JA)"
                  },
                  {
                    "option": "Chinese (ZH)"
                  },
                  {
                    "option": "English (EN)"
                  },
                  {
                    "option": "Bulgarian (BG)"
                  },
                  {
                    "option": "Czech (CS)"
                  },
                  {
                    "option": "Danish (DA)"
                  },
                  {
                    "option": "Greek (EL)"
                  },
                  {
                    "option": "Estonian (ET)"
                  },
                  {
                    "option": "Finnish (FI)"
                  },
                  {
                    "option": "Hungarian (HU)"
                  },
                  {
                    "option": "Indonesian (ID)"
                  },
                  {
                    "option": "Korean (KO)"
                  },
                  {
                    "option": "Lithuanian (LT)"
                  },
                  {
                    "option": "Latvian (LV)"
                  },
                  {
                    "option": "Norwegian (NB)"
                  },
                  {
                    "option": "Romanian (RO)"
                  },
                  {
                    "option": "Slovak (SK)"
                  },
                  {
                    "option": "Slovenian (SL)"
                  },
                  {
                    "option": "Swedish (SV)"
                  },
                  {
                    "option": "Turkish (TR)"
                  },
                  {
                    "option": "Ukrainian (UK)"
                  }
                ]
              },
              "requiredField": true
            }
          ]
        },
        "responseMode": "responseNode",
        "formDescription": "Submit your support question in any language. We'll respond in your native language within minutes."
      },
      "typeVersion": 2.1
    },
    {
      "id": "cfa2fb61-d94f-4b2c-bfd4-852dc420ed59",
      "name": "Gmail: Validation Error",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1024,
        3840
      ],
      "parameters": {
        "sendTo": "={{ $('Extract & Validate Form Data').first().json.customerEmail }}",
        "message": "=<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n</head>\n<body style=\"margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #f5f5f7;\">\n  <div style=\"max-width: 600px; margin: 40px auto; background-color: #ffffff; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,0.08);\">\n    \n    <!-- Header -->\n    <div style=\"background: linear-gradient(135deg, #ff3b30 0%, #ff6961 100%); padding: 40px 32px; text-align: center;\">\n      <div style=\"font-size: 48px; margin-bottom: 12px;\">\u274c</div>\n      <h1 style=\"margin: 0; color: #ffffff; font-size: 28px; font-weight: 600; letter-spacing: -0.5px;\">Validation Error</h1>\n    </div>\n    \n    <!-- Content -->\n    <div style=\"padding: 40px 32px;\">\n      <div style=\"background-color: #fff5f5; border-left: 4px solid #ff3b30; padding: 20px; border-radius: 8px; margin-bottom: 32px;\">\n        <p style=\"margin: 0; color: #1d1d1f; font-size: 16px; line-height: 1.6;\">\n          <strong>Error:</strong> {{ $json.errorReason === 'invalid_email' ? 'Invalid email format. Must contain @ and domain.' : 'Message must be at least 5 characters long.' }}\n        </p>\n      </div>\n      \n      <div style=\"background-color: #f5f5f7; padding: 24px; border-radius: 12px; margin-bottom: 32px;\">\n        <h3 style=\"margin: 0 0 16px 0; color: #1d1d1f; font-size: 18px; font-weight: 600;\">What to do next:</h3>\n        <ul style=\"margin: 0; padding-left: 20px; color: #86868b; font-size: 15px; line-height: 1.8;\">\n          <li>Check your email address format</li>\n          <li>Make sure your message is at least 5 characters long</li>\n          <li>Try submitting the form again</li>\n        </ul>\n      </div>\n      \n      <div style=\"text-align: center;\">\n        <a href=\"https://your-n8n-instance.com/form/support-form\" style=\"display: inline-block; background: linear-gradient(135deg, #007aff 0%, #0051d5 100%); color: #ffffff; text-decoration: none; padding: 16px 40px; border-radius: 12px; font-weight: 600; font-size: 16px; box-shadow: 0 4px 12px rgba(0,122,255,0.3);\">Try Again</a>\n      </div>\n    </div>\n    \n    <!-- Footer -->\n    <div style=\"background-color: #f5f5f7; padding: 24px 32px; text-align: center; border-top: 1px solid #e5e5ea;\">\n      <p style=\"margin: 0; color: #86868b; font-size: 13px;\">This is an automated message from your support system</p>\n    </div>\n  </div>\n</body>\n</html>",
        "options": {},
        "subject": "\u274c Support Request Error"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "3b3d6f7c-89a6-4475-bc2e-c4a02ab36007",
      "name": "Input Section",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        3456
      ],
      "parameters": {
        "color": 7,
        "width": 620,
        "height": 288,
        "content": "### INPUT & VALIDATION\n\nValidates email format, message length, and extracts language code from dropdown."
      },
      "typeVersion": 1
    },
    {
      "id": "5e0fc24e-0399-47f7-8864-7bcb289e0846",
      "name": "Gmail: Translation Error",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1520,
        3840
      ],
      "parameters": {
        "sendTo": "={{ $('Extract & Validate Form Data').first().json.customerEmail }}",
        "message": "=<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n</head>\n<body style=\"margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #f5f5f7;\">\n  <div style=\"max-width: 600px; margin: 40px auto; background-color: #ffffff; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,0.08);\">\n    \n    <!-- Header -->\n    <div style=\"background: linear-gradient(135deg, #ff9500 0%, #ffb340 100%); padding: 40px 32px; text-align: center;\">\n      <div style=\"font-size: 48px; margin-bottom: 12px;\">\u26a0\ufe0f</div>\n      <h1 style=\"margin: 0; color: #ffffff; font-size: 28px; font-weight: 600; letter-spacing: -0.5px;\">Translation Service Issue</h1>\n    </div>\n    \n    <!-- Content -->\n    <div style=\"padding: 40px 32px;\">\n      <div style=\"background-color: #fff9f0; border-left: 4px solid #ff9500; padding: 20px; border-radius: 8px; margin-bottom: 32px;\">\n        <p style=\"margin: 0; color: #1d1d1f; font-size: 16px; line-height: 1.6;\">\n          <strong>Issue:</strong> Our translation service (DeepL) is temporarily unavailable or rate-limited.\n        </p>\n      </div>\n      \n      <div style=\"background-color: #f5f5f7; padding: 24px; border-radius: 12px; margin-bottom: 32px;\">\n        <h3 style=\"margin: 0 0 16px 0; color: #1d1d1f; font-size: 18px; font-weight: 600;\">Your Message:</h3>\n        <p style=\"margin: 0; color: #86868b; font-size: 15px; line-height: 1.6; font-style: italic;\">\"{{ $('Extract & Validate Form Data').first().json.customerMessage }}\"</p>\n      </div>\n      \n      <div style=\"background-color: #e3f2fd; padding: 24px; border-radius: 12px; margin-bottom: 32px;\">\n        <h3 style=\"margin: 0 0 12px 0; color: #1d1d1f; font-size: 18px; font-weight: 600;\">Next Steps:</h3>\n        <p style=\"margin: 0; color: #1d1d1f; font-size: 15px; line-height: 1.8;\">\n          Please try again in <strong>60 seconds</strong>. This is usually a temporary issue that resolves quickly.\n        </p>\n      </div>\n      \n      <div style=\"text-align: center;\">\n        <a href=\"https://your-n8n-instance.com/form/support-form\" style=\"display: inline-block; background: linear-gradient(135deg, #007aff 0%, #0051d5 100%); color: #ffffff; text-decoration: none; padding: 16px 40px; border-radius: 12px; font-weight: 600; font-size: 16px; box-shadow: 0 4px 12px rgba(0,122,255,0.3);\">Submit Again (60s)</a>\n      </div>\n    </div>\n    \n    <!-- Footer -->\n    <div style=\"background-color: #f5f5f7; padding: 24px 32px; text-align: center; border-top: 1px solid #e5e5ea;\">\n      <p style=\"margin: 0; color: #86868b; font-size: 13px;\">This is an automated message from your support system</p>\n    </div>\n  </div>\n</body>\n</html>",
        "options": {},
        "subject": "\u26a0\ufe0f Translation Service Temporarily Unavailable"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "31d95e99-f625-4ecb-82be-fa736de99d76",
      "name": "Gmail: AI Generation Error1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2064,
        3840
      ],
      "parameters": {
        "sendTo": "={{ $('Extract & Validate Form Data').first().json.customerEmail }}",
        "message": "=<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n</head>\n<body style=\"margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #f5f5f7;\">\n  <div style=\"max-width: 600px; margin: 40px auto; background-color: #ffffff; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,0.08);\">\n    \n    <!-- Header -->\n    <div style=\"background: linear-gradient(135deg, #ff9500 0%, #ffb340 100%); padding: 40px 32px; text-align: center;\">\n      <div style=\"font-size: 48px; margin-bottom: 12px;\">\ud83e\udd16</div>\n      <h1 style=\"margin: 0; color: #ffffff; font-size: 28px; font-weight: 600; letter-spacing: -0.5px;\">AI Generation Failed</h1>\n    </div>\n    \n    <!-- Content -->\n    <div style=\"padding: 40px 32px;\">\n      <div style=\"background-color: #fff9f0; border-left: 4px solid #ff9500; padding: 20px; border-radius: 8px; margin-bottom: 32px;\">\n        <p style=\"margin: 0; color: #1d1d1f; font-size: 16px; line-height: 1.6;\">\n          <strong>Issue:</strong> OpenAI failed to generate a response. This is rare and usually resolves quickly.\n        </p>\n      </div>\n      \n      <div style=\"background-color: #f5f5f7; padding: 24px; border-radius: 12px; margin-bottom: 32px;\">\n        <h3 style=\"margin: 0 0 16px 0; color: #1d1d1f; font-size: 18px; font-weight: 600;\">Your Message:</h3>\n        <p style=\"margin: 0; color: #86868b; font-size: 15px; line-height: 1.6; font-style: italic;\">\"{{ $('Extract & Validate Form Data').first().json.customerMessage }}\"</p>\n      </div>\n      \n      <div style=\"background-color: #e3f2fd; padding: 24px; border-radius: 12px; margin-bottom: 32px;\">\n        <p style=\"margin: 0; color: #1d1d1f; font-size: 15px; line-height: 1.8;\">\n          Please try submitting your question again in <strong>30 seconds</strong>.\n        </p>\n      </div>\n      \n      <div style=\"text-align: center;\">\n        <a href=\"https://your-n8n-instance.com/form/support-form\" style=\"display: inline-block; background: linear-gradient(135deg, #007aff 0%, #0051d5 100%); color: #ffffff; text-decoration: none; padding: 16px 40px; border-radius: 12px; font-weight: 600; font-size: 16px; box-shadow: 0 4px 12px rgba(0,122,255,0.3);\">Try Again (30s)</a>\n      </div>\n    </div>\n    \n    <!-- Footer -->\n    <div style=\"background-color: #f5f5f7; padding: 24px 32px; text-align: center; border-top: 1px solid #e5e5ea;\">\n      <p style=\"margin: 0; color: #86868b; font-size: 13px;\">This is an automated message from your support system</p>\n    </div>\n  </div>\n</body>\n</html>",
        "options": {},
        "subject": "\u26a0\ufe0f AI Service Temporarily Unavailable"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "641e9eb0-80db-43bb-a5e6-750fd9b18771",
      "name": "Gmail: Back-Translation Error",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2512,
        3840
      ],
      "parameters": {
        "sendTo": "={{ $('Extract & Validate Form Data').first().json.customerEmail }}",
        "message": "=<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n</head>\n<body style=\"margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #f5f5f7;\">\n  <div style=\"max-width: 600px; margin: 40px auto; background-color: #ffffff; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,0.08);\">\n    \n    <!-- Header -->\n    <div style=\"background: linear-gradient(135deg, #34c759 0%, #30d158 100%); padding: 40px 32px; text-align: center;\">\n      <div style=\"font-size: 48px; margin-bottom: 12px;\">\u2705</div>\n      <h1 style=\"margin: 0; color: #ffffff; font-size: 28px; font-weight: 600; letter-spacing: -0.5px;\">Support Response</h1>\n      <p style=\"margin: 8px 0 0 0; color: rgba(255,255,255,0.9); font-size: 14px;\">English Version (Translation Failed)</p>\n    </div>\n    \n    <!-- Content -->\n    <div style=\"padding: 40px 32px;\">\n      <div style=\"background-color: #fff9e6; border-left: 4px solid #ff9500; padding: 20px; border-radius: 8px; margin-bottom: 32px;\">\n        <p style=\"margin: 0; color: #1d1d1f; font-size: 14px; line-height: 1.6;\">\n          <strong>Note:</strong> We couldn't translate this response back to {{ $('Extract & Validate Form Data').first().json.customerLanguage }}. Here's the English version:\n        </p>\n      </div>\n      \n      <div style=\"background-color: #f5f5f7; padding: 24px; border-radius: 12px; margin-bottom: 24px;\">\n        <h3 style=\"margin: 0 0 12px 0; color: #86868b; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;\">Your Question:</h3>\n        <p style=\"margin: 0; color: #1d1d1f; font-size: 15px; line-height: 1.6; font-style: italic;\">\"{{ $('Extract & Validate Form Data').first().json.customerMessage }}\"</p>\n      </div>\n      \n      <div style=\"background-color: #ffffff; padding: 28px; border: 2px solid #e5e5ea; border-radius: 12px; margin-bottom: 32px;\">\n        <h3 style=\"margin: 0 0 16px 0; color: #1d1d1f; font-size: 18px; font-weight: 600;\">Our Response:</h3>\n        <div style=\"color: #1d1d1f; font-size: 16px; line-height: 1.8;\">\n          {{ $('OpenAI: Generate Response').first().json.response }}\n        </div>\n      </div>\n      \n      <div style=\"background-color: #e3f2fd; padding: 20px; border-radius: 12px;\">\n        <p style=\"margin: 0; color: #1d1d1f; font-size: 14px; line-height: 1.6;\">\n          \ud83d\udca1 <strong>Tip:</strong> You can try submitting your question again in 60 seconds, or reply to this email if you need further assistance.\n        </p>\n      </div>\n    </div>\n    \n    <!-- Footer -->\n    <div style=\"background-color: #f5f5f7; padding: 24px 32px; text-align: center; border-top: 1px solid #e5e5ea;\">\n      <p style=\"margin: 0 0 8px 0; color: #86868b; font-size: 13px;\">Powered by AI Translation \u2022 {{ $('Extract & Validate Form Data1').first().json.timestamp }}</p>\n      <p style=\"margin: 0; color: #86868b; font-size: 12px;\">This is an automated message from your support system</p>\n    </div>\n  </div>\n</body>\n</html>",
        "options": {},
        "subject": "\u2705 Support Response (English Version)"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "cf83b339-a893-4178-bf33-b1ba41ab501b",
      "name": "Gmail: Send Success Response",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2816,
        3568
      ],
      "parameters": {
        "sendTo": "={{ $('Extract & Validate Form Data').first().json.customerEmail }}",
        "message": "=<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n</head>\n<body style=\"margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #f5f5f7;\">\n  <div style=\"max-width: 600px; margin: 40px auto; background-color: #ffffff; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,0.08);\">\n    \n    <!-- Header -->\n    <div style=\"background: linear-gradient(135deg, #007aff 0%, #0051d5 100%); padding: 40px 32px; text-align: center;\">\n      <div style=\"font-size: 48px; margin-bottom: 12px;\">\u2728</div>\n      <h1 style=\"margin: 0; color: #ffffff; font-size: 28px; font-weight: 600; letter-spacing: -0.5px;\">We've Got Your Answer</h1>\n      <p style=\"margin: 8px 0 0 0; color: rgba(255,255,255,0.9); font-size: 14px;\">Translated to your language</p>\n    </div>\n    \n    <!-- Content -->\n    <div style=\"padding: 40px 32px;\">\n      \n      <div style=\"background-color: #f5f5f7; padding: 24px; border-radius: 12px; margin-bottom: 24px;\">\n        <h3 style=\"margin: 0 0 12px 0; color: #86868b; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;\">Your Question:</h3>\n        <p style=\"margin: 0; color: #1d1d1f; font-size: 15px; line-height: 1.6; font-style: italic;\">\"{{ $('Extract & Validate Form Data').first().json.customerMessage }}\"</p>\n      </div>\n      \n      <!-- Main Response -->\n      <div style=\"background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%); padding: 32px; border: 2px solid #007aff; border-radius: 16px; margin-bottom: 32px; box-shadow: 0 2px 12px rgba(0,122,255,0.1);\">\n        <div style=\"display: flex; align-items: center; margin-bottom: 20px;\">\n          <div style=\"background-color: #007aff; width: 4px; height: 24px; border-radius: 2px; margin-right: 12px;\"></div>\n          <h2 style=\"margin: 0; color: #1d1d1f; font-size: 20px; font-weight: 600;\">Our Response:</h2>\n        </div>\n        <div style=\"color: #1d1d1f; font-size: 16px; line-height: 1.8; white-space: pre-line;\">\n{{ $json.text }}\n        </div>\n      </div>\n      \n      <!-- English Version (Collapsible) -->\n      <details style=\"background-color: #f5f5f7; padding: 24px; border-radius: 12px; margin-bottom: 32px;\">\n        <summary style=\"cursor: pointer; color: #007aff; font-size: 14px; font-weight: 600; margin-bottom: 16px;\">\ud83d\udcd6 View English Version</summary>\n        <div style=\"color: #86868b; font-size: 15px; line-height: 1.6; margin-top: 16px; padding-top: 16px; border-top: 1px solid #e5e5ea;\">\n          {{ $('OpenAI: Generate Response').first().json.response }}\n        </div>\n      </details>\n      \n      <!-- Metadata -->\n      <div style=\"background-color: #e3f2fd; padding: 20px; border-radius: 12px; margin-bottom: 32px;\">\n        <div style=\"display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px;\">\n          <div>\n            <div style=\"color: #86868b; font-size: 12px; margin-bottom: 4px;\">Language</div>\n            <div style=\"color: #1d1d1f; font-size: 14px; font-weight: 600;\">{{ $('Extract & Validate Form Data').first().json.customerLanguage }}</div>\n          </div>\n          <div>\n            <div style=\"color: #86868b; font-size: 12px; margin-bottom: 4px;\">Response Time</div>\n            <div style=\"color: #1d1d1f; font-size: 14px; font-weight: 600;\">~5 seconds</div>\n          </div>\n          <div>\n            <div style=\"color: #86868b; font-size: 12px; margin-bottom: 4px;\">Translated by</div>\n            <div style=\"color: #1d1d1f; font-size: 14px; font-weight: 600;\">DeepL AI</div>\n          </div>\n        </div>\n      </div>\n      \n      <!-- CTA -->\n      <div style=\"text-align: center; padding-top: 8px;\">\n        <p style=\"margin: 0 0 16px 0; color: #86868b; font-size: 14px;\">Need more help?</p>\n        <a href=\"https://your-n8n-instance.com/form/support-form\" style=\"display: inline-block; background: linear-gradient(135deg, #34c759 0%, #30d158 100%); color: #ffffff; text-decoration: none; padding: 14px 32px; border-radius: 12px; font-weight: 600; font-size: 15px; box-shadow: 0 4px 12px rgba(52,199,89,0.3);\">Ask Another Question</a>\n      </div>\n      \n    </div>\n    \n    <!-- Footer -->\n    <div style=\"background-color: #f5f5f7; padding: 24px 32px; text-align: center; border-top: 1px solid #e5e5ea;\">\n      <p style=\"margin: 0 0 8px 0; color: #86868b; font-size: 13px;\">Powered by AI Translation \u2022 {{ $('Extract & Validate Form Data1').first().json.timestamp }}</p>\n      <p style=\"margin: 0; color: #86868b; font-size: 12px;\">This response was automatically translated to your language</p>\n    </div>\n  </div>\n</body>\n</html>",
        "options": {},
        "subject": "\u2705 Your Support Response"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "e28f050c-f635-4750-8436-9fa587a7813c",
  "connections": {
    "Is Data Valid?": {
      "main": [
        [
          {
            "node": "DeepL: Customer \u2192 English",
            "type": "main",
            "index": 0
          },
          {
            "node": "Response: Validation Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Response Valid?": {
      "main": [
        [
          {
            "node": "DeepL: English \u2192 Customer",
            "type": "main",
            "index": 0
          },
          {
            "node": "Response: AI Generation Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Translation Success?": {
      "main": [
        [
          {
            "node": "OpenAI: Generate Response",
            "type": "main",
            "index": 0
          },
          {
            "node": "Response: Translation Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Success Response": {
      "main": [
        [
          {
            "node": "Gmail: Send Success Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Form: Customer Support": {
      "main": [
        [
          {
            "node": "Extract & Validate Form Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Package Final Response": {
      "main": [
        [
          {
            "node": "Send Success Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail: Validation Error": {
      "main": [
        []
      ]
    },
    "Back-Translation Success?": {
      "main": [
        [
          {
            "node": "Package Final Response",
            "type": "main",
            "index": 0
          },
          {
            "node": "Response: Back-Translation Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI: Generate Response": {
      "main": [
        [
          {
            "node": "AI Response Valid?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Response: Validation Error": {
      "main": [
        [
          {
            "node": "Gmail: Validation Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DeepL: Customer \u2192 English": {
      "main": [
        [
          {
            "node": "Translation Success?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DeepL: English \u2192 Customer": {
      "main": [
        [
          {
            "node": "Back-Translation Success?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Response: Translation Error": {
      "main": [
        [
          {
            "node": "Gmail: Translation Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract & Validate Form Data": {
      "main": [
        [
          {
            "node": "Is Data Valid?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Response: AI Generation Error": {
      "main": [
        [
          {
            "node": "Gmail: AI Generation Error1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Response: Back-Translation Error": {
      "main": [
        [
          {
            "node": "Gmail: Back-Translation Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}