Assistant de réponse aux e-mails avec approbation Telegram

Avancé

Ceci est unTicket Management, AI Chatbotworkflow d'automatisation du domainecontenant 16 nœuds.Utilise principalement des nœuds comme If, Gmail, Telegram, GmailTrigger, Agent. Automatisation des réponses par e-mail Gmail avec OpenAI et Telegram

Prérequis
  • Compte Google et informations d'identification Gmail API
  • Token Bot Telegram
  • Clé API OpenAI
Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "id": "gXutAybKcZqblZjF",
  "meta": {
    "instanceId": "f339fb4cdac358dcfebe03c578dc787158fe3660e2856c0a125861bc0c95ef5c",
    "templateCredsSetupCompleted": true
  },
  "name": "AI Email Reply Assistant with Telegram Approval",
  "tags": [],
  "nodes": [
    {
      "id": "a29a7c9c-cab6-479a-89f3-71c0abf02727",
      "name": "Structured Output Parser1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        680,
        1140
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"email\": \"email address\",\n  \"subject\": \"subject text\",\n  \"body\": \" body text .\"\n}\n"
      },
      "typeVersion": 1.2
    },
    {
      "id": "954febca-8faf-4899-838f-854a5c344b97",
      "name": "Envoyer un message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1340,
        820
      ],
      "webhookId": "2fac759a-1e15-489e-b619-ead2dea60008",
      "parameters": {
        "sendTo": "={{ $('AI: Generate Email Reply').item.json.output.email }}",
        "message": "={{ $('AI: Generate Email Reply').item.json.output.body }}",
        "options": {},
        "subject": "={{ $('AI: Generate Email Reply').item.json.output.subject }}",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "BjLuqt1WNTbWNBM1",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "feff315f-c008-4b67-bd89-0d88c79005ac",
      "name": "Déclencheur : Nouvel e-mail",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -1000,
        960
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "BjLuqt1WNTbWNBM1",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "b69c3e8d-cd36-4c72-8a8d-006dddd0280c",
      "name": "Vérifier : L'e-mail est-il dans la boîte de réception ?",
      "type": "n8n-nodes-base.if",
      "position": [
        -780,
        960
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3f7094d8-2756-493d-8721-be7d4c83297b",
              "operator": {
                "type": "array",
                "operation": "contains",
                "rightType": "any"
              },
              "leftValue": "={{ $json.labelIds }}",
              "rightValue": "INBOX"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "3cc06ffd-8a5d-4daf-a4c1-55953fba0cc8",
      "name": "IA : Doit-on répondre ?",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -320,
        940
      ],
      "parameters": {
        "text": "=todays date:- {{ $now }}\nmail date:- {{ $json.headers.date }}\nfrom :- {{ $json.headers.from }}\nsubject :- {{ $json.headers.subject.toJsonString() }}\n\ncontent :- {{ $json.text }}",
        "options": {
          "systemMessage": "You are a smart AI email assistant. Your job is to analyze each email and decide if it needs a response from the user. Most emails are promotions, newsletters, or notifications that do not need replies — skip those.\n\nOnly reply \"yes\" if:\n\nThe email asks a question\n\nThe email requests information or action\n\nThe email seems urgent or time-sensitive\n\nThe email involves work, deadlines, appointments, personal matters, or legal/financial implications\n\nOtherwise, reply \"no\".\n\nRespond in strict JSON format like this:\n\njson\nCopy\nEdit\n{\n  \"response\": \"yes\"\n}\nor\n\njson\nCopy\nEdit\n{\n  \"response\": \"no\"\n}\nDo not explain. No comments. Only JSON."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "47ddc596-591f-470c-bafd-6a5ee7881935",
      "name": "Parser : Décision de réponse JSON",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -120,
        1160
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"response\": \"no\"\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "02b4791e-6301-46b8-ad85-4c627651e08a",
      "name": "Vérifier : Réponse nécessaire ?",
      "type": "n8n-nodes-base.if",
      "position": [
        100,
        940
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8aa9d41a-a218-456c-8b46-70b2e4a1af03",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.output.response }}",
              "rightValue": "yes"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a5efce44-3718-4ad4-ba19-b558f029228b",
      "name": "Sortie : Aucune réponse nécessaire",
      "type": "n8n-nodes-base.noOp",
      "position": [
        280,
        1200
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "10b4cdbf-b2e0-4a75-baf2-d81184db8967",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -600,
        1180
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f44760d0-60bf-4f04-9b7c-b1d4159e76ba",
      "name": "IA : Générer une réponse par e-mail",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        500,
        920
      ],
      "parameters": {
        "text": "=todays date:- {{ $now }}\nmail date:- {{ $('Trigger: New Email').item.json.headers.date }}\nfrom :- {{ $('Trigger: New Email').item.json.headers.from }}\nsubject :- {{ $('Trigger: New Email').item.json.headers.subject }}\n\ncontent :- {{ $('Trigger: New Email').item.json.text }}",
        "options": {
          "systemMessage": "=📧 System Prompt: Email Reply Generator\nYou are an AI email assistant. Based on the following details, write a professional and relevant reply email on behalf of the user.\n\nToday's Date:\nOriginal Email Date:\nFrom: \nSubject:\nEmail Content:\n\n✍️ Instructions:\nWrite a clear and concise reply email that responds meaningfully to the content.\n\nKeep the tone professional, polite, and appropriate to the context.\n\nDo not include greetings like \"Hi\" or sign-offs like \"Best regards\" unless necessary.\n\nYour output must be strictly in the following JSON format:\n\n\n\n{\n  \"email\": \"email address\",\n  \"subject\": \"subject text\",\n  \"body\": \" body text .\"\n}\n\n\n\nIf the email is promotional, spam, or clearly does not require a reply, leave both fields blank:\n\n\n{\n  \"subject\": \"\",\n  \"body\": \"\"\n}\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "988af447-e485-4397-b6e8-c848d53384f8",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -300,
        1160
      ],
      "parameters": {
        "options": {
          "baseURL": "https://api.openai.com/v1"
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "e5xm7uBXWaCZn5Uk",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "79953edf-0e9a-42de-88f7-3202eefaf851",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        520,
        1140
      ],
      "parameters": {
        "options": {
          "baseURL": "https://api.openai.com/v1"
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "e5xm7uBXWaCZn5Uk",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d1bbf2f7-4506-4296-97fc-2044619dd524",
      "name": "Telegram : Envoyer + Approuver",
      "type": "n8n-nodes-base.telegram",
      "position": [
        900,
        920
      ],
      "webhookId": "49190a52-864e-4c68-be6c-6ce530f70370",
      "parameters": {
        "chatId": "=7917193308",
        "message": "=📥 *New Email Received*\n\n👤 *From:*  \n{{ $('Trigger: New Email').item.json.headers.from }}\n\n📝 *Subject:*  \n{{ $('Trigger: New Email').item.json.headers.subject }}\n\n💬 *Content:*  \n{{ $('Trigger: New Email').item.json.text }}\n\n\n🤖 *AI-Generated Response*\n\n📤 *To:*  \n{{ $('Trigger: New Email').item.json.headers.from }}\n\n📝 *Subject:*  \n{{ $json.output.subject }}\n\n💬 *Content:*  \n{{ $json.output.body }}\n",
        "options": {
          "limitWaitTime": {
            "values": {
              "resumeUnit": "minutes",
              "resumeAmount": 5
            }
          }
        },
        "operation": "sendAndWait",
        "approvalOptions": {
          "values": {
            "approvalType": "double"
          }
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "x5kGTW8ojjPJjQtB",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f61104a3-2350-4d5e-b613-94b7607dadd2",
      "name": "Vérifier : Telegram approuvé ?",
      "type": "n8n-nodes-base.if",
      "position": [
        1120,
        920
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c7315e3c-6ee1-40bb-8d74-0c70862f30a4",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.approved }}",
              "rightValue": "true"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "d1e81ee3-db7b-4a46-b02a-ddd299d5cadf",
      "name": "Sortie : Telegram non approuvé",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1340,
        1020
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "27b00238-c6fe-49bb-b147-1121f6f6c897",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        360
      ],
      "parameters": {
        "width": 3180,
        "height": 1320,
        "content": "## 🤖 AI Email Reply Assistant\n\n## 🔄 What this workflow does\nThis automation monitors your Gmail inbox, intelligently decides which emails need replies, generates professional responses using AI, and sends them after your approval via Telegram.\n\n---\n\n#### 🧩 Node-by-node Breakdown\n\n1. **📥 Trigger: New Email**\n   - Gmail Trigger node\n   - Polls inbox every minute for new emails\n\n2. **📂 Check: Is Email in Inbox?**\n   - Filters emails to only process those in INBOX\n   - Skips sent, drafts, and other folders\n\n3. **🧠 AI: Should We Reply?**\n   - AI analyzes email content to determine if reply is needed\n   - Skips promotions, newsletters, and notifications\n   - Only processes emails with questions, requests, or urgent matters\n\n4. **✅ Check: Response Required?**\n   - Routes emails based on AI decision\n   - Continues only if reply is needed\n\n5. **✍️ AI: Generate Email Reply**\n   - Creates professional, contextual email response\n   - Maintains appropriate tone and format\n   - Generates subject line and body content\n\n6. **📱 Telegram: Send + Approve**\n   - Shows original email and AI-generated response\n   - Waits for your approval via Telegram buttons\n   - 5-minute timeout for decision\n\n7. **🚀 Send a message**\n   - Sends the approved reply via Gmail\n   - Only executes if you approve via Telegram\n\n---\n\n#### 💡 Key Features\n- **Smart Filtering**: Only replies to emails that actually need responses\n- **Human Approval**: You control what gets sent\n- **Professional Tone**: AI maintains appropriate business communication\n- **Mobile Control**: Approve/reject replies directly from Telegram\n\n---\n\n#### 🛠 Perfect for:\n- Busy professionals managing high email volume\n- Customer service representatives\n- Sales teams with quick response requirements\n- Anyone wanting AI assistance with email management\n\n---\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "29633a52-57b2-462e-be6e-4473426433d0",
  "connections": {
    "988af447-e485-4397-b6e8-c848d53384f8": {
      "ai_languageModel": [
        [
          {
            "node": "3cc06ffd-8a5d-4daf-a4c1-55953fba0cc8",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "79953edf-0e9a-42de-88f7-3202eefaf851": {
      "ai_languageModel": [
        [
          {
            "node": "f44760d0-60bf-4f04-9b7c-b1d4159e76ba",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "feff315f-c008-4b67-bd89-0d88c79005ac": {
      "main": [
        [
          {
            "node": "b69c3e8d-cd36-4c72-8a8d-006dddd0280c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3cc06ffd-8a5d-4daf-a4c1-55953fba0cc8": {
      "main": [
        [
          {
            "node": "02b4791e-6301-46b8-ad85-4c627651e08a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f44760d0-60bf-4f04-9b7c-b1d4159e76ba": {
      "main": [
        [
          {
            "node": "d1bbf2f7-4506-4296-97fc-2044619dd524",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d1bbf2f7-4506-4296-97fc-2044619dd524": {
      "main": [
        [
          {
            "node": "f61104a3-2350-4d5e-b613-94b7607dadd2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b69c3e8d-cd36-4c72-8a8d-006dddd0280c": {
      "main": [
        [
          {
            "node": "3cc06ffd-8a5d-4daf-a4c1-55953fba0cc8",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "10b4cdbf-b2e0-4a75-baf2-d81184db8967",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f61104a3-2350-4d5e-b613-94b7607dadd2": {
      "main": [
        [
          {
            "node": "954febca-8faf-4899-838f-854a5c344b97",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "d1e81ee3-db7b-4a46-b02a-ddd299d5cadf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a29a7c9c-cab6-479a-89f3-71c0abf02727": {
      "ai_outputParser": [
        [
          {
            "node": "f44760d0-60bf-4f04-9b7c-b1d4159e76ba",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "02b4791e-6301-46b8-ad85-4c627651e08a": {
      "main": [
        [
          {
            "node": "f44760d0-60bf-4f04-9b7c-b1d4159e76ba",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "a5efce44-3718-4ad4-ba19-b558f029228b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "47ddc596-591f-470c-bafd-6a5ee7881935": {
      "ai_outputParser": [
        [
          {
            "node": "3cc06ffd-8a5d-4daf-a4c1-55953fba0cc8",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}
Foire aux questions

Comment utiliser ce workflow ?

Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.

Dans quelles scénarios ce workflow est-il adapté ?

Avancé - Gestion des tickets, Chatbot IA

Est-ce payant ?

Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.

Informations sur le workflow
Niveau de difficulté
Avancé
Nombre de nœuds16
Catégorie2
Types de nœuds9
Description de la difficulté

Adapté aux utilisateurs avancés, avec des workflows complexes contenant 16+ nœuds

Auteur
Roshan Ramani

Roshan Ramani

@rawsun007

I love building smart n8n automations that actually work reliably. My focus is on making everyday tasks like email, social media, and CRM workflows simpler using AI. I've shared templates in the n8n community, including a WhatsApp Expense Tracker that people really enjoy. What keeps me excited is constantly trying new things - testing fresh nodes, playing with AI tools like LangChain, and discovering creative ways to connect systems!

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34