8
n8n 中文网amn8n.com

SmartMail代理 - 您的AI邮件助手,由WhatsApp驱动

高级

这是一个Other, AI领域的自动化工作流,包含 24 个节点。主要使用 If, Set, Code, Switch, SplitOut 等节点,结合人工智能技术实现智能自动化。 通过WhatsApp使用Gmail、GPT和语音识别管理邮件

前置要求
  • Google 账号和 Gmail API 凭证
  • 可能需要目标 API 的认证凭证
  • Airtable API Key
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "2CrCmc820XAaHFHL",
  "meta": {
    "instanceId": "0113e6e8f0b87d10de7bde5508e446a6ee60d5da9eac8c7eea34b85efc06e886",
    "templateCredsSetupCompleted": true
  },
  "name": "SmartMail Agent – Your AI Email Assistant, Powered by WhatsApp",
  "tags": [],
  "nodes": [
    {
      "id": "85a2e149-585b-485b-bcfc-0b4097193e39",
      "name": "Email Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "onError": "continueErrorOutput",
      "position": [
        2480,
        -3100
      ],
      "parameters": {
        "text": "={{ $json.message_type }}\n",
        "options": {
          "systemMessage": "=# Overview  \nYou are an AI assistant specialized in managing email-related tasks and providing direct, actionable responses in French and English.\n\n## Context  \n- You are a general-purpose assistant supporting users in email communication and message automation.  \n- You operate in both French and English, depending on the language of the input.  \n- Your tone is strategic, clear, and focused on delivering concise responses.  \n\n## Instructions  \n1. Always validate the presence of actual message content before replying.  \n2. If the input is a greeting (e.g., \"Bonjour\", \"Merci\", \"comment tu vas\"), respond in a concise and friendly tone.  \n3. Format all email replies using HTML for clarity and structure.  \n4. If necessary, ask strategic questions to clarify vague requests or guide toward specific actions.  \n5. Respond directly to the user's message with a final sentence. Do not explain, structure, or rephrase the request.  \n6. If the input is unclear or lacks actionable content, request clarification.  \n7. You must never justify or comment on your actions.  \n\n## Tools    \n- Create Draft  \n- Send Email  \n\n## Examples  \n- Input: \"Bonjour\"  \n  - Output: \"Bonjour ! Ca va très bien, merci. Comment puis-je vous aider aujourd’hui ?\"  \n- Input: \"Envoies un email à Florence.\"  \n  - Output: \"L'email a été envoyé à Florence à l'adresse email suivante : xxx@nomdedomaine\"  \n- Input: \"Merci\"  \n  - Output: \"Avec plaisir ! 😊\"  \n\n## SOP (Standard Operating Procedure)  \n1. Check if the message contains usable content.  \n2. If empty, determine if it's a greeting; if not, request clarification.  \n3. Compose the email using this HTML format:  \n   \"Hello [Name],  \n   <br><br>  \n   [Content]  \n   <br><br>  \n   Best regards,  \n   <br>  \n   [Your Name]\"  \n4. Send or draft the email as instructed.  \n5. Log the outcome of the action if needed.  \n\n## Final Notes  \n- Your role is to provide fast, clean, and final outputs.  \n- Prioritize simple, scalable, and personalized interactions.  \n- All responses are time-sensitive and context-aware.  \n\nCurrent time is {{ $now.format('yyyy-MM-dd') }}  \nTime zone: Paris/Europe  \n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.6
    },
    {
      "id": "8b3fbab7-d5f4-4ab9-9468-e492586c5d2e",
      "name": "发送邮件",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        2200,
        -2680
      ],
      "webhookId": "ea31e63d-e6c5-4f6d-b17f-9ecda87e11c8",
      "parameters": {
        "sendTo": "={{ $fromAI(\"emailAddress\") }}",
        "message": "={{ $fromAI(\"emailBody\") }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $fromAI(\"subject\") }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "VpdTmf44WRCUdBTa",
          "name": "Gmail account TEST"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "eefaed16-798f-4060-9be2-9b527ecd4a56",
      "name": "Create Draft",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        2360,
        -2680
      ],
      "webhookId": "c40fc123-5d3d-4002-85bd-ec6603a0ad83",
      "parameters": {
        "message": "={{ $fromAI(\"emailBody\") }}",
        "options": {
          "sendTo": "={{ $fromAI(\"emailAddress\") }}"
        },
        "subject": "={{ $fromAI(\"subject\") }}",
        "resource": "draft",
        "emailType": "html"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "VpdTmf44WRCUdBTa",
          "name": "Gmail account TEST"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "5b47751d-88f0-4e7c-aecb-df220f672b08",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2040,
        -2680
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4-turbo-preview",
          "cachedResultName": "gpt-4-turbo-preview"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "0drnlAHYRUGeZtLD",
          "name": "OpenAi Emails Key"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "67d7f391-46ba-43ba-b988-35a68b46acdd",
      "name": "WhatsApp触发器",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        1660,
        -3860
      ],
      "webhookId": "2eadd11a-88fa-4423-9ff4-411c12094729",
      "parameters": {
        "updates": [
          "messages"
        ]
      },
      "credentials": {
        "whatsAppTriggerApi": {
          "id": "jifF3mXrNhJwcLKS",
          "name": "WhatsApp OAuth TEST"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "05fa762a-94e2-49cb-8236-5d12dfa046cd",
      "name": "条件分支",
      "type": "n8n-nodes-base.switch",
      "position": [
        1980,
        -3860
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "voice",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b969c18d-14dd-4b34-8d08-801d8818b8d2",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('WhatsApp Trigger').item.json.messages[0].type }}",
                    "rightValue": "audio"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "1daa0ee5-cb8b-44c4-ae74-954cae03c10d",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('WhatsApp Trigger').item.json.messages[0].type }}",
                    "rightValue": "text"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "d3bbad47-a4b0-4bc0-a807-adffb4914bde",
      "name": "HTTP 请求",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2360,
        -3940
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "whatsAppApi"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "MGUvsnUMEoX9BRFP",
          "name": "WhatsApp Token Personal Agent"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2451cc94-89b3-4163-a278-ef54c3302ec6",
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2540,
        -3940
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "transcribe"
      },
      "credentials": {
        "openAiApi": {
          "id": "dGvlNIgvEDsKANs5",
          "name": "OpenAi account Test"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "12942040-c126-4ce3-8549-9f0f0c62cf46",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        2500,
        -3760
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "7453a002-ec0f-4853-a28d-5d06669cb5d0",
              "name": "text",
              "type": "string",
              "value": "={{ $('WhatsApp Trigger').item.json.messages[0].text.body }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "74d29419-8fe1-4d68-84f7-1584e71abc22",
      "name": "拆分输出",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1820,
        -3860
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "={{ $json.field }}"
      },
      "typeVersion": 1
    },
    {
      "id": "b49b0f86-49bf-4e22-afc3-b13639e34c3d",
      "name": "编辑字段1",
      "type": "n8n-nodes-base.set",
      "position": [
        2720,
        -3760
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8cbf25ac-3fc9-4892-9c6a-24c974b03362",
              "name": "message_type",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "49837ff2-bb28-47fe-97d4-6f6d2840586a",
      "name": "WhatsApp Business Cloud1",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        1940,
        -1680
      ],
      "webhookId": "b89990f8-a463-4af2-a732-902da14bb3c2",
      "parameters": {
        "textBody": "={{ $json.output }}",
        "operation": "send",
        "phoneNumberId": "580438095157298",
        "additionalFields": {},
        "recipientPhoneNumber": "+33646644178"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "Pqk2W7YtdeRRoUwW",
          "name": "WhatsApp account TEST"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "86e22c41-98a6-400f-8945-afd724f05c14",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "disabled": true,
      "position": [
        1860,
        -2680
      ],
      "parameters": {
        "sessionKey": "={{ $('Edit Fields1').item.json.message_type }} ",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "4b0530f5-abfc-430c-915e-482dca9cc932",
      "name": "WhatsApp Business Cloud",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        2180,
        -3940
      ],
      "webhookId": "a4388d29-c2c7-45c4-8977-b768eacf997b",
      "parameters": {
        "resource": "media",
        "operation": "mediaUrlGet",
        "mediaGetId": "={{ $json.audio.id }}"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "Pqk2W7YtdeRRoUwW",
          "name": "WhatsApp account TEST"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2e755031-6f6a-4280-bf13-4fc5cc1ccbe4",
      "name": "OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1920,
        -1900
      ],
      "parameters": {
        "input": "={{ $json.output }}",
        "voice": "nova",
        "options": {},
        "resource": "audio"
      },
      "credentials": {
        "openAiApi": {
          "id": "0drnlAHYRUGeZtLD",
          "name": "OpenAi Emails Key"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "a9a3bf53-ea40-4206-9f54-159f96db2f79",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        2160,
        -1900
      ],
      "parameters": {
        "jsCode": "// Loop over input items and change the MIME type of binary data\nfor (const item of $input.all()) {\n\t// Check if the item has binary data\n\tif (item.binary) {\n\t\t// Find the binary property name (assuming there's at least one)\n\t\tconst binaryPropertyNames = Object.keys(item.binary);\n\n\t\tfor (const propName of binaryPropertyNames) {\n\t\t\t// If the MIME type is 'audio/mp3', change it to 'audio/mpeg'\n\t\t\tif (item.binary[propName].mimeType === 'audio/mp3') {\n\t\t\t\titem.binary[propName].mimeType = 'audio/mpeg';\n\t\t\t}\n\t\t}\n\t}\n}\n\nreturn $input.all();\n"
      },
      "typeVersion": 2
    },
    {
      "id": "32005f45-3bb2-4da0-887a-b89fbe49a7ba",
      "name": "条件判断",
      "type": "n8n-nodes-base.if",
      "position": [
        1640,
        -1880
      ],
      "parameters": {
        "options": {
          "ignoreCase": false
        },
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "2163dc40-756e-479a-b7fd-1418ac129a61",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('WhatsApp Trigger').item.json.messages[0].type }}",
              "rightValue": "audio"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "cec9cff4-b04b-4858-a46c-1caa8e2cc8a2",
      "name": "WhatsApp Business Cloud2",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        2400,
        -1900
      ],
      "webhookId": "7116ffeb-dd52-4993-a041-7ceac577b12d",
      "parameters": {
        "resource": "media",
        "phoneNumberId": "580438095157298",
        "additionalFields": {}
      },
      "credentials": {
        "whatsAppApi": {
          "id": "Pqk2W7YtdeRRoUwW",
          "name": "WhatsApp account TEST"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2c9dd33c-6c67-468a-a5bb-16076b08d735",
      "name": "WhatsApp Business Cloud3",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        2640,
        -1900
      ],
      "webhookId": "1957dc07-4009-4a6e-a2a4-11ec08ec9816",
      "parameters": {
        "mediaId": "={{ $json.id }}",
        "mediaPath": "useMediaId",
        "operation": "send",
        "messageType": "audio",
        "phoneNumberId": "580438095157298",
        "additionalFields": {},
        "recipientPhoneNumber": "+33646644178"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "Pqk2W7YtdeRRoUwW",
          "name": "WhatsApp account TEST"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e530836b-5977-4810-a684-4d4d71bd82c3",
      "name": "Get Email",
      "type": "n8n-nodes-base.airtableTool",
      "position": [
        2520,
        -2680
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "app6hvrEDwB41AKAz",
          "cachedResultUrl": "https://airtable.com/app6hvrEDwB41AKAz",
          "cachedResultName": "[BlockA] - Contact List"
        },
        "limit": 5,
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tbldXug1pLHGc0xoI",
          "cachedResultUrl": "https://airtable.com/app6hvrEDwB41AKAz/tbldXug1pLHGc0xoI",
          "cachedResultName": "Auto"
        },
        "options": {},
        "operation": "search",
        "returnAll": false,
        "filterByFormula": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Filter_By_Formula', ``, 'string') }}"
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "KFOvXiPrIgpAWZAy",
          "name": "Airtable Personal Access TEST"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "60875323-4791-4782-a7af-855400619f1b",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        -4460
      ],
      "parameters": {
        "width": 1280,
        "height": 920,
        "content": "## 🟫 第一部分:WhatsApp 消息接收与语音转录"
      },
      "typeVersion": 1
    },
    {
      "id": "b1172ad4-92fe-4a6b-97f7-ccce4bd8f56c",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        -2380
      ],
      "parameters": {
        "color": 3,
        "width": 1280,
        "height": 940,
        "content": "## 🟥 第三部分:语音回复与 WhatsApp 反馈"
      },
      "typeVersion": 1
    },
    {
      "id": "227b5da7-2ffc-4bf0-ba34-f4fbe1f61297",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        -3540
      ],
      "parameters": {
        "color": 4,
        "width": 1280,
        "height": 1160,
        "content": "## 🟩 第二部分:智能邮件助手 – 阅读、草拟、回复"
      },
      "typeVersion": 1
    },
    {
      "id": "98b9f159-67e7-421b-a7df-9be564db9db4",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2900,
        -4460
      ],
      "parameters": {
        "color": 5,
        "width": 720,
        "height": 3020,
        "content": "## 📘 通过 WhatsApp 的智能邮件助手 – 模块化设置指南"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "e85f3f2d-99f2-4df8-b94f-739dcf2c52b1",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "OpenAI1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "WhatsApp Business Cloud1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "WhatsApp Business Cloud2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "WhatsApp Business Cloud",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI1": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Email": {
      "ai_tool": [
        [
          {
            "node": "Email Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email": {
      "ai_tool": [
        [
          {
            "node": "Email Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Agent": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Draft": {
      "ai_tool": [
        [
          {
            "node": "Email Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "Email Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Email Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp Trigger": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Email Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp Business Cloud": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp Business Cloud1": {
      "main": [
        []
      ]
    },
    "WhatsApp Business Cloud2": {
      "main": [
        [
          {
            "node": "WhatsApp Business Cloud3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 其他, 人工智能

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量24
分类2
节点类型15
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Floyd Mahou

Floyd Mahou

@floyd

Ex-finance professional turned AI Automation & Business Architecture Strategist.

外部链接
在 n8n.io 查看

分享此工作流