8
n8n 中文网amn8n.com

我的智能日历代理

高级

这是一个Support Chatbot, AI Chatbot领域的自动化工作流,包含 23 个节点。主要使用 Set, Code, WhatsApp, Agent, WhatsAppTrigger 等节点。 使用自然语言通过 WhatsApp 安排会议,集成 Gemini AI 和 Google Suite

前置要求
  • Google Sheets API 凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "O16uLHqzb7kXJH0u",
  "meta": {
    "instanceId": "65ec47be00b0ac600ad20c40dd4664274304bcd19e969a4326853865046a0fae",
    "templateCredsSetupCompleted": true
  },
  "name": "我的智能日历代理",
  "tags": [],
  "nodes": [
    {
      "id": "bb61c707-22be-4816-8bc9-8303a17a372d",
      "name": "意图代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -272,
        144
      ],
      "parameters": {
        "text": "=User query: {{ $json.messages[0].text.body }}",
        "options": {
          "systemMessage": "=# Overview\nYou are a calendar assistant. Your job is to look at the incoming query and determine the intent.\n\n## Tools\nContacts Data - Use this tool to get contact information like email address. This tool must be used if the user requests to create an event with an attendee. If no attendee is specified, you don't need to use this tool.\nGet_Events - Use this to get events when the user wants to create, delete, or update an event. You should provide details about the event to confirm it is the right one to delete or update.\n\n## Rules\n- You must always get events using the 'Get_Events' tool to make sure there are no scheduling conflicts.\n- When you are asked to move, update, or delete an event, you must use 'Get_Events' to confirm the event. You must output the event details like date, time, and any attendee emails\n\n## Output\n- You must output the request from the user and ask any clarification questions.\n- Always output the email of the contact the user requested if requested.\n- If there are two records of contact information for a single name, output the email and the type of contact.\n\n## Final notes\nHere is the current date/time: {{ $now }}"
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "66efefea-3c23-4399-869c-b551dd2b73c6",
      "name": "获取_事件",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        -320,
        320
      ],
      "parameters": {
        "options": {},
        "timeMax": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Before', `11:59 PM of the day the user requested`, 'string') }}",
        "timeMin": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('After', `12:01 AM of the day the user requested`, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "=yourmail@gmail.com"
        },
        "operation": "getAll",
        "returnAll": true
      },
      "typeVersion": 1.3
    },
    {
      "id": "a3037cd8-650a-4fa2-a524-b41a02d2047a",
      "name": "设置意图",
      "type": "n8n-nodes-base.set",
      "position": [
        144,
        -320
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "3ab6c175-d35c-48a3-a9db-5162f962d5f9",
              "name": "intent",
              "type": "string",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9254a734-712f-485a-8e5d-fe398cbc9e3a",
      "name": "检查反馈",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        544,
        -320
      ],
      "parameters": {
        "options": {},
        "inputText": "={{ $json.data.text }}",
        "categories": {
          "categories": [
            {
              "category": "Approved",
              "description": "The human is confirming or agreeing with our request. This means they acknowledge that the provided information or action is correct and ready to proceed. Approval messages often include phrases like:\n\n\"Yes\"\n\"Looks good to me\"\n\"Send it\"\n\"Correct\"\n\"Approved\"\n\"That works\"\n\"Sounds good\"\n\"Go ahead\""
            },
            {
              "category": "Denied",
              "description": "The human is providing feedback that does not indicate approval. This could include requests for changes, corrections, or additional clarifications. A denial may also involve specifying a type of email, like 'business' or 'personal'.\n\nExamples \"Denied\" phrases:\n'business'\n'change the time'\n'personal'\n'delete both'\n'delete the first one'\n'today'\n'tomorrow'\n'february 22nd'"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "317055fd-c0a8-4946-b3e8-d1282cf7e611",
      "name": "修正代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        832,
        -192
      ],
      "parameters": {
        "text": "=Original intent: {{ $('Set Intent').item.json.intent }}\n\nHuman feedback: {{ $json.data.text }}",
        "options": {
          "systemMessage": "=# Overview\nYou are a correction agent. Your job is to look at the original output, and correct it based on the human feedback.\n\n## Output\n- Your job is to output the new intent of the request. \n- Always include all of the details required like email address of attendees, time, date, summary, etc.\n- Ask a clarification question if necessary. If there is nothing to clarify, just ask \"Is this correct?\""
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "47535e2e-d291-456f-84ff-d3497b91a613",
      "name": "日历代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1296,
        112
      ],
      "parameters": {
        "text": "={{ $('Set Intent').item.json.intent }}",
        "options": {
          "systemMessage": "=# Overview You are a calendar assistant. Your responsibilities include creating, getting, and deleting events in the user's calendar. **Calendar Management Tools** - Use \"Create Event with Attendee\" when an event includes a participant. - Use \"Create Event\" for solo events. - Use \"Get Events\" to fetch calendar schedules when requested. - Use \"Delete Event\" to delete an event. You must use \"Get Events\" first to get the ID of the event to delete. - Use \"Update Event\" to update an event. You must use \"Get Events\" first to get the ID of the event to update. ## Rules - Turn the incoming query into an action. Ignore clarification questions, just take action based on the intent you receive. ## Final Notes Here is the current date/time: {{ $now }} If a duration for an event isn't specified, assume it will be one hour."
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "1ea90a5c-1340-4262-ab79-e2bc812c93a6",
      "name": "创建事件",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        1184,
        320
      ],
      "parameters": {
        "end": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', ``, 'string') }}",
        "start": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', ``, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "=yourmail@gmail.com"
        },
        "additionalFields": {
          "summary": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Summary', ``, 'string') }}"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "edc4be29-f410-483e-bd88-d27be6554b92",
      "name": "创建带参与者的活动",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        1312,
        320
      ],
      "parameters": {
        "end": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', ``, 'string') }}",
        "start": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', ``, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "=yourmail@gmail.com"
        },
        "additionalFields": {
          "summary": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Summary', ``, 'string') }}",
          "attendees": [
            "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Attendees', ``, 'string') }}"
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "f1398793-9d9a-4ed4-b819-ea800825616b",
      "name": "更新事件",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        1440,
        320
      ],
      "parameters": {
        "eventId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Event_ID', ``, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "electronicsjamshaid@gmail.com",
          "cachedResultName": "electronicsjamshaid@gmail.com"
        },
        "operation": "update",
        "updateFields": {
          "end": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', ``, 'string') }}",
          "start": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', ``, 'string') }}"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "85270aec-5307-49f5-9d93-81e0b7b9487b",
      "name": "删除事件",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        1568,
        320
      ],
      "parameters": {
        "eventId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Event_ID', ``, 'string') }}",
        "options": {},
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "=yourmail@gmail.com"
        },
        "operation": "delete"
      },
      "typeVersion": 1.3
    },
    {
      "id": "6dfbc357-cad7-4dba-bbfa-316a85a077ea",
      "name": "联系人数据",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -80,
        320
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1u_VppYHt9GUdH0FPIGm2lzd1kCstP9M_0qtgUt6rqqc/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1u_VppYHt9GUdH0FPIGm2lzd1kCstP9M_0qtgUt6rqqc",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1u_VppYHt9GUdH0FPIGm2lzd1kCstP9M_0qtgUt6rqqc/edit?usp=drivesdk",
          "cachedResultName": "Contacts Data"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "a42bb1c2-1cf5-43e3-bb71-1d3c5a2b04c8",
      "name": "WhatsApp触发器",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        -528,
        144
      ],
      "webhookId": "39ad8bd7-37fa-4065-9cb5-1e3e31ef661d",
      "parameters": {
        "options": {},
        "updates": [
          "messages"
        ]
      },
      "typeVersion": 1
    },
    {
      "id": "c56ea940-cd86-4c3a-869c-e806c86ef10d",
      "name": "发送消息并等待回复",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        336,
        -320
      ],
      "webhookId": "85d87aac-bffc-44c8-80e5-ae76431bd50a",
      "parameters": {
        "message": "={{ $('Intent Agent').item.json.output }}",
        "options": {
          "appendAttribution": false
        },
        "operation": "sendAndWait",
        "responseType": "freeText",
        "phoneNumberId": "={{ $('WhatsApp Trigger').item.json.metadata.phone_number_id }}",
        "recipientPhoneNumber": "={{ $('WhatsApp Trigger').item.json.messages[0].from }}"
      },
      "typeVersion": 1
    },
    {
      "id": "f90cf33d-da10-4894-9d3a-7e84e4b18a81",
      "name": "回复",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        1904,
        176
      ],
      "webhookId": "fc39e55a-f360-448e-b2fe-32348b672014",
      "parameters": {
        "textBody": "={{ $json.output }}",
        "operation": "send",
        "phoneNumberId": "={{ $('WhatsApp Trigger').item.json.metadata.phone_number_id }}",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $('WhatsApp Trigger').item.json.messages[0].from }}"
      },
      "typeVersion": 1
    },
    {
      "id": "149ef5a1-56d8-4374-93cc-19832b39bc80",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        1680,
        176
      ],
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.myNewField = 1;\n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "195a0592-d0b5-40d7-b64e-3bf3b7fa27cf",
      "name": "Google Gemini聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        576,
        272
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "ca6525e2-801a-4c30-9874-4cd5c80dc807",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -576,
        32
      ],
      "parameters": {
        "color": 5,
        "width": 640,
        "height": 432,
        "content": "# 捕获请求"
      },
      "typeVersion": 1
    },
    {
      "id": "0083842a-aaaf-4481-abf9-098b47bdc013",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -432
      ],
      "parameters": {
        "color": 3,
        "width": 1056,
        "height": 432,
        "content": "# 验证详情"
      },
      "typeVersion": 1
    },
    {
      "id": "3d7749da-c962-4de9-a816-7599850c4e5a",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1152,
        32
      ],
      "parameters": {
        "color": 4,
        "width": 944,
        "height": 432,
        "content": "# 安排活动并通知"
      },
      "typeVersion": 1
    },
    {
      "id": "5ba2c7a4-8834-4db6-8640-43baab2b0c04",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        176
      ],
      "parameters": {
        "color": 6,
        "width": 256,
        "height": 256,
        "content": "## 聊天模型"
      },
      "typeVersion": 1
    },
    {
      "id": "983ddfc3-3b01-4ab0-a939-aa6ee3974180",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        -544
      ],
      "parameters": {
        "color": 7,
        "width": 768,
        "height": 80,
        "content": "# Muhammad Ali Zubair | AI自动化专家"
      },
      "typeVersion": 1
    },
    {
      "id": "093dda17-8ede-47f0-8614-8ba727d53cd0",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1392,
        -368
      ],
      "parameters": {
        "width": 720,
        "height": 832,
        "content": "# 🤖 AI WhatsApp日历助手"
      },
      "typeVersion": 1
    },
    {
      "id": "39e8dcc1-129c-4fc0-bb17-12e050bbda3c",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2128,
        -432
      ],
      "parameters": {
        "color": 6,
        "width": 704,
        "height": 1120,
        "content": "# ⚙️ 设置说明"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {
    "WhatsApp Trigger": [
      {
        "json": {
          "field": "messages",
          "contacts": [
            {
              "wa_id": "923415204286",
              "profile": {
                "name": "Chargex"
              }
            }
          ],
          "messages": [
            {
              "id": "wamid.HBgMOTIzNDE1MjA0Mjg2FQIAEhggMkMzQTE0QzFGNzA0QzQzRTYwMEJBOTgwNzgwM0M3RjYA",
              "from": "923415204286",
              "text": {
                "body": "schedule meeting with John at 10am on 27 August"
              },
              "type": "text",
              "timestamp": "1756309631"
            }
          ],
          "metadata": {
            "phone_number_id": "688851804316760",
            "display_phone_number": "923709351768"
          },
          "messaging_product": "whatsapp"
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "e9dafb17-f19e-4852-b454-1a4fc9d77020",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get_Events": {
      "ai_tool": [
        [
          {
            "node": "Intent Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Set Intent": {
      "main": [
        [
          {
            "node": "Send message and wait for response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Event": {
      "ai_tool": [
        [
          {
            "node": "Calendar Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Delete Event": {
      "ai_tool": [
        [
          {
            "node": "Calendar Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Intent Agent": {
      "main": [
        [
          {
            "node": "Set Intent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Event": {
      "ai_tool": [
        [
          {
            "node": "Calendar Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Contacts Data": {
      "ai_tool": [
        [
          {
            "node": "Intent Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calendar Agent": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Feedback": {
      "main": [
        [
          {
            "node": "Calendar Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Correction Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Correction Agent": {
      "main": [
        [
          {
            "node": "Set Intent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp Trigger": {
      "main": [
        [
          {
            "node": "Intent Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Intent Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Check Feedback",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Correction Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Calendar Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Create Event with Attendee": {
      "ai_tool": [
        [
          {
            "node": "Calendar Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Send message and wait for response": {
      "main": [
        [
          {
            "node": "Check Feedback",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 客服机器人, AI 聊天机器人

需要付费吗?

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

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

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

作者
Muhammad Ali

Muhammad Ali

@ali01

Transforming Business Workflows into Revenue Engines with n8n. From Marketing to Sales Ops, I Design Automations that Save Time and Increase Profits. Connect with me on LinkedIn for Custom Solutions.

外部链接
在 n8n.io 查看

分享此工作流