Prueba

    Esto es una prueba

    Shared 10/19/2025

    31 views

    Visual Workflow

    JSON Code

    {
      "meta": {
        "instanceId": "c4d12dcf03cd5ac8a4aa510afa317642b3f3ad61d09cb68bcefb5b7da6c219a4",
        "templateCredsSetupCompleted": true
      },
      "nodes": [
        {
          "id": "7fbb4a68-97b9-498a-807a-9f88c537e5a9",
          "name": "Telegram Trigger",
          "type": "n8n-nodes-base.telegramTrigger",
          "position": [
            -16,
            -16
          ],
          "webhookId": "b647bdc9-5834-44b4-b7b6-635431a3cf66",
          "parameters": {
            "updates": [
              "message"
            ],
            "additionalFields": {}
          },
          "credentials": {
            "telegramApi": {
              "id": "tV8HbClQeh8OapHa",
              "name": "Telegram account"
            }
          },
          "typeVersion": 1.2
        },
        {
          "id": "f0f367bf-bafd-4641-bd4a-cb9bc164114e",
          "name": "Switch",
          "type": "n8n-nodes-base.switch",
          "position": [
            208,
            -48
          ],
          "parameters": {
            "rules": {
              "values": [
                {
                  "outputKey": "START",
                  "conditions": {
                    "options": {
                      "version": 2,
                      "leftValue": "",
                      "caseSensitive": true,
                      "typeValidation": "strict"
                    },
                    "combinator": "and",
                    "conditions": [
                      {
                        "id": "d57bc9de-583e-483f-b948-20810b8df8af",
                        "operator": {
                          "type": "string",
                          "operation": "startsWith"
                        },
                        "leftValue": "={{ $json.message.text }}",
                        "rightValue": "/start"
                      }
                    ]
                  },
                  "renameOutput": true
                },
                {
                  "outputKey": "HELP",
                  "conditions": {
                    "options": {
                      "version": 2,
                      "leftValue": "",
                      "caseSensitive": true,
                      "typeValidation": "strict"
                    },
                    "combinator": "and",
                    "conditions": [
                      {
                        "id": "2cc42532-81de-41fc-9fa2-8e49615e4b51",
                        "operator": {
                          "type": "string",
                          "operation": "startsWith"
                        },
                        "leftValue": "={{ $json.message.text }}",
                        "rightValue": "/help"
                      }
                    ]
                  },
                  "renameOutput": true
                },
                {
                  "outputKey": "TAREAS",
                  "conditions": {
                    "options": {
                      "version": 2,
                      "leftValue": "",
                      "caseSensitive": true,
                      "typeValidation": "strict"
                    },
                    "combinator": "and",
                    "conditions": [
                      {
                        "id": "35c95d7a-895e-40c1-9b0f-84112228707b",
                        "operator": {
                          "name": "filter.operator.equals",
                          "type": "string",
                          "operation": "equals"
                        },
                        "leftValue": "={{ $json.message.text }}",
                        "rightValue": "/tareas"
                      }
                    ]
                  },
                  "renameOutput": true
                },
                {
                  "conditions": {
                    "options": {
                      "version": 2,
                      "leftValue": "",
                      "caseSensitive": true,
                      "typeValidation": "strict"
                    },
                    "combinator": "and",
                    "conditions": [
                      {
                        "id": "2e40c64c-4d09-4bb3-a163-8c001da9ef75",
                        "operator": {
                          "type": "string",
                          "operation": "startsWith"
                        },
                        "leftValue": "={{ $json.message.text }}",
                        "rightValue": "/nueva"
                      }
                    ]
                  }
                }
              ]
            },
            "options": {}
          },
          "typeVersion": 3.3
        },
        {
          "id": "dfb3fdce-937f-4ef1-8305-3d1a759e730f",
          "name": "Send a text message",
          "type": "n8n-nodes-base.telegram",
          "position": [
            432,
            -304
          ],
          "webhookId": "0691b871-4b0e-4e26-bd4d-8d8dbfad2e43",
          "parameters": {
            "text": "=👋 ¡Hola {{$json[\"message\"][\"from\"][\"first_name\"]}}!\nSoy tu asistente de tareas.  \nUsa /help para ver lo que puedo hacer.",
            "chatId": "={{ $json.message.from.id }}",
            "additionalFields": {
              "appendAttribution": false
            }
          },
          "credentials": {
            "telegramApi": {
              "id": "tV8HbClQeh8OapHa",
              "name": "Telegram account"
            }
          },
          "typeVersion": 1.2
        },
        {
          "id": "ad3e5fc2-938e-427a-b3a3-af45c82a9e42",
          "name": "Send a text message1",
          "type": "n8n-nodes-base.telegram",
          "position": [
            432,
            -112
          ],
          "webhookId": "c8f6be3b-1eb0-4c12-845c-1b46bba18932",
          "parameters": {
            "text": "=Estos son los comandos disponibles:\n\n/start - arranca el bot\n/help - muestra esta ayuda\n/tareas - obtiene las tareas pendientes",
            "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
            "additionalFields": {
              "appendAttribution": false
            }
          },
          "credentials": {
            "telegramApi": {
              "id": "tV8HbClQeh8OapHa",
              "name": "Telegram account"
            }
          },
          "typeVersion": 1.2
        },
        {
          "id": "7a105b6c-f96d-46a8-bbec-3f8ae97272e2",
          "name": "Get row(s)",
          "type": "n8n-nodes-base.dataTable",
          "position": [
            432,
            80
          ],
          "parameters": {
            "filters": {
              "conditions": [
                {
                  "keyName": "estado",
                  "keyValue": "pendiente"
                }
              ]
            },
            "operation": "get",
            "dataTableId": {
              "__rl": true,
              "mode": "list",
              "value": "RfKrGLjVtPUFar6S",
              "cachedResultUrl": "/projects/xnHx8OZDIWFd2LvX/datatables/RfKrGLjVtPUFar6S",
              "cachedResultName": "tareas_pendientes"
            }
          },
          "typeVersion": 1
        },
        {
          "id": "df7ed20f-2665-420d-b516-6e7163e33c54",
          "name": "Send a text message2",
          "type": "n8n-nodes-base.telegram",
          "position": [
            1104,
            80
          ],
          "webhookId": "f81e381b-2691-4a76-8d59-95e5886dcc5f",
          "parameters": {
            "text": "={{ $json.mensaje }}",
            "chatId": "={{ $json.chatId }}",
            "additionalFields": {
              "appendAttribution": false
            }
          },
          "credentials": {
            "telegramApi": {
              "id": "tV8HbClQeh8OapHa",
              "name": "Telegram account"
            }
          },
          "typeVersion": 1.2
        },
        {
          "id": "a4e0270b-a715-470a-91fb-6a0ba334f201",
          "name": "Code in JavaScript",
          "type": "n8n-nodes-base.code",
          "position": [
            880,
            80
          ],
          "parameters": {
            "jsCode": "// Unir todas las tareas en un único mensaje\nconst tareasPendientes = $input.all().map(item => {\n  const { tarea, prioridad } = item.json;\n  return `• ${tarea} (${prioridad})`;\n}).join('\\n');\n\n// Devolver un único item con el mensaje final\nreturn [\n  {\n    json: {\n      mensaje: `📋 *Tareas pendientes:*\\n${tareasPendientes}`,\n      chatId: $input.first().json.chatId\n    }\n  }\n];\n"
          },
          "typeVersion": 2
        },
        {
          "id": "3ee1649a-72dd-4406-a9f5-62d3d0b8e7e2",
          "name": "addChatId",
          "type": "n8n-nodes-base.set",
          "position": [
            656,
            80
          ],
          "parameters": {
            "options": {},
            "assignments": {
              "assignments": [
                {
                  "id": "e9ed7e61-90ba-46be-b5aa-393f62dc2b59",
                  "name": "chatId",
                  "type": "string",
                  "value": "={{ $('Telegram Trigger').item.json.message.from.id }}"
                }
              ]
            },
            "includeOtherFields": true
          },
          "typeVersion": 3.4
        },
        {
          "id": "34ce93be-8625-4102-ad9f-28f47bf3ecef",
          "name": "Sticky Note",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            640,
            -368
          ],
          "parameters": {
            "width": 224,
            "height": 208,
            "content": "## RAMA 1\nRecibe los datos de Telegram si el mensaje recibido es /start"
          },
          "typeVersion": 1
        },
        {
          "id": "12d5bf56-859b-4732-b7e1-eb8a5709af35",
          "name": "Sticky Note1",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            640,
            -128
          ],
          "parameters": {
            "color": 4,
            "width": 224,
            "height": 144,
            "content": "## RAMA 2\nRecibe los datos de Telegram si el mensaje recibido es /help"
          },
          "typeVersion": 1
        },
        {
          "id": "926c11bf-d349-4fbc-8d4a-ec96f07b6943",
          "name": "Sticky Note2",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            1312,
            64
          ],
          "parameters": {
            "color": 2,
            "width": 224,
            "height": 144,
            "content": "## RAMA 3\nRecibe los datos de Telegram si el mensaje recibido es /tareas"
          },
          "typeVersion": 1
        },
        {
          "id": "adf4d0bd-b345-4879-a7d5-05065a537922",
          "name": "Edit Fields",
          "type": "n8n-nodes-base.set",
          "position": [
            432,
            272
          ],
          "parameters": {
            "options": {},
            "assignments": {
              "assignments": [
                {
                  "id": "400ec247-80e9-4f1d-a1d3-fb3ed2389c55",
                  "name": "texto",
                  "type": "string",
                  "value": "={{ $json.message.text.replace('/nueva', '').trim() }}"
                }
              ]
            }
          },
          "typeVersion": 3.4
        },
        {
          "id": "c1214235-5956-4782-a1b2-dff58bda07b4",
          "name": "Send message and wait for response",
          "type": "n8n-nodes-base.telegram",
          "position": [
            656,
            272
          ],
          "webhookId": "5554be72-2e3c-4b65-ab5e-5f82480a2d4c",
          "parameters": {
            "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
            "message": "Rellena el resto de datos relacionados con la tarea",
            "options": {
              "appendAttribution": false,
              "messageButtonLabel": "Datos para la nueva tarea",
              "responseFormCustomCss": ":root {\n  --font-family: 'Open Sans', sans-serif;\n  --font-weight-normal: 400;\n  --font-weight-bold: 600;\n  --font-size-body: 12px;\n  --font-size-label: 14px;\n  --font-size-test-notice: 12px;\n  --font-size-input: 14px;\n  --font-size-header: 20px;\n  --font-size-paragraph: 14px;\n  --font-size-link: 12px;\n  --font-size-error: 12px;\n  --font-size-html-h1: 28px;\n  --font-size-html-h2: 20px;\n  --font-size-html-h3: 16px;\n  --font-size-html-h4: 14px;\n  --font-size-html-h5: 12px;\n  --font-size-html-h6: 10px;\n  --font-size-subheader: 14px;\n\n  /* Colors adaptados */\n  --color-background: #f7f8fa;         /* fondo claro adaptado a tu estilo */\n  --color-test-notice-text: #ff9f43;   /* tono de aviso adaptado */\n  --color-test-notice-bg: #fff8f1;\n  --color-test-notice-border: #ffe3c6;\n  --color-card-bg: #ffffff;\n  --color-card-border: #dfe2e6;\n  --color-card-shadow: rgba(0, 0, 0, 0.04); /* sombra ligera adaptada */\n  --color-link: #1e6ffb;                /* azul acción de enlace adaptado */\n  --color-header: #2d2f32;\n  --color-label: #4a4c50;\n  --color-input-border: #dfe2e6;\n  --color-input-text: #585b60;\n  --color-focus-border: #1e6ffb;        /* el mismo azul para foco */\n  --color-submit-btn-bg: #1e6ffb;       /* botón principal azul */\n  --color-submit-btn-text: #ffffff;\n  --color-error: #e03131;               /* color de error más intenso */\n  --color-required: #e03131;\n  --color-clear-button-bg: #4a4c50;\n  --color-html-text: #4a4c50;\n  --color-html-link: #1e6ffb;\n  --color-header-subtext: #6b6d70;\n\n  /* Border Radii */\n  --border-radius-card: 8px;\n  --border-radius-input: 6px;\n  --border-radius-clear-btn: 50%;\n  --card-border-radius: 8px;\n\n  /* Spacing */\n  --padding-container-top: 24px;\n  --padding-card: 24px;\n  --padding-test-notice-vertical: 12px;\n  --padding-test-notice-horizontal: 24px;\n  --margin-bottom-card: 16px;\n  --padding-form-input: 12px;\n  --card-padding: 24px;\n  --card-margin-bottom: 16px;\n\n  /* Dimensions */\n  --container-width: 448px;\n  --submit-btn-height: 48px;\n  --checkbox-size: 18px;\n\n  /* Others */\n  --box-shadow-card: 0px 4px 16px 0px var(--color-card-shadow);\n  --opacity-placeholder: 0.5;\n}\n",
              "responseFormButtonLabel": "Enviar"
            },
            "operation": "sendAndWait",
            "formFields": {
              "values": [
                {
                  "fieldLabel": "Nombre del responsable",
                  "requiredField": true
                },
                {
                  "fieldType": "dropdown",
                  "fieldLabel": "Prioridad",
                  "fieldOptions": {
                    "values": [
                      {
                        "option": "Alta"
                      },
                      {
                        "option": "Media"
                      },
                      {
                        "option": "Baja"
                      }
                    ]
                  },
                  "requiredField": true
                },
                {
                  "fieldType": "date",
                  "fieldLabel": "Fecha Límite",
                  "requiredField": true
                },
                {
                  "fieldName": "Estado",
                  "fieldType": "hiddenField",
                  "fieldValue": "pendiente"
                },
                {
                  "fieldName": "Texto",
                  "fieldType": "hiddenField",
                  "fieldValue": "={{ $json.texto }}"
                }
              ]
            },
            "responseType": "customForm"
          },
          "credentials": {
            "telegramApi": {
              "id": "tV8HbClQeh8OapHa",
              "name": "Telegram account"
            }
          },
          "typeVersion": 1.2
        },
        {
          "id": "c5ef8a92-e778-4ccf-b8f2-ace0c6cdf83f",
          "name": "Insert row",
          "type": "n8n-nodes-base.dataTable",
          "position": [
            880,
            272
          ],
          "parameters": {
            "columns": {
              "value": {
                "tarea": "={{ $json.data.Texto }}",
                "estado": "={{ $json.data.Estado }}",
                "prioridad": "={{ $json.data.Prioridad }}",
                "responsable": "={{ $json.data['Nombre del responsable'] }}",
                "fecha_limite": "={{ $json.data['Fecha Límite'] }}"
              },
              "schema": [
                {
                  "id": "tarea",
                  "type": "string",
                  "display": true,
                  "removed": false,
                  "readOnly": false,
                  "required": false,
                  "displayName": "tarea",
                  "defaultMatch": false
                },
                {
                  "id": "responsable",
                  "type": "string",
                  "display": true,
                  "removed": false,
                  "readOnly": false,
                  "required": false,
                  "displayName": "responsable",
                  "defaultMatch": false
                },
                {
                  "id": "prioridad",
                  "type": "string",
                  "display": true,
                  "removed": false,
                  "readOnly": false,
                  "required": false,
                  "displayName": "prioridad",
                  "defaultMatch": false
                },
                {
                  "id": "estado",
                  "type": "string",
                  "display": true,
                  "removed": false,
                  "readOnly": false,
                  "required": false,
                  "displayName": "estado",
                  "defaultMatch": false
                },
                {
                  "id": "fecha_limite",
                  "type": "dateTime",
                  "display": true,
                  "removed": false,
                  "readOnly": false,
                  "required": false,
                  "displayName": "fecha_limite",
                  "defaultMatch": false
                },
                {
                  "id": "fecha_notificacion",
                  "type": "dateTime",
                  "display": true,
                  "removed": true,
                  "readOnly": false,
                  "required": false,
                  "displayName": "fecha_notificacion",
                  "defaultMatch": false
                }
              ],
              "mappingMode": "defineBelow",
              "matchingColumns": [],
              "attemptToConvertTypes": false,
              "convertFieldsToString": false
            },
            "options": {},
            "dataTableId": {
              "__rl": true,
              "mode": "list",
              "value": "RfKrGLjVtPUFar6S",
              "cachedResultUrl": "/projects/xnHx8OZDIWFd2LvX/datatables/RfKrGLjVtPUFar6S",
              "cachedResultName": "tareas_pendientes"
            }
          },
          "typeVersion": 1
        },
        {
          "id": "9d7731e5-163f-4037-b9b6-977774dc8b2c",
          "name": "Sticky Note3",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            1312,
            256
          ],
          "parameters": {
            "color": 5,
            "width": 224,
            "content": "## RAMA 4\n### Opcional\nAgrega una nueva tarea a la tabla mediante el comando /nueva"
          },
          "typeVersion": 1
        },
        {
          "id": "c9a51d8a-ab30-43ca-814e-5f98373242db",
          "name": "Send a text message3",
          "type": "n8n-nodes-base.telegram",
          "position": [
            1104,
            272
          ],
          "webhookId": "222d5b7c-af0e-42d0-a5bc-da5ef465b980",
          "parameters": {
            "text": "👍 Se ha creado la nueva tarea",
            "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
            "additionalFields": {}
          },
          "credentials": {
            "telegramApi": {
              "id": "tV8HbClQeh8OapHa",
              "name": "Telegram account"
            }
          },
          "typeVersion": 1.2
        }
      ],
      "pinData": {
        "Telegram Trigger": [
          {
            "message": {
              "chat": {
                "id": 7558487,
                "type": "private",
                "username": "m_giron",
                "last_name": "Girón",
                "first_name": "Mario"
              },
              "date": 1760869740,
              "from": {
                "id": 7558487,
                "is_bot": false,
                "username": "m_giron",
                "last_name": "Girón",
                "first_name": "Mario",
                "language_code": "es"
              },
              "text": "/nueva Arreglar el VPS",
              "entities": [
                {
                  "type": "bot_command",
                  "length": 6,
                  "offset": 0
                }
              ],
              "message_id": 2
            },
            "update_id": 788690783
          }
        ]
      },
      "connections": {
        "Switch": {
          "main": [
            [
              {
                "node": "Send a text message",
                "type": "main",
                "index": 0
              }
            ],
            [
              {
                "node": "Send a text message1",
                "type": "main",
                "index": 0
              }
            ],
            [
              {
                "node": "Get row(s)",
                "type": "main",
                "index": 0
              }
            ],
            [
              {
                "node": "Edit Fields",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "addChatId": {
          "main": [
            [
              {
                "node": "Code in JavaScript",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Get row(s)": {
          "main": [
            [
              {
                "node": "addChatId",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Insert row": {
          "main": [
            [
              {
                "node": "Send a text message3",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Edit Fields": {
          "main": [
            [
              {
                "node": "Send message and wait for response",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Telegram Trigger": {
          "main": [
            [
              {
                "node": "Switch",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Code in JavaScript": {
          "main": [
            [
              {
                "node": "Send a text message2",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Send message and wait for response": {
          "main": [
            [
              {
                "node": "Insert row",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    }