{
  "name": "Voice-to-email response system with Telegram, OpenAI Whisper & Gmail",
  "nodes": [
    {
      "id": "618c19de-7259-46f7-a02f-d8a4fc140bf3",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        700,
        380
      ]
    },
    {
      "id": "7dae5a0e-353b-4a7b-a773-4bcc4ce580ed",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        540,
        380
      ]
    },
    {
      "id": "bab7f1c9-25a8-4c64-b963-ea684afc2380",
      "name": "Text Email",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1480,
        180
      ]
    },
    {
      "id": "0d2490f2-96be-46f2-aa1f-fd63e49c81f4",
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        800,
        820
      ]
    },
    {
      "id": "1911c739-07a4-42d4-aeb9-d90bb2cb2828",
      "name": "New Email Received",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -100,
        220
      ]
    },
    {
      "id": "e37d6747-a63f-4aee-bd3d-30c02b6fdc15",
      "name": "In the Inbox?",
      "type": "n8n-nodes-base.if",
      "position": [
        120,
        220
      ]
    },
    {
      "id": "c6eaa6bf-aa92-4dc2-93b9-9695b79c3047",
      "name": "Needs a response?",
      "type": "n8n-nodes-base.if",
      "position": [
        900,
        200
      ]
    },
    {
      "id": "44369d4b-6271-4f01-af9b-3b022ab50fb0",
      "name": "Telegram Bot Message Received",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -100,
        840
      ]
    },
    {
      "id": "f487f113-da38-41ab-8d1a-c6296fedb91e",
      "name": "It needs to be an audio message + a reply!",
      "type": "n8n-nodes-base.telegram",
      "position": [
        320,
        940
      ]
    },
    {
      "id": "215fd988-7e02-4bae-9b57-284e59a7a467",
      "name": "Get Audio File",
      "type": "n8n-nodes-base.telegram",
      "position": [
        620,
        820
      ]
    },
    {
      "id": "a8b83c7a-442a-445a-a55b-2ad7fdd1674b",
      "name": "Create Email Draft",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1400,
        820
      ]
    },
    {
      "id": "cf942bba-201b-4135-bac9-a5cdbd516749",
      "name": "Direct to Draft",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1560,
        820
      ]
    },
    {
      "id": "b21f66c4-544c-4401-96b6-b7e0239702e4",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -20
      ],
      "parameters": {
        "width": 560,
        "height": 580,
        "content": "## 1. New Email Received\n\nOur workflow is triggered when a new email comes in. \n\nWe use an IF node here to only run the automation on incoming emails to the INBOX - not in the SENT folder."
      }
    },
    {
      "id": "595b7700-97b9-400a-a96b-516452c3db86",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        460,
        -20
      ],
      "parameters": {
        "width": 740,
        "height": 580,
        "content": "## 2. Check If Email Needs a Response\n\nWe use ChatGPT to check if the email needs a reply. Anything sent with an \"unsubscribe\" button or \"manage preferences\" is ignored. Anything that comes from a com"
      }
    },
    {
      "id": "42551c14-0b70-42b7-a7ca-0bab580e050a",
      "name": "Does Email Need a Response?",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        520,
        200
      ]
    },
    {
      "id": "ac18470f-4884-43ca-80b5-c8936fc4d4cd",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1240,
        -20
      ],
      "parameters": {
        "width": 520,
        "height": 580,
        "content": "## 3. Send Email to Telegram\n\nWe use a VoicerEmailer bot to send the email over a Telegram message to our account on Telegram."
      }
    },
    {
      "id": "be53cc8e-c5dd-4b82-aa78-c7870bf7de7b",
      "name": "Is Type Audio Message + Reply?",
      "type": "n8n-nodes-base.if",
      "position": [
        100,
        840
      ]
    },
    {
      "id": "280d69b3-4cf5-4515-8ae8-c499b21e4d99",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        600
      ],
      "parameters": {
        "width": 680,
        "height": 580,
        "content": "## 4. Telegram Reply Received\n\nThis workflow is triggered when the Telegram bot receives a message. \n\nWe check that the message is a reply to a previous email message, and that the reply is an audio m"
      }
    },
    {
      "id": "168f9296-8ff4-4598-91ab-81967cf36dd2",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        600
      ],
      "parameters": {
        "width": 440,
        "height": 580,
        "content": "## 5. Audio Transcription\n\nWe get the audio file from the Telegram message and send it to OpenAI's Whisper API to get a transcription of the message."
      }
    },
    {
      "id": "8e2731c6-c4ca-40f3-8c26-6421b57f95e2",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1120,
        1000
      ]
    },
    {
      "id": "7c350b3d-1cad-4ae9-8330-8bb55fbcea15",
      "name": "Write Polished Reply",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1100,
        820
      ]
    },
    {
      "id": "37905767-3cca-4789-b016-2fec4f21e45b",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        600
      ],
      "parameters": {
        "width": 720,
        "height": 580,
        "content": "## 5. Create Email Draft\n\nFinally, we get ChatGPT to write up a response, given the original email for context and our voice note reply. \n\nWe create a new draft in Gmail, which shows up in the same em"
      }
    },
    {
      "id": "a9942f9d-8896-45cd-b715-1228d8e3295c",
      "name": "Set Chat ID",
      "type": "n8n-nodes-base.set",
      "position": [
        1300,
        180
      ]
    },
    {
      "id": "5a60bcd6-da89-4892-9a3f-1b04a2238ab6",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        340
      ],
      "parameters": {
        "width": 160,
        "height": 120,
        "content": "## Edit here\nAdd in your Chat ID here."
      }
    }
  ],
  "connections": {
    "OpenAI": {
      "main": [
        [
          {
            "node": "Write Polished Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Chat ID": {
      "main": [
        [
          {
            "node": "Text Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "In the Inbox?": {
      "main": [
        [
          {
            "node": "Does Email Need a Response?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Audio File": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Needs a response?": {
      "main": [
        [
          {
            "node": "Set Chat ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Does Email Need a Response?",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Create Email Draft": {
      "main": [
        [
          {
            "node": "Direct to Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New Email Received": {
      "main": [
        [
          {
            "node": "In the Inbox?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Write Polished Reply",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Write Polished Reply": {
      "main": [
        [
          {
            "node": "Create Email Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Does Email Need a Response?",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Does Email Need a Response?": {
      "main": [
        [
          {
            "node": "Needs a response?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Bot Message Received": {
      "main": [
        [
          {
            "node": "Is Type Audio Message + Reply?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Type Audio Message + Reply?": {
      "main": [
        [
          {
            "node": "Get Audio File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "It needs to be an audio message + a reply!",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}