ChatGPT工作后台运营AI 评分 · 72/100AI 辅助编辑·未发现明显提示词注入风险n8n.io

WhatsApp 自动化 HR 服务系统:GPT 分类 + Google Workspace

员工发送 WhatsApp 消息 → LLM 分类意图 → 路由到 5 个专用 AI Agent → 自动处理请假、考勤、FAQ、投诉、候选人筛选 → WhatsApp 回复结果

经验丰富步骤流程提示词贴士
给谁
HR 团队、初创公司、需要自动化员工事务处理的企业
你会得到
通过 WhatsApp 自动处理请假审批、考勤打卡、HR 政策问答、投诉转邮件、候选人筛选与面试安排
你需要
n8n · whatsapp · google-sheets · google-calendar · supabase

硬约束

前置条件:n8n 实例;WhatsApp Business API 凭证(Twilio 或 Meta 官方);OpenAI API 密钥;Google Sheets/Calendar/Gmail OAuth2;Supabase 向量库。费用:OpenAI 按 token 计费;WhatsApp Business API 按消息计费;Google Workspace 按订阅计费。注意:workflow.json 中的 Google Sheets 文档 ID、Supabase 表名、办公室地理围栏坐标、WhatsApp 电话号码均为占位符,必须替换为实际值。

他们做了什么

作者 tnayagarwal 在 n8n 上发布了一个 65 节点的模板工作流,将 WhatsApp 作为员工与 HR 系统的交互入口。员工发送文字、位置、音频或图片消息后,工作流通过 GPT-4o 分类意图,再路由到 5 个专用 AI Agent 分别处理请假、考勤、FAQ、投诉和候选人筛选,最终结果通过 WhatsApp 回复。

效果如何

模板在 n8n.io 上获得 22,613 次查看(author_report)。工作流展示了完整的节点连接和可运行的提示词配置,但本站未实际导入运行。

值得知道

1. 办公室地理围栏坐标在 Code1 节点中为空白数组,必须手动填入实际经纬度。2. Google Sheets 文档 ID 为作者私有表格,需替换为自有数据。3. WhatsApp 的 phoneNumberId 和 recipientPhoneNumber 为硬编码,需更新。4. CV 下载子工作流包含特定 Google Drive 文件 ID,需替换。5. 模板中多处出现 'ICICI' 作为示例公司名称,实际使用时应替换。6. Supabase 向量库表名默认为 'data',需与实际的 policy 文档表对应。7. 作者使用了 gpt-4.1-nano、gpt-4o-mini、gpt-4o 等多种模型组合,非单一模型。

n8n 工作流模板

结构已检查 · 未实际运行

下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。

配置与测试清单

需要绑定的凭证

  • WhatsApp Trigger 节点:绑定whatsAppTriggerApi 凭证。
  • OpenAI 节点:绑定OpenAI API 凭证。
  • OpenAI Chat Model 节点:绑定OpenAI API 凭证。
  • HTTP Request 节点:绑定HTTP Header Auth 凭证。
  • HTTP Request1 节点:绑定HTTP Header Auth 凭证。
  • OpenAI1 节点:绑定OpenAI API 凭证。
  • OpenAI Chat Model3 节点:绑定OpenAI API 凭证。
  • OpenAI Chat Model1 节点:绑定OpenAI API 凭证。
  • Supabase Vector Store 节点:绑定supabaseApi 凭证。
  • Embeddings OpenAI 节点:绑定OpenAI API 凭证。
  • OpenAI Chat Model2 节点:绑定OpenAI API 凭证。
  • Gmail 节点:绑定Gmail OAuth2 凭证。
  • Personalize email 节点:绑定OpenAI API 凭证。
  • Google Calendar 节点:绑定Google Calendar OAuth2 凭证。
  • Google Sheets2 节点:绑定Google Sheets OAuth2 凭证。
  • OpenAI Chat Model4 节点:绑定OpenAI API 凭证。
  • Gmail1 节点:绑定Gmail OAuth2 凭证。
  • JD tool 节点:绑定Google Sheets OAuth2 凭证。
  • applicants 节点:绑定Google Sheets OAuth2 凭证。
  • OpenAI Chat Model5 节点:绑定OpenAI API 凭证。
  • OpenAI Chat Model6 节点:绑定OpenAI API 凭证。
  • Gmail2 节点:绑定Gmail OAuth2 凭证。
  • dept head email 节点:绑定Google Sheets OAuth2 凭证。
  • OpenAI Chat Model7 节点:绑定OpenAI API 凭证。
  • getrows 节点:绑定Google Sheets OAuth2 凭证。
  • putrows 节点:绑定Google Sheets OAuth2 凭证。
  • update leaves 节点:绑定Google Sheets OAuth2 凭证。
  • get leaves 节点:绑定Google Sheets OAuth2 凭证。
  • download media 节点:绑定whatsAppApi 凭证。
  • download media1 节点:绑定whatsAppApi 凭证。
  • read sheets 节点:绑定Google Sheets OAuth2 凭证。
  • WhatsApp Responder 节点:绑定whatsAppApi 凭证。
  • get mail 节点:绑定Google Sheets OAuth2 凭证。
  • WhatsApp Approval 节点:绑定whatsAppApi 凭证。

