我的工作流
高级
这是一个Support Chatbot, AI Chatbot领域的自动化工作流,包含 32 个节点。主要使用 If, Code, Switch, Telegram, GoogleSheets 等节点。 集成 Google 日历和 Sheets 的 Telegram 预约调度机器人
前置要求
- •Telegram Bot Token
- •Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "5JULEkgK2wDftVHr",
"meta": {
"instanceId": "2dee634c602faefa427bcb2bb35486341c695a76ae2228c1c1392d276a2a4657",
"templateCredsSetupCompleted": true
},
"name": "我的工作流",
"tags": [],
"nodes": [
{
"id": "7d54054d-f2d6-43dc-a323-0ff3c9cf4811",
"name": "Telegram触发器",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
-1600,
592
],
"webhookId": "f58cafd7-8951-40a0-9d72-5750fe8f8734",
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "E8JczYL88dmAFsU6",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "dca7347f-c874-42b4-bab9-0b4c86e7b54e",
"name": "Google Calendar MCP",
"type": "n8n-nodes-base.switch",
"position": [
-1232,
544
],
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "3d67f2fa-ab68-4d63-92d5-98e39a74e654",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.message.text }}",
"rightValue": "/start"
}
]
}
},
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "82403d8b-6194-41ab-a033-06c9d5f2491e",
"operator": {
"type": "string",
"operation": "startsWith"
},
"leftValue": "={{ $json.message.text }}",
"rightValue": "agendar "
}
]
}
},
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "882a2a60-bf83-4195-8347-3d3fcbc43dec",
"operator": {
"type": "string",
"operation": "startsWith"
},
"leftValue": "={{ $json.message.text }}",
"rightValue": "cancelar "
}
]
}
},
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "42e95cb5-de43-4724-bd5d-7521740b777d",
"operator": {
"type": "string",
"operation": "startsWith"
},
"leftValue": "={{ $json.message.text }}",
"rightValue": "citas "
}
]
}
}
]
},
"options": {
"fallbackOutput": "extra"
}
},
"typeVersion": 3.2
},
{
"id": "280a841b-1ba9-470a-9f4e-fdae5da9661d",
"name": "JavaScript 代码",
"type": "n8n-nodes-base.code",
"position": [
-736,
304
],
"parameters": {
"jsCode": "// Obtenemos los datos del mensaje como antes\nconst text = $input.first().json.message.text;\nconst parts = text.split(' ');\nconst date = parts[1];\nconst time = parts[2];\nconst name = parts.slice(3).join(' ');\n\n// 1. Define tu zona horaria para evitar errores\nconst zone = 'America/Guayaquil';\n\n// 2. Creamos un objeto de fecha REAL a partir del texto, especificando el formato y la zona horaria\nconst startDateTime = DateTime.fromFormat(`${date} ${time}`, 'yyyy-MM-dd HH:mm', { zone });\n\n// 3. Calculamos la hora de fin (1 hora después) usando el objeto que creamos\nconst endDateTime = startDateTime.plus({ hours: 1 });\n\n// 4. Devolvemos los datos listos para Google Calendar en el formato que necesita (ISO)\nreturn {\n name: name,\n summary: `Cita para ${name} - Bot CIAP`,\n startDateTime: startDateTime.toISO(),\n endDateTime: endDateTime.toISO()\n};"
},
"typeVersion": 2
},
{
"id": "086bc82f-dddf-4f03-bebd-54bcaec07ca7",
"name": "创建事件",
"type": "n8n-nodes-base.googleCalendar",
"position": [
0,
0
],
"parameters": {
"end": "={{ $('Code in JavaScript').item.json.endDateTime }}",
"start": "={{ $('Code in JavaScript').item.json.startDateTime }}",
"calendar": {
"__rl": true,
"mode": "list",
"value": "609c991f2d18dc48becef29cc15681413164f070e6e9c30caef0c54589a88f0d@group.calendar.google.com",
"cachedResultName": "Citas CIAP"
},
"remindersUi": {
"remindersValues": [
{
"method": "popup",
"minutes": 30
}
]
},
"additionalFields": {
"summary": "={{ $('Code in JavaScript').item.json.summary }}",
"attendees": [],
"description": "Cita CIAP agendada con Bot",
"conferenceDataUi": {
"conferenceDataValues": {
"conferenceSolution": "hangoutsMeet"
}
}
},
"useDefaultReminders": false
},
"credentials": {
"googleCalendarOAuth2Api": {
"id": "PqirkB1NsFBmCnEV",
"name": "Google Calendar account"
}
},
"typeVersion": 1.3
},
{
"id": "fba969c8-56d9-4173-8b61-6bf08a24e20c",
"name": "预约成功回复",
"type": "n8n-nodes-base.telegram",
"position": [
544,
0
],
"webhookId": "fbbaa02f-9ecf-42e0-ba21-54bc354c7733",
"parameters": {
"text": "=¡Tu cita ha sido agendada con éxito! ✅\n\n👤 *Nombre:* {{ $('Code in JavaScript').item.json.name }}\n\n📅 *Fecha y Hora:* {{ DateTime.fromISO($('Code in JavaScript').item.json.startDateTime).setLocale('es').toFormat(\"EEEE, dd 'de' MMMM 'de' yyyy 'a las' HH:mm\") }}\n\nRecibirás un recordatorio. ¡Te esperamos!",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"additionalFields": {
"parse_mode": "Markdown"
}
},
"credentials": {
"telegramApi": {
"id": "E8JczYL88dmAFsU6",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "6874d8cc-581a-4a48-8613-6f04e9dfd763",
"name": "初始机器人回复",
"type": "n8n-nodes-base.telegram",
"position": [
-896,
-192
],
"webhookId": "fbbaa02f-9ecf-42e0-ba21-54bc354c7733",
"parameters": {
"text": "¡Hola! 👋 ¡Bienvenido/a al Asistente Virtual de Citas!\n\nEstoy aquí para ayudarte a gestionar tus citas de forma rápida y sencilla.\n\n**🗓️ Para agendar una cita**\nUsa el siguiente formato exacto:\n`agendar AAAA-MM-DD HH:MM Tu Nombre Completo`\n\n*Ejemplo:*\n`agendar 2025-09-22 15:00 Ana Rodriguez`\n\n---\n\n**❌ Para cancelar una cita existente**\nUsa el mismo formato que usaste para agendar:\n`cancelar AAAA-MM-DD HH:MM Tu Nombre Completo`\n\n*Ejemplo:*\n`cancelar 2025-09-22 15:00 Ana Rodriguez`\n\n---\n\n**📋 Para ver tus próximas citas**\nSimplemente envía un mensaje con tu nombre:\n`citas Tu Nombre Completo`\n*Ejemplo: `citas Ana Rodriguez`*\n\nProcesaré tu solicitud y te enviaré una confirmación al instante.\n\nUna vez que envíes tu mensaje, procesaré tu solicitud y te enviaré una confirmación.",
"chatId": "={{ $json.message.chat.id }}",
"additionalFields": {
"parse_mode": "Markdown"
}
},
"credentials": {
"telegramApi": {
"id": "E8JczYL88dmAFsU6",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "ba6c34c1-e2d3-467a-9245-08919dc661d4",
"name": "获取多个事件",
"type": "n8n-nodes-base.googleCalendar",
"position": [
-464,
304
],
"parameters": {
"options": {},
"timeMax": "={{ $json.endDateTime }}",
"timeMin": "={{ $json.startDateTime }}",
"calendar": {
"__rl": true,
"mode": "list",
"value": "609c991f2d18dc48becef29cc15681413164f070e6e9c30caef0c54589a88f0d@group.calendar.google.com",
"cachedResultName": "Citas CIAP"
},
"operation": "getAll",
"returnAll": true
},
"credentials": {
"googleCalendarOAuth2Api": {
"id": "PqirkB1NsFBmCnEV",
"name": "Google Calendar account"
}
},
"notesInFlow": false,
"retryOnFail": false,
"typeVersion": 1.3,
"alwaysOutputData": true
},
{
"id": "b53a67b7-3c32-403c-a498-74084fbcbaf3",
"name": "条件判断",
"type": "n8n-nodes-base.if",
"position": [
-240,
304
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "e9199cc8-ccae-402f-9170-06d16542c4fa",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.isEmpty() }}",
"rightValue": 0
}
]
}
},
"typeVersion": 2.2
},
{
"id": "92ba97c4-45ae-44a5-a6f4-99e187db603e",
"name": "时间不可用回复",
"type": "n8n-nodes-base.telegram",
"position": [
80,
320
],
"webhookId": "fbbaa02f-9ecf-42e0-ba21-54bc354c7733",
"parameters": {
"text": "Lo siento, ese horario ya no está disponible.\n\n🗓️ Por favor, intenta con otra fecha u hora.",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"additionalFields": {
"parse_mode": "Markdown"
}
},
"credentials": {
"telegramApi": {
"id": "E8JczYL88dmAFsU6",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "7e7ae0c9-81f8-4372-bc55-9cefec839de7",
"name": "在 Google Sheets 中添加预约",
"type": "n8n-nodes-base.googleSheets",
"position": [
256,
0
],
"parameters": {
"columns": {
"value": {
"id": "={{ $json.id }}",
"Fecha ISO": "={{ $json.start.dateTime }}",
"Fecha y hora": "={{ DateTime.fromISO($('Code in JavaScript').item.json.startDateTime).setLocale('es').toFormat(\"EEEE, dd 'de' MMMM 'de' yyyy 'a las' HH:mm\") }}",
"Nombre Cliente": "={{ $('Code in JavaScript').item.json.name }}"
},
"schema": [
{
"id": "id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "id",
"defaultMatch": true,
"canBeUsedToMatch": true
},
{
"id": "Nombre Cliente",
"type": "string",
"display": true,
"required": false,
"displayName": "Nombre Cliente",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Fecha y hora",
"type": "string",
"display": true,
"required": false,
"displayName": "Fecha y hora",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Fecha ISO",
"type": "string",
"display": true,
"required": false,
"displayName": "Fecha ISO",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"id"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zDo2juIh2YkYZx1erqdhu5y5WC43iM0GV8LpMqov3UM/edit#gid=0",
"cachedResultName": "Hoja 1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1zDo2juIh2YkYZx1erqdhu5y5WC43iM0GV8LpMqov3UM",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zDo2juIh2YkYZx1erqdhu5y5WC43iM0GV8LpMqov3UM/edit?usp=drivesdk",
"cachedResultName": "Citas Agendadas"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "1O2F3aS1ySR6zH7n",
"name": "Google Sheets account"
}
},
"typeVersion": 4.7
},
{
"id": "1f56c7fd-e275-42a9-93cf-583651a8d965",
"name": "默认机器人回复",
"type": "n8n-nodes-base.telegram",
"position": [
-976,
1392
],
"webhookId": "fbbaa02f-9ecf-42e0-ba21-54bc354c7733",
"parameters": {
"text": "🤔 No entendí tu mensaje.\n\nRecuerda los comandos disponibles:\n\n• Envía /start para ver el mensaje de bienvenida.\n• Para agendar una cita, usa el formato:\n`agendar AAAA-MM-DD HH:MM Tu Nombre Completo`",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"additionalFields": {
"parse_mode": "Markdown"
}
},
"credentials": {
"telegramApi": {
"id": "E8JczYL88dmAFsU6",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "d07fad71-b4f5-43b0-87b4-5abe0f2b13e0",
"name": "JavaScript 代码1",
"type": "n8n-nodes-base.code",
"position": [
-720,
720
],
"parameters": {
"jsCode": "// Obtenemos los datos del mensaje\nconst text = $input.first().json.message.text;\nconst parts = text.split(' ');\nconst date = parts[1];\nconst time = parts[2];\nconst name = parts.slice(3).join(' ');\n\n// Define tu zona horaria\nconst zone = 'America/Guayaquil'; // Asegúrate que sea la correcta\n\n// Creamos el objeto de fecha para buscar\nconst startDateTime = DateTime.fromFormat(`${date} ${time}`, 'yyyy-MM-dd HH:mm', { zone });\n\n// 3. Calculamos la hora de fin (1 hora después) usando el objeto que creamos\nconst endDateTime = startDateTime.plus({ hours: 1 });\n\n// Devolvemos los datos necesarios para la búsqueda\nreturn {\n name: name,\n summary: `Cita para ${name}`, // El título exacto que debe buscar\n startDateTime: startDateTime.toISO(),\n endDateTime: endDateTime.toISO()\n};"
},
"typeVersion": 2
},
{
"id": "9e01f0c5-68b1-44e7-b056-85b8576e6f84",
"name": "获取多个事件1",
"type": "n8n-nodes-base.googleCalendar",
"position": [
-464,
720
],
"parameters": {
"options": {},
"timeMax": "={{ $json.endDateTime }}",
"timeMin": "={{ $json.startDateTime }}",
"calendar": {
"__rl": true,
"mode": "list",
"value": "609c991f2d18dc48becef29cc15681413164f070e6e9c30caef0c54589a88f0d@group.calendar.google.com",
"cachedResultName": "Citas CIAP"
},
"operation": "getAll",
"returnAll": true
},
"credentials": {
"googleCalendarOAuth2Api": {
"id": "PqirkB1NsFBmCnEV",
"name": "Google Calendar account"
}
},
"notesInFlow": false,
"retryOnFail": false,
"typeVersion": 1.3,
"alwaysOutputData": true
},
{
"id": "6a2d5552-a1fa-449a-ac3d-e6fb8d4f498b",
"name": "如果 1",
"type": "n8n-nodes-base.if",
"position": [
-240,
720
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "61e695f8-6364-4e01-9456-ee5937b41cc5",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.isEmpty() }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "6da89bc2-2a60-4a00-87a9-026a59e9d3c8",
"name": "删除事件",
"type": "n8n-nodes-base.googleCalendar",
"position": [
208,
848
],
"parameters": {
"eventId": "={{ $json.id }}",
"options": {},
"calendar": {
"__rl": true,
"mode": "list",
"value": "609c991f2d18dc48becef29cc15681413164f070e6e9c30caef0c54589a88f0d@group.calendar.google.com",
"cachedResultName": "Citas CIAP"
},
"operation": "delete"
},
"credentials": {
"googleCalendarOAuth2Api": {
"id": "PqirkB1NsFBmCnEV",
"name": "Google Calendar account"
}
},
"typeVersion": 1.3
},
{
"id": "73d74b1e-9a18-49ef-abb9-d6191c892145",
"name": "从表格中删除行或列",
"type": "n8n-nodes-base.googleSheets",
"position": [
768,
848
],
"parameters": {
"operation": "delete",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zDo2juIh2YkYZx1erqdhu5y5WC43iM0GV8LpMqov3UM/edit#gid=0",
"cachedResultName": "Hoja 1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1zDo2juIh2YkYZx1erqdhu5y5WC43iM0GV8LpMqov3UM",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zDo2juIh2YkYZx1erqdhu5y5WC43iM0GV8LpMqov3UM/edit?usp=drivesdk",
"cachedResultName": "Citas Agendadas"
},
"startIndex": "={{ $json.row_number }}"
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "1O2F3aS1ySR6zH7n",
"name": "Google Sheets account"
}
},
"typeVersion": 4.7
},
{
"id": "bcc018ce-5b16-4caf-b27c-96ca2aa02d36",
"name": "预约取消回复",
"type": "n8n-nodes-base.telegram",
"position": [
1056,
848
],
"webhookId": "fbbaa02f-9ecf-42e0-ba21-54bc354c7733",
"parameters": {
"text": "✅ ¡Tu cita ha sido cancelada con éxito!",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"additionalFields": {
"parse_mode": "Markdown"
}
},
"credentials": {
"telegramApi": {
"id": "E8JczYL88dmAFsU6",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "09c000de-845b-4891-8a1d-6067a60a607b",
"name": "未找到预约回复",
"type": "n8n-nodes-base.telegram",
"position": [
208,
560
],
"webhookId": "fbbaa02f-9ecf-42e0-ba21-54bc354c7733",
"parameters": {
"text": "❌ No se encontró ninguna cita agendada con esos datos. Por favor, verifica la fecha, hora y nombre.",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"additionalFields": {
"parse_mode": "Markdown"
}
},
"credentials": {
"telegramApi": {
"id": "E8JczYL88dmAFsU6",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "75a7d2a8-dfba-4a6d-a596-ffb4a86cf2ad",
"name": "JavaScript 代码2",
"type": "n8n-nodes-base.code",
"position": [
-688,
1168
],
"parameters": {
"jsCode": "const text = $input.first().json.message.text;\n\n// \"citas\" es la 0, el nombre empieza en la 1\nconst name = text.split(' ').slice(1).join(' '); \n\n// Preparamos el término de búsqueda exacto para el título del evento\nconst searchTerm = `Cita para ${name}`;\n\nreturn {\n name: name,\n searchTerm: searchTerm\n};"
},
"typeVersion": 2
},
{
"id": "1e9e9e69-843f-43a7-b255-14e71accac05",
"name": "查找已安排的预约",
"type": "n8n-nodes-base.googleSheets",
"position": [
512,
848
],
"parameters": {
"options": {},
"filtersUI": {
"values": [
{
"lookupValue": "={{ $('If1').item.json.id }}",
"lookupColumn": "id"
}
]
},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zDo2juIh2YkYZx1erqdhu5y5WC43iM0GV8LpMqov3UM/edit#gid=0",
"cachedResultName": "Hoja 1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1zDo2juIh2YkYZx1erqdhu5y5WC43iM0GV8LpMqov3UM",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zDo2juIh2YkYZx1erqdhu5y5WC43iM0GV8LpMqov3UM/edit?usp=drivesdk",
"cachedResultName": "Citas Agendadas"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "1O2F3aS1ySR6zH7n",
"name": "Google Sheets account"
}
},
"typeVersion": 4.7
},
{
"id": "0b205172-0b74-4743-bf06-b28dafee3c93",
"name": "查找客户预约",
"type": "n8n-nodes-base.googleSheets",
"position": [
-448,
1168
],
"parameters": {
"options": {},
"filtersUI": {
"values": [
{
"lookupValue": "={{ $json.name }}",
"lookupColumn": "Nombre Cliente"
}
]
},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zDo2juIh2YkYZx1erqdhu5y5WC43iM0GV8LpMqov3UM/edit#gid=0",
"cachedResultName": "Hoja 1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1zDo2juIh2YkYZx1erqdhu5y5WC43iM0GV8LpMqov3UM",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zDo2juIh2YkYZx1erqdhu5y5WC43iM0GV8LpMqov3UM/edit?usp=drivesdk",
"cachedResultName": "Citas Agendadas"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "1O2F3aS1ySR6zH7n",
"name": "Google Sheets account"
}
},
"typeVersion": 4.7,
"alwaysOutputData": true
},
{
"id": "184d70ba-ad50-4f61-8f8c-286e0d387138",
"name": "If2",
"type": "n8n-nodes-base.if",
"position": [
-176,
1232
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "62047214-0958-4dcb-9b5f-0ccc359ba9de",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.isEmpty() }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "71052b88-b00e-49dd-a6a1-b78e7d3016ff",
"name": "未找到预约回复",
"type": "n8n-nodes-base.telegram",
"position": [
192,
1088
],
"webhookId": "fbbaa02f-9ecf-42e0-ba21-54bc354c7733",
"parameters": {
"text": "=🤔 No encontré ninguna cita futura agendada para {{ $('Code in JavaScript2').item.json.name }}. ",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"additionalFields": {
"parse_mode": "Markdown"
}
},
"credentials": {
"telegramApi": {
"id": "E8JczYL88dmAFsU6",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "deb3937c-cda4-45e1-b633-5b1017b9e88d",
"name": "JavaScript 代码3",
"type": "n8n-nodes-base.code",
"position": [
192,
1328
],
"parameters": {
"jsCode": "// 1. Recibe los datos que vienen del nodo IF.\n// Ya sabemos que no vienen vacíos, así que los procesamos directamente.\nconst citas = $items().map(item => item.json);\n\n// 2. Obtenemos la fecha y hora actual para comparar.\nconst ahora = DateTime.now();\n\n// 3. Filtramos para quedarnos solo con las citas futuras.\nconst citasFuturas = citas.filter(cita => {\n // Convertimos la \"Fecha ISO\" de la hoja de cálculo a un objeto de fecha real.\n const fechaCita = DateTime.fromISO(cita[\"Fecha ISO\"]);\n // Devolvemos 'true' solo si la fecha de la cita es posterior a ahora.\n return fechaCita > ahora;\n});\n\n// 4. Verificamos si, después de filtrar, nos quedamos sin citas.\nif (citasFuturas.length === 0) {\n // Tomamos el nombre del cliente de los datos originales para el mensaje.\n const nombreCliente = citas[0][\"Nombre Cliente\"];\n return {\n message: `Hola, ${nombreCliente}. 👋 Veo que tienes citas registradas en nuestro sistema, pero ninguna será en los próximos días.`\n };\n}\n\n// 5. Si SÍ hay citas futuras, construimos el mensaje de respuesta.\nconst nombreCliente = citasFuturas[0][\"Nombre Cliente\"];\nlet mensaje = `¡Hola, ${nombreCliente}! 👋 Aquí tienes un resumen de tus próximas citas:\\n\\n`;\n\nfor (const cita of citasFuturas) {\n // Usamos la columna \"Fecha y hora\" que ya tiene el formato amigable.\n mensaje += `🗓️ ${cita[\"Fecha y hora\"]}\\n`;\n}\n\n// Devolvemos el mensaje final listo para ser enviado.\nreturn {\n message: mensaje\n};"
},
"typeVersion": 2
},
{
"id": "c86aa958-6808-4d95-8d5b-e43bd07a0397",
"name": "预约成功回复1",
"type": "n8n-nodes-base.telegram",
"position": [
464,
1328
],
"webhookId": "fbbaa02f-9ecf-42e0-ba21-54bc354c7733",
"parameters": {
"text": "={{ $json.message }}",
"chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
"additionalFields": {
"parse_mode": "Markdown"
}
},
"credentials": {
"telegramApi": {
"id": "E8JczYL88dmAFsU6",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "81359378-4b13-4f3b-9692-fd48f6526a21",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1936,
592
],
"parameters": {
"color": 4,
"width": 256,
"height": 128,
"content": "## 起始点"
},
"typeVersion": 1
},
{
"id": "5466fa3f-0fc3-4e7e-9129-e53b5e519b75",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1392,
384
],
"parameters": {
"color": 5,
"width": 256,
"height": 128,
"content": "## 命令选项"
},
"typeVersion": 1
},
{
"id": "fb9456e4-6fd4-4c61-b34d-74c6d703542e",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-688,
-192
],
"parameters": {
"width": 208,
"height": 112,
"content": "## 帮助回复"
},
"typeVersion": 1
},
{
"id": "adecfb45-5b06-4617-9452-daff282c63d5",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-656,
112
],
"parameters": {
"color": 4,
"width": 464,
"height": 112,
"content": "## \"Agendar\" 模块"
},
"typeVersion": 1
},
{
"id": "de5e987a-fb6d-4c10-8c4b-4752e904e9ac",
"name": "便签说明4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-624,
560
],
"parameters": {
"color": 3,
"width": 464,
"height": 112,
"content": "## \"Cancelar\" 模块"
},
"typeVersion": 1
},
{
"id": "204d8550-367a-49fc-a171-b64b62542033",
"name": "便签说明5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-592,
1040
],
"parameters": {
"color": 2,
"width": 464,
"height": 80,
"content": "## \"Citas\" 模块"
},
"typeVersion": 1
},
{
"id": "3d2d5f40-d8ef-4610-b0fa-33fb9c86896e",
"name": "便签 6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-768,
1424
],
"parameters": {
"color": 2,
"width": 320,
"height": 96,
"content": "## 默认回复"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "70c8a269-0a1c-4f37-9ecd-df60620f10db",
"connections": {
"If": {
"main": [
[
{
"node": "Create an event",
"type": "main",
"index": 0
}
],
[
{
"node": "Respuesta Hora no disponible",
"type": "main",
"index": 0
}
]
]
},
"If1": {
"main": [
[
{
"node": "Respuesta Cita no encontrada",
"type": "main",
"index": 0
}
],
[
{
"node": "Delete an event",
"type": "main",
"index": 0
}
]
]
},
"If2": {
"main": [
[
{
"node": "Respuesta Citas no encontradas",
"type": "main",
"index": 0
}
],
[
{
"node": "Code in JavaScript3",
"type": "main",
"index": 0
}
]
]
},
"Switch": {
"main": [
[
{
"node": "Respuesta Bot Inicial",
"type": "main",
"index": 0
}
],
[
{
"node": "Code in JavaScript",
"type": "main",
"index": 0
}
],
[
{
"node": "Code in JavaScript1",
"type": "main",
"index": 0
}
],
[
{
"node": "Code in JavaScript2",
"type": "main",
"index": 0
}
],
[
{
"node": "Respuesta Bot Defecto",
"type": "main",
"index": 0
}
]
]
},
"Create an event": {
"main": [
[
{
"node": "Agregar cita en Google Sheets",
"type": "main",
"index": 0
}
]
]
},
"Delete an event": {
"main": [
[
{
"node": "Buscar cita agendada",
"type": "main",
"index": 0
}
]
]
},
"Get many events": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"Get many events1": {
"main": [
[
{
"node": "If1",
"type": "main",
"index": 0
}
]
]
},
"Telegram Trigger": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Code in JavaScript": {
"main": [
[
{
"node": "Get many events",
"type": "main",
"index": 0
}
]
]
},
"Code in JavaScript1": {
"main": [
[
{
"node": "Get many events1",
"type": "main",
"index": 0
}
]
]
},
"Code in JavaScript2": {
"main": [
[
{
"node": "Buscar citas de cliente",
"type": "main",
"index": 0
}
]
]
},
"Code in JavaScript3": {
"main": [
[
{
"node": "Respuesta de Cita Agendada1",
"type": "main",
"index": 0
}
]
]
},
"Buscar cita agendada": {
"main": [
[
{
"node": "Delete rows or columns from sheet",
"type": "main",
"index": 0
}
]
]
},
"Buscar citas de cliente": {
"main": [
[
{
"node": "If2",
"type": "main",
"index": 0
}
]
]
},
"Agregar cita en Google Sheets": {
"main": [
[
{
"node": "Respuesta de Cita Agendada",
"type": "main",
"index": 0
}
]
]
},
"Delete rows or columns from sheet": {
"main": [
[
{
"node": "Respuesta Cita Cancelada",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 客服机器人, AI 聊天机器人
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
ESPOLBot日历|常见问题
基于Telegram、MongoDB和Gemini AI的大学常见问题与日历助手
Set
Code
Html
+14
91 节点Club de Inteligencia Artificial Politécnico CIAP
客服机器人
使用Gemini、语音和图像生成构建多模态Telegram AI助手
使用Gemini、语音和图像生成构建多模态Telegram AI助手
If
Set
Code
+19
95 节点Iniyavan JC
个人效率
Telegram命令中心
使用Telegram机器人命令中心自动化工作流执行
If
Set
Code
+5
23 节点Amir
客服机器人
J.A.R.V.I.S.
在Telegram上使用OpenAI、SERP和向量存储构建全面的多模态助手
If
Set
Code
+16
48 节点FabioInTech
客服机器人
带有 Chatgpt Agent Prompt 检查的信用卡
AI驱动信用卡推荐系统,集成OpenAI GPT、Telegram和Google Sheets
If
Set
Code
+7
31 节点Nishant
AI 聊天机器人
宠物美容发布与预约自动化
使用AI、Facebook和Telegram机器人自动化宠物美容发布与预约
If
Set
Switch
+17
36 节点Christian Moises
AI 聊天机器人
工作流信息
难度等级
高级
节点数量32
分类2
节点类型8
作者
Club de Inteligencia Artificial Politécnico CIAP
@ciap外部链接
在 n8n.io 查看 →
分享此工作流