Réponse automatique IA pour Gmail

Intermédiaire

Ceci est unMultimodal AIworkflow d'automatisation du domainecontenant 11 nœuds.Utilise principalement des nœuds comme If, Set, Gmail, GmailTrigger, Agent. Générateur de réponse automatique Gmail, utilisant GPT-4o-mini

Prérequis
  • Compte Google et informations d'identification Gmail API
  • Clé API OpenAI

Catégorie

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
{
  "name": "Gmail Auto-Reply with AI",
  "tags": [],
  "nodes": [
    {
      "id": "50972917-6da6-4b55-b18b-0bd96445e9f8",
      "name": "Déclenchement sur nouvel email",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        0,
        -352
      ],
      "parameters": {
        "filters": {
          "readStatus": "unread"
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "f42bb871-a182-4708-aa12-65f6c9c5ee28",
      "name": "Obtenir les emails non lus",
      "type": "n8n-nodes-base.gmail",
      "position": [
        224,
        -352
      ],
      "parameters": {
        "simple": false,
        "options": {},
        "messageId": "={{ $json.id }}",
        "operation": "get"
      },
      "typeVersion": 2.1
    },
    {
      "id": "c0ce4d37-a5ce-4926-9edf-5aa68d80426a",
      "name": "Obtenir les champs requis",
      "type": "n8n-nodes-base.set",
      "position": [
        448,
        -352
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "name": "threadId",
              "type": "string",
              "value": "={{ $json.threadId }}"
            },
            {
              "name": "id",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "name": "From",
              "type": "string",
              "value": "={{ $json.headers.from }}"
            },
            {
              "name": "message",
              "type": "string",
              "value": "={{ $json.text }}"
            },
            {
              "name": "subject",
              "type": "string",
              "value": "={{ $json.subject }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "64d9c2c7-0ef8-49f2-9c6c-5b0aabd27112",
      "name": "Agent IA",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        672,
        -352
      ],
      "parameters": {
        "text": "=You are an assistant that helps draft email replies.\n\nYour task:\n1. Read the email message below:\n\"{{ $json.message }}\"\n\n2. Decide if this is an email that requires a reply.  \n   - If it's spam, a notification, or irrelevant, set `isReply` to false.  \n   - If it's a genuine message that can be replied to, set `isReply` to true.  \n\n3. If `isReply` is true, draft a short and polite reply that:  \n   - Acknowledges the sender.  \n   - Is under 120 words.  \n   - Does not promise action you cannot take.  \n\n4. Return the result **only in valid JSON**, no extra text.\n\nJSON format to return:\n{\n  \"isReply\": true | false,\n  \"response\": \"string or empty if isReply is false\"\n}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "5673e94b-82b0-407f-9db4-60b35dfb8253",
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        680,
        -128
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "00fe0a38-cc10-492e-86d6-af0494c8afc9",
      "name": "Sortie structurée",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        808,
        -128
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"isReply\": {\n      \"type\": \"boolean\",\n      \"description\": \"Whether the email requires a reply\"\n    },\n    \"response\": {\n      \"type\": \"string\",\n      \"description\": \"The drafted reply text if isReply is true, otherwise empty\"\n    }\n  },\n  \"required\": [\"isReply\", \"response\"]\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "7fd55349-a8a3-4c1b-8dc8-221a50915a5e",
      "name": "L'agent IA peut-il répondre ?",
      "type": "n8n-nodes-base.if",
      "position": [
        1024,
        -352
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.output.isReply }}",
              "rightValue": "true"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "ba0480ca-4f1d-4813-b6d8-674ec1f2bafe",
      "name": "Créer un brouillon",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1248,
        -352
      ],
      "parameters": {
        "message": "={{ $json.output.response }}",
        "options": {
          "threadId": "={{ $('Get Required Fields').item.json.threadId }}"
        },
        "subject": "={{ $('Get Required Fields').item.json.subject }}",
        "resource": "draft"
      },
      "typeVersion": 2.1
    },
    {
      "id": "be177f90-54e7-472f-8b30-3dd6c8c1f4a3",
      "name": "Étiqueter l'email comme 'Action'",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1472,
        -352
      ],
      "parameters": {
        "labelIds": [
          "Label_4601850039988562325"
        ],
        "resource": "thread",
        "threadId": "={{ $('Get Required Fields').item.json.threadId }}",
        "operation": "addLabels"
      },
      "typeVersion": 2.1
    },
    {
      "id": "434ebfe4-410a-4f49-9285-cfd6256abb6f",
      "name": "Note autocollante",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        0
      ],
      "parameters": {
        "width": 336,
        "content": "## 🛠️ Setup Instructions\n  - Connect Gmail and OpenAI credentials before activating.\n  - Make sure your Gmail has a label called `Action`."
      },
      "typeVersion": 1
    },
    {
      "id": "77831399-3e74-454e-8e27-b9d6e2af638c",
      "name": "Note autocollante 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        608,
        -576
      ],
      "parameters": {
        "color": 5,
        "width": 368,
        "height": 656,
        "content": "## ⚠️ Reply Logic\n  - AI won't reply to spam, notifications, or irrelevant messages.\n  - Only genuine messages get responses. You can review drafts before sending.\n  - Tweak the AI agent's prompt to match your brand voice."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "connections": {
    "5673e94b-82b0-407f-9db4-60b35dfb8253": {
      "ai_languageModel": [
        [
          {
            "node": "64d9c2c7-0ef8-49f2-9c6c-5b0aabd27112",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "64d9c2c7-0ef8-49f2-9c6c-5b0aabd27112": {
      "main": [
        [
          {
            "node": "7fd55349-a8a3-4c1b-8dc8-221a50915a5e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ba0480ca-4f1d-4813-b6d8-674ec1f2bafe": {
      "main": [
        [
          {
            "node": "be177f90-54e7-472f-8b30-3dd6c8c1f4a3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f42bb871-a182-4708-aa12-65f6c9c5ee28": {
      "main": [
        [
          {
            "node": "c0ce4d37-a5ce-4926-9edf-5aa68d80426a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "00fe0a38-cc10-492e-86d6-af0494c8afc9": {
      "ai_outputParser": [
        [
          {
            "node": "64d9c2c7-0ef8-49f2-9c6c-5b0aabd27112",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "c0ce4d37-a5ce-4926-9edf-5aa68d80426a": {
      "main": [
        [
          {
            "node": "64d9c2c7-0ef8-49f2-9c6c-5b0aabd27112",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "50972917-6da6-4b55-b18b-0bd96445e9f8": {
      "main": [
        [
          {
            "node": "f42bb871-a182-4708-aa12-65f6c9c5ee28",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7fd55349-a8a3-4c1b-8dc8-221a50915a5e": {
      "main": [
        [
          {
            "node": "ba0480ca-4f1d-4813-b6d8-674ec1f2bafe",
            "type": "main",
            "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é ?

Intermédiaire - IA Multimodale

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é
Intermédiaire
Nombre de nœuds11
Catégorie1
Types de nœuds8
Description de la difficulté

Adapté aux utilisateurs expérimentés, avec des workflows de complexité moyenne contenant 6-15 nœuds

Auteur
Matt Chong | n8n Creator

Matt Chong | n8n Creator

@mattxchong

Automation nerd fueled by good coffee, deep curiosity, and clean flows.

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34