需要替换的配置

  • 源模板来自 n8n 公开库 #4975(约 65 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
  • Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。

测试输入与预期结果

  • 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
  • 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。

模板处理说明

  • 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
  • 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。

模板获取日期: 2026-10-24

步骤

  1. 配置触发器与 LLM 消息分类器

    在 n8n 中导入模板。配置 WhatsApp Trigger 节点接收 messages 类型更新。连接 Delegatory LLM 节点(Basic LLM Chain),使用 gpt-4o 模型。该节点分析 incoming message 的 type 和 text.body,按规则输出 1-5 的单一数字:1=请假,2=HR 问答,3=考勤(location 类型),4=投诉/请求,5=候选人筛选。音频或图片消息也归类为 2。

    运行提示词 · 来源原文。Delegatory LLM 节点(Basic LLM Chain)的 text 参数;promptType=define

    =You are given a message object with the structure:
    
    type: {{ $json.messages[0].type }}
    
    text body (if applicable): {{ $json.messages[0].text.body }}
    
    Your task is to analyze the message and classify it into exactly one category, returning only the corresponding number, based on the detailed rules below.
    
    📩 If the type is "text":
    Analyze the content in {{ $json.messages[0].text.body }} and classify based on the user's intent:
    
    ✅ Output 1 → Leave Request
    Use this only if the message is about applying for leave, informing absence, or time off.
    Examples:
    
    “I need leave for tomorrow.”
    
    “I won’t be coming in today.”
    
    “Apply leave from 12th to 14th.”
    
    ✅ Output 2 → HR Chatbot (FAQ or Policy Queries)
    Use this for any general queries about HR policies, benefits, leave balances, holidays, or onboarding.
    Examples:
    
    “How many leaves do I have left?”
    
    “What is the dress code policy?”
    
    “Where can I get my salary slip?”
    
    ✅ Output 5 → Shortlisting Request
    Use this if the user is instructing to filter, rank, or shortlist candidates for a particular job or JD.
    Examples:
    
    “Shortlist candidates for backend role.”
    
    “Filter CVs for the UI designer position.”
    
    ✅ Output 4 → Request or Complaint for Department Head
    Use this if the user is requesting to send an email to or escalate an issue to a department head or authority.
    Examples:
    
    “Raise a complaint to admin.”
    
    “Send a mail to IT about my laptop.”
    
    “Escalate this matter to HR.”
    
    📍 If the type is "location":
    This indicates attendance marking via GPS.
    
    ✅ Output 3
    🎙️ If the type is "audio" or "image":
    Assume this is a general HR query via media. For example, a voice message asking for policy info or a photo of a document.
    
    ✅ Output 2
    🔴 Final & Strict Instruction:
    You must return only one of the following numbers:
    1, 2, 3, 4, or 5
    No text. No description. No formatting. Only the number.
  2. Switch 路由到对应 Agent

    添加 Switch 节点,根据 LLM 输出的数字路由到 5 条分支:1→Leave Agent,2→HR FAQ Agent,3→Attendance Marking,4→Escalation Agent,5→Shortlisting Agent。每条分支后使用 Merge 节点将原始 WhatsApp 数据带回,供下游 Agent 处理。

  3. Leave Agent:请假审批与转交

    Leave Agent(AI Agent 节点,gpt-4.1-nano)接收请假请求。通过 Google Sheets 工具查询员工可用假期;若请假天数<2天且为病假,自动批准并发送 Gmail 邮件(抄送部门主管);若≥2天或非病假,转发部门主管审批。无可用假期时回复 WhatsApp 告知。使用 update leaves / get leaves 工具读写 Google Sheets。

    运行提示词 · 来源原文。Leave Agent 节点(AI Agent)的 text 参数;promptType=define

    =You are an autonomous leave request assistant for ICICI's internal HR system.
    You receive leave requests from employees through WhatsApp in plain text 
    {{ $json.messages[0].text.body }}- this is the leave request text and details use the above 
    - “I need a sick leave on 11th June”
    - “I'm applying for medical leave from 11th to 14th June”
    - “Can I take a personal leave tomorrow?”
    Your goal is to process each leave request correctly based on live employee data and respond with the appropriate action.
    Tools You Can Use:
    1. **Google Sheets – Get Rows Tool**
       - Use this to retrieve employee records
       - Sheet contains the following columns:
         - `name`, `email`, `department head email`, `available leaves`, `last leave`, `attendance`, `department`
    2. **Google Sheets – Append or Update Rows Tool**
       - Use this to log any leave taken or updates if needed
    3. **Gmail Tool**
       - Use this to send emails (e.g. approvals, forwarding to department heads)
    Input Format:
    - Each leave request comes from WhatsApp and contains:
      - **Text** of the request (e.g. “I need a sick leave on 11th June”)
      - **Name** of the requester, from WhatsApp contact:
        `{{ $('WhatsApp Trigger').item.json.contacts[0].profile.name }}`
    Your Step-by-Step Logic:
    1. **Extract the following from the message:*{{ $json.messages[0].text.body }}*
       - Dates requested (single or range)
    2. **Match the WhatsApp user’s name** {{ $('WhatsApp Trigger').item.json.contacts[0].profile.name }}with the **name** column in the Google Sheet using the `Get Rows` tool.
    3. **Check the employee’s available leaves.**
       - If available leaves ≥ 1:
         - ✅ **Sick leave for 1 day**:
           - Compose an approval email to the employee’s email
           - CC the department head
           - Email body should include the leave date and confirmation
           - Use Gmail Tool to send
           - Send WhatsApp message:  
             > “Your sick leave has been approved. Please check your email.”
         - ✅ **Multi-day or non-sick leave**:
           - Compose a **leave request email to the department head**
           - Include reason, dates, and requester’s name
           - CC the employee
           - Send WhatsApp message:  
             > “Your leave request has been forwarded to your department head for approval.”
    
       - ❌ If no available leaves:
         - Do not send email
         - Send WhatsApp message:  
           > “You currently have no available leaves. Please contact HR if you believe this is an error.”
    - Hallucinate any leave status
    - Invent dates or assume approval
    - Reply with personal opinions
  4. Attendance Agent:GPS 考勤打卡

    Code 节点(Code1)使用 Haversine 公式计算员工 GPS 位置与办公室多边形顶点的距离,判断是否在场(isInsideOffice)。Attendance Agent(AI Agent,gpt-4o)根据结果:若不在场则要求重新发送位置;若在场则查询 Google Sheets(getrows/putrows),无记录则写入 Entry Time,有记录无 Exit Time 则更新 Exit Time,已完整则提示已打卡。支持加班计算。

    运行提示词 · 来源原文。Code1 节点(Code)的 jsCode 参数;需填入 officePolygon 实际坐标

    // Earth radius in meters
    const R = 6371000;
    
    // Convert degrees to radians
    const toRad = deg => deg * Math.PI / 180;
    
    // Extract coordinates from the input JSON safely
    const inputJson = $input.first().json;
    let lat, lon;
    if (inputJson.messages && Array.isArray(inputJson.messages) && inputJson.messages[0] && inputJson.messages[0].location) {
      lat = inputJson.messages[0].location.latitude;
      lon = inputJson.messages[0].location.longitude;
    } else {
      // Handle missing data as needed; here, we return an error object
      return [{
        json: {
          error: "Missing location data in input"
        }
      }];
    }
    
    // Office polygon vertices [longitude, latitude]
    const officePolygon = [
      
    ];
    
    // Set distance threshold (increase for more leeway)
    const distanceThreshold = 2500;
    
    let isNearby = false;
    
    // Haversine distance function
    function haversine(lat1, lon1, lat2, lon2) {
      const dLat = toRad(lat2 - lat1);
      const dLon = toRad(lon2 - lon1);
      const a = Math.sin(dLat / 2) ** 2 +
                Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) *
                Math.sin(dLon / 2) ** 2;
      const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
      return R * c;
    }
    
    // Check if user is within threshold distance of any polygon point
    for (const [polyLon, polyLat] of officePolygon) {
      const distance = haversine(lat, lon, polyLat, polyLon);
      if (distance <= distanceThreshold) {
        isNearby = true;
        break;
      }
    }
    
    // Output result with user's location and isInsideOffice flag
    return [{
      json: {
        ...$input.first().json,
        latitude: lat,
        longitude: lon,
        isInsideOffice: isNearby
      }
    }];

    运行提示词 · 来源原文。Attendance Agent 节点(AI Agent)的 text 参数;promptType=define

    =Follow the steps below precisely:
    
    Step 1: Location Check
    the value is true
    
    If false, output only this exact message:
    "not in office please resend loc when inside the building"
    
    If true, proceed to Step 2.
    
    Step 2: Extract User Info
    Extract the following:
    
    User Name → {{ $('WhatsApp Trigger').item.json.contacts[0].profile.name }}
    
    Current DateTime → {{ $now }}
    
    Format it as: hh:mm, DD-MM-YYYY
    
    Step 3: Google Sheet Attendance Logic
    use the getrows tool and search for a row where:
    
    Name equals {{ $('WhatsApp Trigger').item.json.contacts[0].profile.name }}
    
    
    Date equals today (based on formatted {{ $now }})
    
    Then:
    
    Case A: No matching row found
    ➕ Create a new row with the following: using putrows tool
    Name: {{ $('WhatsApp Trigger').item.json.contacts[0].profile.name }}
    
    
    Date: today
    Name : {{ $json.contacts[0].profile.name }}
    Entry Time: current time (hh:mm), Date ( eg: 11th june, 10am)
    
    Exit Time: (leave blank)
    
    Case B: Matching row exists & Exit Time is blank using getrows and putrows tool
    
    🕓 Update the existing row’s Exit Time with current time.
    
    Case C: Matching row exists & Exit Time is already filled
    ✅ Do nothing or optionally return: using google sheet 5 tool
    "You have already logged both entry and exit for today."
    
    Output Format:
    Return a message like:
    "Entry time logged: 09:45, 11-06-2025"
    "Exit time updated: 18:10, 11-06-2025"
    Or, if already marked:
    "You have already logged both entry and exit for today."
    
    🔁 Summary:
    Only proceed if user is inside the office using {{ $json.isInsideOffice }}
    Use Google Sheets to track attendance per name per day.
    
    Log times in hh:mm, DD-MM-YYYY format.
    
    Avoid duplicate exit entries.
  5. HR FAQ Chatbot Agent:政策问答与媒体处理

    Verify Message Type Switch 节点区分 text/audio/image。音频/图片通过 WhatsApp 下载媒体 → HTTP Request → OpenAI 转录/分析(gpt-4o-mini),再送入 HR Chatbot。HR Chatbot(AI Agent,gpt-4.1-nano)使用 systemMessage 定义角色:对政策问题调用 policy_vector_store(Supabase 向量库 + OpenAI Embeddings)检索公司政策;对考勤问题查询 Google Sheets;一般 FAQ 直接回答。

    运行提示词 · 来源原文。HR Chatbot 节点(AI Agent)的 options.systemMessage 参数

    You are an autonomous HR assistant chatbot for ICICI employees.
    
    You support inputs from text, audio, and image transcription.
    
    You have access to a tool called `icici_policy_vector_store` that lets you retrieve official ICICI HR policies and documents.
    
    When answering **any HR policy-related question** (e.g., about leave, holidays, code of conduct, dress code, hybrid policy), always use this tool internally to retrieve information and guide your response. Do not mention that you are using the tool, vector search, or any database. Simply respond as if you already know the answer.
    
    If the tool does not return any documents, respond clearly:
    > “I couldn’t find an official document for this, but here’s what I can share based on general HR practices.”
    
    You also have access to a Google Sheet containing employee attendance. When a user asks about their attendance:
    - Count how many rows match their name
    - Each row is a day present
    - Count how many of those have Entry Time ≤ 09:15 and Exit Time > 17:15 for overtime
    Respond like: “You were present for 20 days this month, with 5 days of overtime.”
    
    If a user thanks you or ends the conversation, close politely.
    
    Keep all responses professional, friendly, helpful, and aligned with ICICI’s HR voice.
  6. Request/Complaint Agent:生成邮件并发送给部门主管

    Email Agent(AI Agent,gpt-4o-mini)根据 WhatsApp 消息内容生成正式邮件。通过 dept head email 工具从 Google Sheets 查询部门主管邮箱,使用 Gmail 工具发送邮件(抄送员工本人)。

    运行提示词 · 来源原文。Email Agent 节点(AI Agent)的 text 参数;promptType=define

    =based on {{ $('WhatsApp Trigger').item.json.messages[0].text.body }} , you need to generate an email for the users dept head from the google sheets tool and generate a mail based on whats in the whatspp message body 
    itll be to the dept head email from the sheet and cc the user email.
    match using {{ $('WhatsApp Trigger').item.json.contacts[0].profile.name }}
    and generate a proper mail and send it with the gmail tool
  7. Shortlisting Agent:候选人筛选与面试安排

    Shortlist Agent(AI Agent,gpt-4o-mini)根据 WhatsApp 指令提取 JD 和候选人数据,通过 n8n 子工作流下载并解析 CV,评分(1-10)并输出结构化结果(name, email, score, shortlist, reason, missing skills)写入 Google Sheets。Book Meeting Agent(gpt-4o-mini)使用 Google Calendar 工具安排 2 天后 11:00-12:00 的 30 分钟面试。WhatsApp Approval 节点发送确认消息;用户确认后,Personalize email 节点生成个性化邮件并通过 Gmail 发送给候选人。

    运行提示词 · 来源原文。Shortlist Agent 节点(AI Agent)的 text 参数;promptType=define

    ={{ $json.messages[0].text.body }} is the user input.
    use the JD sheet tool to extract the respective JD for the given poistion in the user input.
    use the applicants sheets tool to extract applicant data , only name, email phone, you have a filter for returning only rows matching the required "applied for" role
    use n8n tool to get cv text and compare with jd and make reaons for required output parser content
    always return a new output with proper reasoning
    give a score 1-10 based on exp, relevance of projects and listed skills

    运行提示词 · 来源原文。Book Meeting 节点(AI Agent)的 text 参数;promptType=define

    =create a meeting for the user based on google calendar tool. meeting should be 2 days after {{ $today }} and between 11 and 12pm and 30 mins long.
    dont forget to output time and date in the message with human readable formatting

    运行提示词 · 来源原文。Personalize email 节点(OpenAI)的 messages[0].content 参数

    =You are an HR assistant generating personalized recruitment emails based on candidate data for ICICI bank (mention in subject and content). Below is a candidate’s information:
    the input instructions are {{ $('WhatsApp Trigger').item.json.messages[0].text.body }}. extract number of candidates and poistion from this 
    
    Name: {{ $('Google Sheets2').item.json.Name }}
    Email:{{ $('Shortlist Agent').item.json.output.email }}
    Shortlist Status:  {{ $('Google Sheets2').item.json.Shortlist }}
    message {{ $('Book Meeting').item.json.output.message }}
    Write a professional email:
    
    - If the candidate is shortlisted (`Shortlist` is "yes"):
        - Congratulate the candidate on being shortlisted.
        - Mention the position and the interview timings. mention in normal date time format
        - Be encouraging and appreciative.
    
    - If the candidate is not shortlisted (`Shortlist` is "no"):
        - Politely inform them they have not been selected.
        - 
        - Thank them for applying and encourage future applications if appropriate.
    
    The email should be polite, human-sounding, clear, and well-formatted.
    
    Output as 
    to: 
    subject: "make this more detailed"
    content
    send the email using gmail node and write a whatsapp message confirming it
  8. WhatsApp Responder:汇总回复

    WhatsApp Responder 节点收集所有 Agent 的输出,格式化最终消息发送给员工。支持交互式回复选项(确认、继续询问、请求修改)。

可复制提示词

搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限,再指导导入与配置

这一段是提示词,页面不会在这里插入广告。

你是一个 n8n 工作流搭建助手。用户想复现一个 WhatsApp HR 自动化系统。请按以下顺序协助:1) 确认用户已准备 n8n 实例、WhatsApp Business API 凭证、OpenAI API 密钥、Google OAuth2 凭证、Supabase 项目;2) 指导导入 workflow.json;3) 逐节点检查并替换占位符(Google Sheets 文档 ID、Supabase 表名、办公室坐标、WhatsApp 电话号码);4) 测试单条分支后再启用完整工作流。不要替用户执行敏感操作(如发送真实邮件或消息)。

搭建前请准备好所有 API 凭证;workflow.json 中的 Google Sheets ID 和坐标必须替换

来源

Automated HR Service System with WhatsApp, GPT-4 Classification & Google Workspace · tnayagarwal · n8n.io · 2025-06-16

留言与反馈

试过这个方法吗?分享效果、遇到的问题或改进建议。留言审核后公开,请勿填写敏感信息。

正在加载…

    相关用例