{
  "name": "Telegram Task Manager - Part 1",
  "nodes": [
    {
      "parameters": {
        "path": "telegram-webhook",
        "responseMode": "onReceived",
        "authentication": "none",
        "options": {}
      },
      "name": "Telegram Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        450,
        300
      ],
      "id": "3c5c8b6a-86d4-4c8b-8e1f-2d9f8c7b6a1e"
    },
    {
      "parameters": {
        "value": "={{ $json.message.text }}",
        "rules": {
          "rules": [
            {
              "value2": "/themviec",
              "operation": "startsWith",
              "output": 0
            },
            {
              "value2": "/xemviec",
              "operation": "startsWith",
              "output": 1
            },
            {
              "value2": "/hoanthanh",
              "operation": "startsWith",
              "output": 2
            },
            {
              "value2": "/xoa",
              "operation": "startsWith",
              "output": 3
            }
          ]
        }
      },
      "name": "Switch Command",
      "type": "n8n-nodes-base.switch",
      "position": [
        680,
        300
      ],
      "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef"
    },
    {
      "parameters": {
        "functionCode": "const message = $node['Telegram Webhook'].json.message;\nconst text = message.text;\nconst command = \"/themviec \";\nlet taskDetails = text.substring(command.length).trim();\nlet taskName = taskDetails;\nlet reminderTimeString = null;\nif (taskDetails.includes('@')) {\n  const parts = taskDetails.split('@');\n  taskName = parts[0].trim();\n  reminderTimeString = parts[1].trim();\n}\nconst chatId = message.chat.id;\nconst originalMessageId = message.message_id;\nconst taskId = `${originalMessageId}_${chatId}`;\nconst result = {\n  taskId: taskId,\n  chatId: chatId,\n  taskName: taskName,\n  status: 'pending',\n  createdAt: new Date().toISOString(),\n  originalMessageId: originalMessageId,\n};\nif (reminderTimeString) {\n  result.reminderTimeString = reminderTimeString;\n}\nreturn [{ json: result }];"
      },
      "name": "ParseThemViecInput",
      "type": "n8n-nodes-base.function",
      "position": [
        900,
        -100
      ],
      "id": "b2c3d4e5-f6a7-b8c9-d0e1-f2a3b4c5d6e7"
    },
    {
      "parameters": {
        "conditions": {
          "conditions": [
            {
              "value1": "={{ $json.reminderTimeString }}",
              "operation": "isNotEmpty"
            }
          ]
        }
      },
      "name": "HasReminderTime",
      "type": "n8n-nodes-base.if",
      "position": [
        1120,
        -100
      ],
      "id": "c3d4e5f6-a7b8-c9d0-e1f2-a3b4c5d6e7f8"
    },
    {
      "parameters": {
        "functionCode": "const reminderTimeString = $node['ParseThemViecInput'].json.reminderTimeString;\nconst date = new Date(reminderTimeString);\nconst isoReminderTime = date.toISOString();\nreturn [{ json: { isoReminderTime: isoReminderTime } }];"
      },
      "name": "FormatReminderTime",
      "type": "n8n-nodes-base.function",
      "position": [
        1340,
        -200
      ],
      "id": "d4e5f6a7-b8c9-d0e1-f2a3-b4c5d6e7f8g9"
    },
    {
      "parameters": {
        "mode": "mergeByIndex"
      },
      "name": "MergeThemViecData",
      "type": "n8n-nodes-base.merge",
      "position": [
        1340,
        -50
      ],
      "id": "e5f6a7b8-c9d0-e1f2-a3b4-c5d6e7f8g9h0"
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "append",
        "spreadsheetId": "1IqMBoaBEfV4O2D3-gk9ywNSevD4kGNG2w5jApHaTQmUm",
        "sheetName": "Tasks",
        "valueInputOption": "RAW",
        "values": "={{ [ [$json.taskId, $json.chatId, $json.taskName, $json.isoReminderTime || null, $json.status, $json.createdAt, $json.originalMessageId] ] }}"
      },
      "name": "AddRowToGoogleSheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1560,
        -50
      ],
      "credentials": {
        "googleSheetsOAuth2Api": "<your credential>"
      },
      "id": "f6a7b8c9-d0e1-f2a3-b4c5-d6e7f8g9h0i1"
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "=\u0110\u00e3 th\u00eam c\u00f4ng vi\u1ec7c: \"{{ $json.taskName }}\"\nTask ID: {{ $json.taskId }}\n{{ $json.isoReminderTime ? \"S\u1ebd nh\u1eafc b\u1ea1n v\u00e0o l\u00fac: \" + new Date($json.isoReminderTime).toLocaleString('vi-VN', { dateStyle: 'full', timeStyle: 'short', timeZone: 'Asia/Ho_Chi_Minh' }) : \"Kh\u00f4ng c\u00f3 nh\u1eafc nh\u1edf.\" }}",
        "additionalFields": {
          "reply_to_message_id": "={{ $json.originalMessageId }}"
        }
      },
      "name": "SendThemViecConfirmation",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1780,
        -50
      ],
      "credentials": {
        "telegramApi": "<your credential>"
      },
      "id": "a7b8c9d0-e1f2-a3b4-c5d6-e7f8g9h0i1j2"
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "getRows",
        "spreadsheetId": "1IqMBoaBEfV4O2D3-gk9ywNSevD4kGNG2w5jApHaTQmUm",
        "sheetName": "Tasks",
        "range": "Tasks!A:G"
      },
      "name": "GetTasksFromSheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        900,
        150
      ],
      "credentials": {
        "googleSheetsOAuth2Api": "<your credential>"
      },
      "id": "b8c9d0e1-f2a3-b4c5-d6e7-f8g9h0i1j2k3"
    },
    {
      "parameters": {
        "functionCode": "const tasks = $items();\nconst chatId = $node['Telegram Webhook'].json.message.chat.id;\nconst originalMessageId = $node['Telegram Webhook'].json.message.message_id;\nlet responseMessage = '\ud83d\udccb **Danh s\u00e1ch c\u00f4ng vi\u1ec7c:**\n';\nif (tasks.length === 0) {\n  responseMessage = 'Kh\u00f4ng c\u00f3 c\u00f4ng vi\u1ec7c n\u00e0o.';\n} else {\n  tasks.forEach((task, index) => {\n    const { TaskID, TaskName, Status, ReminderTime } = task.json;\n    responseMessage += `${index + 1}. ${TaskName} (ID: ${TaskID}, Tr\u1ea1ng th\u00e1i: ${Status})${ReminderTime ? ', Nh\u1eafc nh\u1edf: ' + new Date(ReminderTime).toLocaleString('vi-VN', { timeZone: 'Asia/Ho_Chi_Minh' }) : ''}\n`;\n  });\n}\nreturn [{ json: { responseMessage, chatId, originalMessageId } }];"
      },
      "name": "FormatTaskList",
      "type": "n8n-nodes-base.function",
      "position": [
        1120,
        150
      ],
      "id": "new-id-for-format-task-list"
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "={{ $json.responseMessage }}",
        "additionalFields": {
          "reply_to_message_id": "={{ $json.originalMessageId }}"
        }
      },
      "name": "SendTaskList",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1340,
        150
      ],
      "credentials": {
        "telegramApi": "<your credential>"
      },
      "id": "d0e1f2a3-b4c5-d6e7-f8g9-h0i1j2k3l4m5"
    },
    {
      "parameters": {
        "functionCode": "const text = $node['Telegram Webhook'].json.message.text;\nconst command = \"/hoanthanh \";\nconst taskIdToComplete = text.substring(command.length).trim();\nconst chatId = $node['Telegram Webhook'].json.message.chat.id;\nconst originalMessageId = $node['Telegram Webhook'].json.message.message_id;\nif (!taskIdToComplete) {\n  return [{ json: { error: \"Vui l\u00f2ng cung c\u1ea5p TaskID. V\u00ed d\u1ee5: /hoanthanh Your_Task_ID\", chatId: chatId, originalMessageId: originalMessageId} }];\n}\nreturn [{ json: { taskIdToComplete: taskIdToComplete, chatId: chatId, originalMessageId: originalMessageId }}];"
      },
      "name": "ParseHoanThanhInput",
      "type": "n8n-nodes-base.function",
      "position": [
        900,
        380
      ],
      "id": "e1f2a3b4-c5d6-e7f8-g9h0-i1j2k3l4m5n6"
    },
    {
      "parameters": {
        "conditions": {
          "conditions": [
            {
              "value1": "={{ $json.error }}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "name": "CheckHoanThanhError",
      "type": "n8n-nodes-base.if",
      "position": [
        1120,
        380
      ],
      "id": "f2a3b4c5-d6e7-f8g9-h0i1-j2k3l4m5n6o7"
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "getRows",
        "spreadsheetId": "1IqMBoaBEfV4O2D3-gk9ywNSevD4kGNG2w5jApHaTQmUm",
        "sheetName": "Tasks",
        "range": "Tasks!A:G"
      },
      "name": "GetAllTasksForUpdate",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1340,
        300
      ],
      "credentials": {
        "googleSheetsOAuth2Api": "<your credential>"
      },
      "id": "a3b4c5d6-e7f8-g9h0-i1j2-k3l4m5n6o7p8"
    },
    {
      "parameters": {
        "functionCode": "const allTasks = $items();\nconst parseHoanThanhInputData = $node['ParseHoanThanhInput'].json;\nconst taskIdToUpdate = parseHoanThanhInputData.taskIdToComplete;\nconst currentUserChatId = parseHoanThanhInputData.chatId.toString();\nconst originalMessageId = parseHoanThanhInputData.originalMessageId;\n\nlet rowIndexToUpdate = -1;\nlet taskNameToConfirm = '';\nlet foundAndAuthorized = false;\n\nfor (let i = 0; i < allTasks.length; i++) {\n  const task = allTasks[i].json;\n  if (task.TaskID === taskIdToUpdate) {\n    if (task.ChatID && task.ChatID.toString() === currentUserChatId) {\n        if (task.Status && task.Status.toLowerCase() === 'pending') {\n            rowIndexToUpdate = i + 2; // Google Sheets rows are 1-indexed, headers are row 1, so data starts at row 2\n            taskNameToConfirm = task.TaskName;\n            foundAndAuthorized = true;\n            break;\n        } else {\n            return [{ json: { error: `C\u00f4ng vi\u1ec7c \\\"${task.TaskName}\\\" (ID: ${taskIdToUpdate}) \u0111\u00e3 \u1edf tr\u1ea1ng th\u00e1i \\\"${task.Status}\\\".`, chatId: currentUserChatId, originalMessageId: originalMessageId }}];\n        }\n    } else {\n        return [{ json: { error: `B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n v\u1edbi TaskID: ${taskIdToUpdate}.`, chatId: currentUserChatId, originalMessageId: originalMessageId }}];\n    }\n  }\n}\n\nif (!foundAndAuthorized) {\n  return [{ json: { error: `Kh\u00f4ng t\u00ecm th\u1ea5y TaskID: ${taskIdToUpdate} ho\u1eb7c b\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n.`, chatId: currentUserChatId, originalMessageId: originalMessageId }}];\n}\n\nreturn [{ json: { rowIndex: rowIndexToUpdate, newStatus: 'completed', taskName: taskNameToConfirm, chatId: currentUserChatId, originalMessageId: originalMessageId, taskIdCompleted: taskIdToUpdate }}];"
      },
      "name": "FindRowAndUpdateStatus",
      "type": "n8n-nodes-base.function",
      "position": [
        1560,
        300
      ],
      "id": "b4c5d6e7-f8g9-h0i1-j2k3-l4m5n6o7p8q9"
    },
    {
      "parameters": {
        "conditions": {
          "conditions": [
            {
              "value1": "={{ $json.error }}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "name": "CheckFindHoanThanhError",
      "type": "n8n-nodes-base.if",
      "position": [
        1780,
        300
      ],
      "id": "c5d6e7f8-g9h0-i1j2-k3l4-m5n6o7p8q9r0"
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "update",
        "spreadsheetId": "1IqMBoaBEfV4O2D3-gk9ywNSevD4kGNG2w5jApHaTQmUm",
        "sheetName": "Tasks",
        "rowIndex": "={{ $json.rowIndex }}",
        "valueInputOption": "RAW",
        "values": "={{ [ [$json.newStatus] ] }}"
      },
      "name": "UpdateTaskStatusInSheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2000,
        220
      ],
      "credentials": {
        "googleSheetsOAuth2Api": "<your credential>"
      },
      "id": "d6e7f8g9-h0i1-j2k3-l4m5-n6o7p8q9r0s1"
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "=\u2705 \u0110\u00e3 ho\u00e0n th\u00e0nh c\u00f4ng vi\u1ec7c: \"{{ $json.taskName }}\" (ID: `{{ $json.taskIdCompleted }}`)",
        "additionalFields": {
          "reply_to_message_id": "={{ $json.originalMessageId }}"
        }
      },
      "name": "SendHoanThanhConfirmation",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2220,
        220
      ],
      "credentials": {
        "telegramApi": "<your credential>"
      },
      "id": "e7f8g9h0-i1j2-k3l4-m5n6-o7p8q9r0s1t2"
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "={{ $json.error }}",
        "additionalFields": {
          "reply_to_message_id": "={{ $json.originalMessageId }}"
        }
      },
      "name": "SendHoanThanhError",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1340,
        460
      ],
      "credentials": {
        "telegramApi": "<your credential>"
      },
      "id": "f8g9h0i1-j2k3-l4m5-n6o7-p8q9r0s1t2u3"
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "={{ $json.error }}",
        "additionalFields": {
          "reply_to_message_id": "={{ $json.originalMessageId }}"
        }
      },
      "name": "SendFindHoanThanhError",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2000,
        380
      ],
      "credentials": {
        "telegramApi": "<your credential>"
      },
      "id": "g9h0i1j2-k3l4-m5n6-o7p8-q9r0s1t2u3v4"
    },
    {
      "parameters": {
        "functionCode": "const text = $node['Telegram Webhook'].json.message.text;\nconst command = \"/xoa \";\nconst taskIdToDelete = text.substring(command.length).trim();\nconst chatId = $node['Telegram Webhook'].json.message.chat.id;\nconst originalMessageId = $node['Telegram Webhook'].json.message.message_id;\nif (!taskIdToDelete) {\n  return [{ json: { error: \"Vui l\u00f2ng cung c\u1ea5p TaskID. V\u00ed d\u1ee5: /xoa Your_Task_ID\", chatId: chatId, originalMessageId: originalMessageId} }];\n}\nreturn [{ json: { taskIdToDelete: taskIdToDelete, chatId: chatId, originalMessageId: originalMessageId }}];"
      },
      "name": "ParseXoaInput",
      "type": "n8n-nodes-base.function",
      "position": [
        900,
        600
      ],
      "id": "h0i1j2k3-l4m5-n6o7-p8q9-r0s1t2u3v4w5"
    },
    {
      "parameters": {
        "conditions": {
          "conditions": [
            {
              "value1": "={{ $json.error }}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "name": "CheckXoaError",
      "type": "n8n-nodes-base.if",
      "position": [
        1120,
        600
      ],
      "id": "i1j2k3l4-m5n6-o7p8-q9r0-s1t2u3v4w5x6"
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "getRows",
        "spreadsheetId": "1IqMBoaBEfV4O2D3-gk9ywNSevD4kGNG2w5jApHaTQmUm",
        "sheetName": "Tasks",
        "range": "Tasks!A:G"
      },
      "name": "GetAllTasksForDelete",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1340,
        520
      ],
      "credentials": {
        "googleSheetsOAuth2Api": "<your credential>"
      },
      "id": "j2k3l4m5-n6o7-p8q9-r0s1-t2u3v4w5x6y7"
    },
    {
      "parameters": {
        "functionCode": "const allTasks = $items();\nconst parseXoaInputData = $node['ParseXoaInput'].json;\nconst taskIdToDelete = parseXoaInputData.taskIdToDelete;\nconst currentUserChatId = parseXoaInputData.chatId.toString();\nconst originalMessageId = parseXoaInputData.originalMessageId;\n\nlet rowIndexToDelete = -1;\nlet taskNameToConfirm = '';\nlet foundAndAuthorized = false;\n\nfor (let i = 0; i < allTasks.length; i++) {\n  const task = allTasks[i].json;\n  if (task.TaskID === taskIdToDelete) {\n    if (task.ChatID && task.ChatID.toString() === currentUserChatId) {\n        rowIndexToDelete = i + 2; // Google Sheets rows are 1-indexed, headers are row 1, so data starts at row 2\n        taskNameToConfirm = task.TaskName;\n        foundAndAuthorized = true;\n        break;\n    } else {\n        return [{ json: { error: `B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n x\u00f3a TaskID: ${taskIdToDelete}.`, chatId: currentUserChatId, originalMessageId: originalMessageId }}];\n    }\n  }\n}\n\nif (!foundAndAuthorized) {\n  return [{ json: { error: `Kh\u00f4ng t\u00ecm th\u1ea5y TaskID \u0111\u1ec3 x\u00f3a: ${taskIdToDelete} ho\u1eb7c b\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n.`, chatId: currentUserChatId, originalMessageId: originalMessageId }}];\n}\n\nreturn [{ json: { rowIndex: rowIndexToDelete, taskName: taskNameToConfirm, chatId: currentUserChatId, originalMessageId: originalMessageId, taskIdDeleted: taskIdToDelete }}];"
      },
      "name": "FindRowToDelete",
      "type": "n8n-nodes-base.function",
      "position": [
        1560,
        520
      ],
      "id": "k3l4m5n6-o7p8-q9r0-s1t2-u3v4w5x6y7z8"
    },
    {
      "parameters": {
        "conditions": {
          "conditions": [
            {
              "value1": "={{ $json.error }}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "name": "CheckFindXoaError",
      "type": "n8n-nodes-base.if",
      "position": [
        1780,
        520
      ],
      "id": "l4m5n6o7-p8q9-r0s1-t2u3-v4w5x6y7z8a9"
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "delete",
        "spreadsheetId": "1IqMBoaBEfV4O2D3-gk9ywNSevD4kGNG2w5jApHaTQmUm",
        "sheetName": "Tasks",
        "rowIndex": "={{ $json.rowIndex }}"
      },
      "name": "DeleteTaskFromSheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2000,
        440
      ],
      "credentials": {
        "googleSheetsOAuth2Api": "<your credential>"
      },
      "id": "m5n6o7p8-q9r0-s1t2-u3v4-w5x6y7z8a9b0"
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "=\ud83d\uddd1\ufe0f \u0110\u00e3 x\u00f3a c\u00f4ng vi\u1ec7c: \"{{ $json.taskName }}\" (ID: `{{ $json.taskIdDeleted }}`)",
        "additionalFields": {
          "reply_to_message_id": "={{ $json.originalMessageId }}"
        }
      },
      "name": "SendXoaConfirmation",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2220,
        440
      ],
      "credentials": {
        "telegramApi": "<your credential>"
      },
      "id": "n6o7p8q9-r0s1-t2u3-v4w5-x6y7z8a9b0c1"
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "={{ $json.error }}",
        "additionalFields": {
          "reply_to_message_id": "={{ $json.originalMessageId }}"
        }
      },
      "name": "SendXoaErrorParse",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1340,
        680
      ],
      "credentials": {
        "telegramApi": "<your credential>"
      },
      "id": "o7p8q9r0-s1t2-u3v4-w5x6-y7z8a9b0c1d2"
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "={{ $json.error }}",
        "additionalFields": {
          "reply_to_message_id": "={{ $json.originalMessageId }}"
        }
      },
      "name": "SendFindXoaError",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2000,
        600
      ],
      "credentials": {
        "telegramApi": "<your credential>"
      },
      "id": "p8q9r0s1-t2u3-v4w5-x6y7-z8a9b0c1d2e3"
    },
    {
      "parameters": {
        "chatId": "={{ $node['Telegram Webhook'].json.message.chat.id }}",
        "text": "\ud83d\ude15 Xin l\u1ed7i, t\u00f4i kh\u00f4ng hi\u1ec3u l\u1ec7nh c\u1ee7a b\u1ea1n.\nVui l\u00f2ng s\u1eed d\u1ee5ng m\u1ed9t trong c\u00e1c l\u1ec7nh sau:\n\u2022 `/themviec [N\u1ed9i dung c\u00f4ng vi\u1ec7c]`\n\u2022 `/themviec [N\u1ed9i dung c\u00f4ng vi\u1ec7c] @ [Th\u1eddi gian nh\u1eafc]`\n  (V\u00ed d\u1ee5 th\u1eddi gian: \"ng\u00e0y mai 10h\", \"25/12 14:30\")\n\u2022 `/xemviec`\n\u2022 `/hoanthanh [TaskID]`\n\u2022 `/xoa [TaskID]`",
        "additionalFields": {
          "reply_to_message_id": "={{ $node['Telegram Webhook'].json.message.message_id }}"
        }
      },
      "name": "SendInvalidCommandMessage",
      "type": "n8n-nodes-base.telegram",
      "position": [
        900,
        800
      ],
      "credentials": {
        "telegramApi": "<your credential>"
      },
      "id": "q9r0s1t2-u3v4-w5x6-y7z8-a9b0c1d2e3f4"
    }
  ],
  "connections": {
    "Telegram Webhook": {
      "main": [
        [
          {
            "node": "Switch Command",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch Command": {
      "main": [
        [
          {
            "node": "ParseThemViecInput",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "GetTasksFromSheet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ParseHoanThanhInput",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ParseXoaInput",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "SendInvalidCommandMessage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ParseThemViecInput": {
      "main": [
        [
          {
            "node": "HasReminderTime",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HasReminderTime": {
      "main": [
        [
          {
            "node": "FormatReminderTime",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "MergeThemViecData",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "FormatReminderTime": {
      "main": [
        [
          {
            "node": "MergeThemViecData",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MergeThemViecData": {
      "main": [
        [
          {
            "node": "AddRowToGoogleSheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AddRowToGoogleSheet": {
      "main": [
        [
          {
            "node": "SendThemViecConfirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetTasksFromSheet": {
      "main": [
        [
          {
            "node": "FormatTaskList",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FormatTaskList": {
      "main": [
        [
          {
            "node": "SendTaskList",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ParseHoanThanhInput": {
      "main": [
        [
          {
            "node": "CheckHoanThanhError",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CheckHoanThanhError": {
      "main": [
        [
          {
            "node": "GetAllTasksForUpdate",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "SendHoanThanhError",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetAllTasksForUpdate": {
      "main": [
        [
          {
            "node": "FindRowAndUpdateStatus",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FindRowAndUpdateStatus": {
      "main": [
        [
          {
            "node": "CheckFindHoanThanhError",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CheckFindHoanThanhError": {
      "main": [
        [
          {
            "node": "UpdateTaskStatusInSheet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "SendFindHoanThanhError",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UpdateTaskStatusInSheet": {
      "main": [
        [
          {
            "node": "SendHoanThanhConfirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ParseXoaInput": {
      "main": [
        [
          {
            "node": "CheckXoaError",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CheckXoaError": {
      "main": [
        [
          {
            "node": "GetAllTasksForDelete",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "SendXoaErrorParse",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetAllTasksForDelete": {
      "main": [
        [
          {
            "node": "FindRowToDelete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FindRowToDelete": {
      "main": [
        [
          {
            "node": "CheckFindXoaError",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CheckFindXoaError": {
      "main": [
        [
          {
            "node": "DeleteTaskFromSheet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "SendFindXoaError",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DeleteTaskFromSheet": {
      "main": [
        [
          {
            "node": "SendXoaConfirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "timezone": "Asia/Ho_Chi_Minh"
  },
  "id": "a0b1c2d3-e4f5-a6b7-c8d9-e0f1a2b3c4d5",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": [
    {
      "id": "1",
      "name": "Telegram"
    },
    {
      "id": "2",
      "name": "Google Sheets"
    },
    {
      "id": "3",
      "name": "Task Management"
    }
  ]
}