{
  "name": "Automated multilingual Gmail draft reply with OpenAI GPT-4o",
  "nodes": [
    {
      "id": "579d54f2-8c04-4624-890a-c432d96f3911",
      "name": "If Needs Reply",
      "type": "n8n-nodes-base.if",
      "position": [
        1500,
        220
      ]
    },
    {
      "id": "526ab96e-bf2a-44f5-9e1b-3b1a10b5f55b",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        580,
        0
      ],
      "parameters": {
        "width": 444,
        "height": 434,
        "content": "### Gmail Trigger\n\nGet new incoming messages from Gmail with a specific label.\n\nIn this example, the \"Inquiry\" label is used. Feel free to set it up using other Gmail filters.\n\n⚠️ Adjust the time (pol"
      }
    },
    {
      "id": "7289a14b-225e-4399-aa6c-cb56158f450d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        0
      ],
      "parameters": {
        "width": 576,
        "height": 577,
        "content": "### Assess the email contents that need a reply\n\nThis assessment uses OpenAI GPT-4o and a JSON parser to determine whether a response is necessary and to identify the message’s language."
      }
    },
    {
      "id": "d10724dd-406c-4143-9c22-2c3ecd45e6be",
      "name": "Gmail - Create Draft",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2760,
        160
      ]
    },
    {
      "id": "b805dfdb-a68e-458f-9af9-8a9e773a951d",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2660,
        0
      ],
      "parameters": {
        "width": 326,
        "height": 395,
        "content": "### Create a Draft in the conversation\n\nDraft Integration: after converting the text to html, it places the draft into the Gmail thread as a reply to the first message"
      }
    },
    {
      "id": "cbb5c6a6-a445-474b-890f-54d1a546c28a",
      "name": "Switch based on email language",
      "type": "n8n-nodes-base.switch",
      "position": [
        1840,
        200
      ]
    },
    {
      "id": "a720280e-7c5f-4f83-ad2e-b13572cba762",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1760,
        0
      ],
      "parameters": {
        "width": 813,
        "height": 740,
        "content": "### Generate a Reply\n\nDefine the output from the Switch node. Then, generate a draft reply using OpenAI GPT-4 Turbo based on the message’s detected language. Establish the rules and conventions for ea"
      }
    },
    {
      "id": "a107790b-f883-469e-8763-61ec92bf1d8e",
      "name": "Generate email for a Japanese client",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        2080,
        160
      ]
    },
    {
      "id": "a548fcdd-1f5e-4a75-b136-07ecf4e96d3d",
      "name": "Generate email reply for an English client",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        2080,
        440
      ]
    },
    {
      "id": "dcdf44aa-b313-4a22-ae45-0774e5a85add",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        0
      ],
      "parameters": {
        "width": 560,
        "height": 941,
        "content": "## Automated Multilingual Gmail Draft Reply with OpenAI GPT-4o in n8n\n\n### Who is this for?\nThis workflow is ideal for anyone who receives a high volume of Gmail inquiries, especially those providing "
      }
    },
    {
      "id": "323eb990-e7c4-4495-811a-a3c5b26c27f0",
      "name": "Gmail trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        740,
        220
      ]
    },
    {
      "id": "1659ef58-d317-4260-99a8-f1de50d50839",
      "name": "OpenAI GPT-4o",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1140,
        420
      ]
    },
    {
      "id": "aeb51aac-0706-4a0e-8a21-cc09147a6e87",
      "name": "Assess if a message needs a reply and identify the language",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1140,
        220
      ]
    },
    {
      "id": "7e8a17a4-fc57-4f8f-9755-3984547bfcce",
      "name": "Parser Result",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1300,
        420
      ]
    },
    {
      "id": "79600a11-8038-48d7-a7a5-5c0ffdb6d412",
      "name": "OpenAI GPT 4o - For English",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2100,
        580
      ]
    },
    {
      "id": "e0e0ef36-5a52-4d77-ba51-270693ce893f",
      "name": "OpenAI GPT-4o - for Japanese",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2060,
        300
      ]
    }
  ],
  "connections": {
    "Gmail trigger": {
      "main": [
        [
          {
            "node": "Assess if a message needs a reply and identify the language",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-4o": {
      "ai_languageModel": [
        [
          {
            "node": "Assess if a message needs a reply and identify the language",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Parser Result": {
      "ai_outputParser": [
        [
          {
            "node": "Assess if a message needs a reply and identify the language",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "If Needs Reply": {
      "main": [
        [
          {
            "node": "Switch based on email language",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT 4o - For English": {
      "ai_languageModel": [
        [
          {
            "node": "Generate email reply for an English client",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-4o - for Japanese": {
      "ai_languageModel": [
        [
          {
            "node": "Generate email for a Japanese client",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Switch based on email language": {
      "main": [
        [
          {
            "node": "Generate email for a Japanese client",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate email reply for an English client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate email for a Japanese client": {
      "main": [
        [
          {
            "node": "Gmail - Create Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate email reply for an English client": {
      "main": [
        [
          {
            "node": "Gmail - Create Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Assess if a message needs a reply and identify the language": {
      "main": [
        [
          {
            "node": "If Needs Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}