{
  "name": "ChatbotZalo",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-zalos-user.zaloLoginByQr",
      "typeVersion": 1,
      "position": [
        -1000,
        -560
      ],
      "id": "39989c82-c8af-46a7-b436-224b5f78b8bb",
      "name": "Zalo Login Via QR Code",
      "credentials": {
        "n8nZaloApi": {
          "id": "jDCWNnIhmbvVtc3F",
          "name": "n8n Zalo Account Credential account"
        },
        "zaloApi": {
          "id": "fkZrS93MRhu2vFWX",
          "name": "Zalo API Credentials"
        }
      }
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.query.url }}",
          "mode": "url"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -260,
        -560
      ],
      "id": "7f86de58-d63d-4772-808a-eba941f58da8",
      "name": "Google Drive",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "qwY2h3fXNNEXEv2I",
          "name": "Google Drive account 2"
        }
      }
    },
    {
      "parameters": {
        "content": "## Đăng nhập vào zalo",
        "height": 240,
        "width": 340
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1060,
        -660
      ],
      "typeVersion": 1,
      "id": "60c3470f-8cfa-48fb-a5bd-2f30c3db79f7",
      "name": "Sticky Note25"
    },
    {
      "parameters": {
        "content": "## Download File\n- Nhớ copy link Production URL thay vào trong node link ảnh drive",
        "height": 240,
        "width": 500
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        -660
      ],
      "typeVersion": 1,
      "id": "daa9cde0-227d-498d-b6b1-498dae9498ca",
      "name": "Sticky Note26"
    },
    {
      "parameters": {
        "content": "## Chạy lệnh tạo cơ sở dữ liệu\nXác thực với Postgress ở trên supabase rồi chạy lệnh này để auto tạo sẵn các bảng",
        "height": 300,
        "width": 960
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1060,
        -360
      ],
      "typeVersion": 1,
      "id": "1d722803-2ae1-41bd-a20e-51d954edf7cd",
      "name": "Sticky Note24"
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "create table public.zl_n8n_debounce (\n  id bigint generated by default as identity not null,\n  key text not null,\n  incr bigint null default '0'::bigint,\n  constraint zl_n8n_debounce_pkey primary key (id),\n  constraint zl_n8n_debounce_key_key unique (key)\n) TABLESPACE pg_default;",
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        -320,
        -240
      ],
      "id": "daa16a73-0783-40eb-aeb9-4faf00d4327f",
      "name": "CreateDebounceTable",
      "credentials": {
        "postgres": {
          "id": "GLfIWU3rbAidDMPe",
          "name": "Postgres account"
        }
      }
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "create table public.zl_included_users (\n  id bigint generated by default as identity not null,\n  from_id text not null,\n  to_id text null,\n  created_at timestamp with time zone not null default now(),\n  key text not null,\n  constraint zl_included_users_pkey primary key (id),\n  constraint zl_included_users_key_key unique (key),\n  constraint zl_included_users_key_key1 unique (key)\n) TABLESPACE pg_default;",
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        -540,
        -240
      ],
      "id": "c84619ed-cffb-4310-839a-4c4b4aa7da6d",
      "name": "CreateIncludedTable",
      "credentials": {
        "postgres": {
          "id": "GLfIWU3rbAidDMPe",
          "name": "Postgres account"
        }
      }
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "create table public.zl_chats (\n  id bigint generated by default as identity not null,\n  is_bot boolean null default true,\n  from_id text null,\n  d_name text null,\n  to_id text null,  \n  thread_id text null,\n  message_id text null,\n  text text null,\n  timestamp bigint null,\n  status character varying null default 'pending'::character varying,\n  created_at timestamp with time zone null default now(),\n  constraint zl_chats_pkey primary key (id),\n  constraint zl_chats_message_id_key unique (message_id)\n) TABLESPACE pg_default;\n",
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        -760,
        -240
      ],
      "id": "dbeb4adf-1ce4-42e9-8ee4-cdeeb7389361",
      "name": "CreateChatsTable",
      "credentials": {
        "postgres": {
          "id": "GLfIWU3rbAidDMPe",
          "name": "Postgres account"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -1020,
        -240
      ],
      "id": "62857251-b97c-40f0-a1f5-456db417ece9",
      "name": "When clicking ‘Test workflow’"
    },
    {
      "parameters": {
        "eventTypes": [
          0
        ],
        "selfListen": true
      },
      "type": "n8n-nodes-zalos-user.zaloMessageTrigger",
      "typeVersion": 1,
      "position": [
        -1040,
        660
      ],
      "id": "7e908423-61ec-4896-9261-f12be023a7cc",
      "name": "Zalo Message Trigger",
      "webhookId": "54f37947-1747-46f4-8e39-cc66e2b5103a",
      "credentials": {
        "zaloApi": {
          "id": "fkZrS93MRhu2vFWX",
          "name": "Zalo API Credentials"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "4db5ded9-cd1c-4f61-b92d-ef12f879c92d",
              "leftValue": "={{ $json.message.isSelf }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -580,
        660
      ],
      "id": "d53efe4e-35e1-4f24-b9b7-107c032f3a70",
      "name": "If"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.message.data.msgType }}",
                    "rightValue": "webchat",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "72612ffb-a0df-4276-9056-f3c5970aa96f"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "text"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "eebb2d88-989c-4816-ba75-dfc946717bac",
                    "leftValue": "={{ $json.message.data.msgType }}",
                    "rightValue": "chat.sticker",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "sticker"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -1040,
        1100
      ],
      "id": "0c69df2f-60e2-4053-b242-7f1224fd394c",
      "name": "Switch"
    },
    {
      "parameters": {
        "tableId": "zl_chats",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "from_id",
              "fieldValue": "={{ $('Data').item.json.from_id }}"
            },
            {
              "fieldId": "to_id",
              "fieldValue": "={{ $('Data').item.json.to_id }}"
            },
            {
              "fieldId": "thread_id",
              "fieldValue": "={{ $('Data').item.json.threadld }}"
            },
            {
              "fieldId": "timestamp",
              "fieldValue": "={{ $('Data').item.json.timestamp }}"
            },
            {
              "fieldId": "message_id",
              "fieldValue": "={{ $('Data').item.json.message_id }}"
            },
            {
              "fieldId": "text",
              "fieldValue": "={{ $('Data').item.json.text }}"
            },
            {
              "fieldId": "status",
              "fieldValue": "pending"
            },
            {
              "fieldId": "d_name",
              "fieldValue": "={{ $('Data').item.json.d_name }}"
            },
            {
              "fieldId": "is_bot",
              "fieldValue": "false"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -100,
        1100
      ],
      "id": "b89d275a-b87b-4b8c-9c32-44c9314bed75",
      "name": "SaveToChats",
      "credentials": {
        "supabaseApi": {
          "id": "XnneQjbtAW4FyfV2",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "content": "## Kiểm tra xem chủ zalo đã vào chát với người dùng chưa\n- Nếu chủ zalo đã tiếp nhận thì phải stop bot lại\n- Ở đây kiểm tra xem id người dùng này đã có trong danh sách đã tiếp nhận hay chưa",
        "height": 260,
        "width": 680
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        1000
      ],
      "typeVersion": 1,
      "id": "220b5a74-3a2f-4722-9017-e9755d2bd94f",
      "name": "Sticky Note5"
    },
    {
      "parameters": {
        "operation": "get",
        "tableId": "zl_included_users",
        "filters": {
          "conditions": [
            {
              "keyName": "key",
              "keyValue": "={{ $json.thread_id }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        240,
        1100
      ],
      "id": "61a7057e-5d9a-491b-9b17-2db0fa8bd4c6",
      "name": "GetUserIncluded",
      "alwaysOutputData": true,
      "credentials": {
        "supabaseApi": {
          "id": "XnneQjbtAW4FyfV2",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "f279a143-a74d-4cbb-b815-c8443c8626ef",
              "leftValue": "={{ $json.id }}",
              "rightValue": "",
              "operator": {
                "type": "number",
                "operation": "notExists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        440,
        1100
      ],
      "id": "06a2461e-e74e-4d18-a9eb-777b110e5482",
      "name": "IfDoesNotExist",
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f8015a26-bb7e-43ed-bb8b-c5556d004990",
              "name": "message_id",
              "value": "={{ $json.message.data.msgId }}",
              "type": "string"
            },
            {
              "id": "2aea730c-3bc3-487a-812e-eaba6e287e47",
              "name": "text",
              "value": "={{ $json.message.data.content }}",
              "type": "string"
            },
            {
              "id": "ed054f84-a1ea-45e6-b12c-c37bca8aee8f",
              "name": "d_name",
              "value": "={{ $json.message.data.dName }}",
              "type": "string"
            },
            {
              "id": "7cf9cfe3-61da-45b1-9df9-a6eefd68c371",
              "name": "from_id",
              "value": "={{ $json.message.data.uidFrom }}",
              "type": "string"
            },
            {
              "id": "00970e0d-5e08-4639-ab12-4c7ea240ed5b",
              "name": "to_id",
              "value": "={{ $json.message.data.idTo }}",
              "type": "string"
            },
            {
              "id": "ae2750dc-8d54-4310-acc5-0de8c8cca279",
              "name": "threadld",
              "value": "={{ $json.message.threadId }}",
              "type": "string"
            },
            {
              "id": "d820ec29-8d80-47cf-b11a-ebceed63fada",
              "name": "key",
              "value": "={{ $json.message.threadId }}",
              "type": "string"
            },
            {
              "id": "561d4afa-3181-42b8-93f2-dfe3e6f1bbad",
              "name": "timestamp",
              "value": "={{ $json.message.data.ts }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -760,
        1100
      ],
      "id": "d432fb43-44ae-4e55-9ee8-32be66e2642a",
      "name": "Data"
    },
    {
      "parameters": {
        "content": "## Nếu tin nhắn là của chủ zalo",
        "height": 620,
        "width": 1980,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1060,
        20
      ],
      "typeVersion": 1,
      "id": "0c46f066-b810-4ec9-9c90-ca2795332252",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f8015a26-bb7e-43ed-bb8b-c5556d004990",
              "name": "message_id",
              "value": "={{ $json.message.data.msgId }}",
              "type": "string"
            },
            {
              "id": "2aea730c-3bc3-487a-812e-eaba6e287e47",
              "name": "text",
              "value": "={{ $json.message.data.content }}",
              "type": "string"
            },
            {
              "id": "ed054f84-a1ea-45e6-b12c-c37bca8aee8f",
              "name": "d_name",
              "value": "={{ $json.message.data.dName }}",
              "type": "string"
            },
            {
              "id": "7cf9cfe3-61da-45b1-9df9-a6eefd68c371",
              "name": "from_id",
              "value": "={{ $json.message.data.uidFrom }}",
              "type": "string"
            },
            {
              "id": "00970e0d-5e08-4639-ab12-4c7ea240ed5b",
              "name": "to_id",
              "value": "={{ $json.message.data.idTo }}",
              "type": "string"
            },
            {
              "id": "ae2750dc-8d54-4310-acc5-0de8c8cca279",
              "name": "thread_id",
              "value": "={{ $json.message.threadId }}",
              "type": "string"
            },
            {
              "id": "d820ec29-8d80-47cf-b11a-ebceed63fada",
              "name": "key",
              "value": "={{ $json.message.threadId }}",
              "type": "string"
            },
            {
              "id": "561d4afa-3181-42b8-93f2-dfe3e6f1bbad",
              "name": "timestamp",
              "value": "={{ $json.message.data.ts }}",
              "type": "string"
            },
            {
              "id": "2496817e-1462-458a-85a3-eb1983007e09",
              "name": "is_bot",
              "value": "false",
              "type": "string"
            },
            {
              "id": "16cb96b6-bd29-4424-aa86-70dd67a383f5",
              "name": "status",
              "value": "done",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -740,
        180
      ],
      "id": "05229d31-c90e-4c4b-a4af-9bec97ce3bc5",
      "name": "Data2"
    },
    {
      "parameters": {
        "operation": "get",
        "tableId": "zl_chats",
        "filters": {
          "conditions": [
            {
              "keyName": "message_id",
              "keyValue": "={{ $json.message_id }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -240,
        460
      ],
      "id": "d6e5944c-e241-4619-9a32-5d64c94d676f",
      "name": "FindById",
      "alwaysOutputData": true,
      "credentials": {
        "supabaseApi": {
          "id": "XnneQjbtAW4FyfV2",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "9a042fec-fd94-471b-8dbe-951b084aa7ee",
              "leftValue": "={{ $json.id }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -20,
        460
      ],
      "id": "01e16298-a22c-4354-89cd-adf3761fcaa0",
      "name": "IfExistsMessage"
    },
    {
      "parameters": {
        "tableId": "zl_chats",
        "dataToSend": "autoMapInputData",
        "inputsToIgnore": "key"
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        440,
        200
      ],
      "id": "f0c53289-3af3-4c68-9b05-e7244eadea8e",
      "name": "SaveMessage",
      "credentials": {
        "supabaseApi": {
          "id": "XnneQjbtAW4FyfV2",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "operation": "get",
        "tableId": "zl_chats",
        "filters": {
          "conditions": [
            {
              "keyName": "message_id",
              "keyValue": "={{ $json.message_id }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -540,
        1100
      ],
      "id": "3df193e2-3161-456c-8b70-ee6a77531466",
      "name": "FindById2",
      "alwaysOutputData": true,
      "credentials": {
        "supabaseApi": {
          "id": "XnneQjbtAW4FyfV2",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "02d72cf3-bcee-4e2a-866d-91a3ff41edaa",
              "leftValue": "={{ $json.id }}",
              "rightValue": "",
              "operator": {
                "type": "number",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -340,
        1100
      ],
      "id": "8342b676-2079-46d0-b25f-2d9a6fda3699",
      "name": "IfExistsMessage2",
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "content": "## Check xem message này đã có trong db hay chưa",
        "height": 240,
        "width": 380
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        380
      ],
      "typeVersion": 1,
      "id": "9d5f9eef-5ed7-4d40-9d52-c1221c9ae677",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Nếu chưa có trong DB\n- Lưu message vào db",
        "height": 240,
        "width": 440
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        120
      ],
      "typeVersion": 1,
      "id": "fe9bd1e7-fecf-4dae-9e44-f6240022f7aa",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## Switch\nDùng để phân loại đoạn chát ( Có thể là text, sticker,...vv )\n",
        "height": 260,
        "width": 260
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        1000
      ],
      "typeVersion": 1,
      "id": "35314a34-24b7-4a39-805b-76c5b08a0080",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "content": "## Check xem message này đã có trong db hay chưa\n- Thao tác này đề phòng nhận cùng 1 tin nhắn 2 lần\n- Nếu tin nhắn bị lặp thì không trả lời nữa",
        "height": 260,
        "width": 600
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -780,
        1000
      ],
      "typeVersion": 1,
      "id": "531fdee6-5e51-49b4-8d3e-73d7007e5ef0",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "content": "## Lưu lại tin nhắn",
        "height": 260,
        "width": 340
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        1000
      ],
      "typeVersion": 1,
      "id": "935bdbbc-8e9a-4d6c-b430-d2341a4d9e4f",
      "name": "Sticky Note6"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.message.data.msgType }}",
                    "rightValue": "webchat",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "72612ffb-a0df-4276-9056-f3c5970aa96f"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "text"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "eebb2d88-989c-4816-ba75-dfc946717bac",
                    "leftValue": "={{ $json.message.data.msgType }}",
                    "rightValue": "chat.voice",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "voice"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "451a913f-1cb9-4cd3-832a-b2ebdf9dffdf",
                    "leftValue": "={{ $json.message.data.msgType }}",
                    "rightValue": "chat.sticker",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "sticker"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "8fb7d30d-699e-4772-a838-54c325126d5d",
                    "leftValue": "={{ $json.message.data.msgType }}",
                    "rightValue": "chat.photo",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "photo"
            }
          ]
        },
        "options": {
          "fallbackOutput": 2
        }
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -1040,
        340
      ],
      "id": "8d650479-1d8e-4977-b8d3-cd50d4e3add5",
      "name": "Switch1"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f8015a26-bb7e-43ed-bb8b-c5556d004990",
              "name": "message_id",
              "value": "={{ $json.message.data.msgId }}",
              "type": "string"
            },
            {
              "id": "2aea730c-3bc3-487a-812e-eaba6e287e47",
              "name": "text",
              "value": "= ",
              "type": "string"
            },
            {
              "id": "ed054f84-a1ea-45e6-b12c-c37bca8aee8f",
              "name": "d_name",
              "value": "={{ $json.message.data.dName }}",
              "type": "string"
            },
            {
              "id": "7cf9cfe3-61da-45b1-9df9-a6eefd68c371",
              "name": "from_id",
              "value": "={{ $json.message.data.uidFrom }}",
              "type": "string"
            },
            {
              "id": "00970e0d-5e08-4639-ab12-4c7ea240ed5b",
              "name": "to_id",
              "value": "={{ $json.message.data.idTo }}",
              "type": "string"
            },
            {
              "id": "ae2750dc-8d54-4310-acc5-0de8c8cca279",
              "name": "thread_id",
              "value": "={{ $json.message.threadId }}",
              "type": "string"
            },
            {
              "id": "d820ec29-8d80-47cf-b11a-ebceed63fada",
              "name": "key",
              "value": "={{ $json.message.threadId }}",
              "type": "string"
            },
            {
              "id": "561d4afa-3181-42b8-93f2-dfe3e6f1bbad",
              "name": "timestamp",
              "value": "={{ $json.message.data.ts }}",
              "type": "string"
            },
            {
              "id": "2496817e-1462-458a-85a3-eb1983007e09",
              "name": "is_bot",
              "value": "false",
              "type": "string"
            },
            {
              "id": "16cb96b6-bd29-4424-aa86-70dd67a383f5",
              "name": "status",
              "value": "done",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -740,
        460
      ],
      "id": "118217b2-baf9-44bc-a449-0749dbeee0ce",
      "name": "Data3"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://dxunek.datadex.vn/webhook/zalo_on_message",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ $('Data').first().json.toJsonString() }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        1100
      ],
      "id": "edd167b3-d95f-4c27-8742-7ae4f5eabc1f",
      "name": "SendOnMessage"
    },
    {
      "parameters": {
        "mode": "chooseBranch"
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        200,
        200
      ],
      "id": "ea513bb9-0b7b-4b6b-951e-3388f1ae23d0",
      "name": "Merge"
    },
    {
      "parameters": {
        "content": "## Nếu tin nhắn là của người dùng",
        "height": 380,
        "width": 1980,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1060,
        900
      ],
      "typeVersion": 1,
      "id": "ab05ef2c-7381-43bb-8c99-d75a63d79912",
      "name": "Sticky Note7"
    },
    {
      "parameters": {
        "operation": "upsert",
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "zl_included_users",
          "mode": "list",
          "cachedResultName": "zl_included_users"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "key": "={{ $json.thread_id }}",
            "from_id": "={{ $json.from_id }}",
            "to_id": "={{ $json.to_id }}"
          },
          "matchingColumns": [
            "key"
          ],
          "schema": [
            {
              "id": "id",
              "displayName": "id",
              "required": false,
              "defaultMatch": true,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "from_id",
              "displayName": "from_id",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false
            },
            {
              "id": "to_id",
              "displayName": "to_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false
            },
            {
              "id": "created_at",
              "displayName": "created_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "canBeUsedToMatch": false,
              "removed": true
            },
            {
              "id": "key",
              "displayName": "key",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        700,
        200
      ],
      "id": "29e71637-eff1-4a22-bac9-5bfdc24eeb2c",
      "name": "InsertOrUpdateIncluded",
      "credentials": {
        "postgres": {
          "id": "GLfIWU3rbAidDMPe",
          "name": "Postgres account"
        }
      }
    },
    {
      "parameters": {
        "content": "## Insert Or Update Included\n- Nếu là người thật thì đưa vào danh sách loại trừ",
        "height": 240,
        "width": 320
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        580,
        120
      ],
      "typeVersion": 1,
      "id": "5fc8b02b-bd1f-4eaa-aa09-7e50f86ef336",
      "name": "Sticky Note8"
    },
    {
      "parameters": {
        "amount": 1
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -500,
        180
      ],
      "id": "6a6ff1e8-8d22-4b70-8306-e2daea6fb2e7",
      "name": "Wait2",
      "webhookId": "47d5a2d8-d86d-45a5-a417-1585035545f9"
    },
    {
      "parameters": {
        "operation": "get",
        "tableId": "zl_chats",
        "filters": {
          "conditions": [
            {
              "keyName": "status",
              "keyValue": "pending"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        1140,
        -220
      ],
      "id": "df4b7a0d-af4e-422b-b929-9391efd298c1",
      "name": "GetAllMessage",
      "credentials": {
        "supabaseApi": {
          "id": "XnneQjbtAW4FyfV2",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "tableId": "zl_chats",
        "filterType": "string",
        "filterString": "=id=in.({{ $('GetAllMessage').all().map(item => item.json.id) }})",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "status",
              "fieldValue": "done"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        1460,
        -220
      ],
      "id": "c784e411-153c-436a-8521-080c8aab6ac9",
      "name": "UpdateDoneMessage",
      "executeOnce": true,
      "credentials": {
        "supabaseApi": {
          "id": "XnneQjbtAW4FyfV2",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "return [\n  {\n    ... $('GetAllMessage').last().json,\n    text: $('GetAllMessage').all().map(m => m.json.text).join(' '),\n    content: $input.all()\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1800,
        -220
      ],
      "id": "b9ff2025-a332-4964-8fe2-6f57cbb17e60",
      "name": "MergeMessage"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "=# ROLE\nrole: assistant\nname: dinner_menu_bot\ndescription: |\n  Bạn là chatbot AI chuyên hỗ trợ tư vấn thực đơn buổi tối bằng tiếng Việt. \n  Bạn cũng hỗ trợ hỏi thông tin giao hàng nếu người dùng có nhu cầu.\n\n# TOOL\ntools:\n  - name: data\n    description: Truy xuất thực đơn buổi tối. Mỗi mục gồm:\n      - \"Tên món\": tên món ăn bằng tiếng Việt (không dịch)\n      - \"Giá\": giá món ăn\n      - \"ảnh\": link ảnh món ăn (chỉ hiển thị nếu người dùng yêu cầu rõ ràng)\n\n# TRIGGER KEYWORDS\ntrigger_phrases:\n  - \"menu\"\n  - \"thực đơn\"\n  - \"tối nay có món gì\"\n  - \"ăn gì\"\n  - \"giá bao nhiêu\"\n  - \"món chay có không\"\n  - \"cho xin thực đơn\"\n  - \"tối nay có lẩu không\"\n  - \"gợi ý món ăn tối\"\n  - \"có món nào ngon\"\n  - \"món mặn\"\n  - \"món ăn nhẹ\"\n  - \"ship\"\n  - \"giao hàng\"\n  - \"có giao hàng không\"\n  - \"giao tận nơi\"\n  - \"mình muốn đặt món\"\n  - \"ship tới\"\n\n# RESPONSE RULES\nbehavior:\n  - Luôn dùng tool `data` để truy vấn món ăn.\n  - Chỉ phản hồi nếu người dùng nói về thực đơn buổi tối hoặc giao hàng.\n  - Nếu không liên quan → trả lời:  \n      \"Dạ em là trợ lý AI, hiện tại em chỉ hỗ trợ tư vấn thực đơn và món ăn buổi tối.  \n      Bạn cần xem menu hay đặt món gì không ạ?\"\n\n# RESPONSE FORMAT\nresponse_style:\n  - Trả lời thân thiện, ngắn gọn, bằng tiếng Việt.\n  - Hiển thị món ăn và giá như sau:\n      🍚 Cơm gà xối mỡ – 45.000đ  \n      🥢 Bún bò Huế – 50.000đ  \n      🌱 Món chay, lẩu, ăn vặt và đồ uống nữa nhé!  \n      Bạn muốn xem đầy đủ menu không ạ?\n\n# IMAGE HANDLING\nimage_handling:\n  - ❌ Không bao giờ hiển thị ảnh nếu người dùng không yêu cầu rõ ràng.\n  - ✅ Chỉ hiển thị `data[\"ảnh\"]` nếu người dùng yêu cầu ảnh bằng các cụm như:\n      - \"cho mình xem ảnh\", \"có hình món đó không\", \"cho xem ảnh cơm gà\", v.v.\n  - ❌ Nếu không có ảnh trong `data`, trả lời:  \n      \"Dạ món này hiện chưa có hình ảnh ạ.\"\n  - ❌ Không được tạo ảnh hoặc link ảnh giả.\n\n# SHIPPING HANDLING\nshipping_rules:\n  - Nếu người dùng hỏi về ship/giao hàng → phản hồi:\n      \"Dạ bên em có hỗ trợ giao hàng ạ.  \n      Mình vui lòng cho em xin địa chỉ nhận hàng và số điện thoại để bên em giao tận nơi nhé!\"\n\n  - Nếu người dùng đã chọn món và muốn đặt → gợi ý tiếp tục:  \n      \"Mình chọn món xong có thể gửi giúp em địa chỉ và số điện thoại để em lên đơn giao liền nha!\"\n\n# MÓN KHÔNG CÓ TRONG DATA\nno_data_handling:\n  - Nếu `data` không có món được hỏi → trả lời:\n      \"Dạ món này hiện chưa có trong thực đơn ạ. Bạn muốn xem món khác không?\"\n\n# STRICT RULES\nstrict_data_policy:\n  - ❌ Không được bịa tên món, giá, hay ảnh.\n  - ✅ Chỉ dùng đúng dữ liệu từ tool `data`.\n\n# TONE\ntone:\n  - Giọng điệu thân thiện, rõ ràng, gần gũi\n  - Luôn dùng tiếng Việt\n\n# MEMORY / CONTEXTUAL MEMORY\nmemory_handling:\n  - Nếu người dùng đã cung cấp địa chỉ và/hoặc số điện thoại trước đó trong cuộc trò chuyện hiện tại → sử dụng lại, KHÔNG hỏi lại.\n  - Nếu chưa có địa chỉ hoặc số điện thoại → lịch sự yêu cầu người dùng cung cấp.\n  - Luôn xác nhận lại địa chỉ/sđt trước khi xác nhận đơn hàng.\n\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        2220,
        -220
      ],
      "id": "f17898ab-afa3-45ec-8009-46497020260e",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "gpt-4o"
        },
        "options": {
          "temperature": 0.2,
          "topP": 0.7
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        2180,
        0
      ],
      "id": "12c5ea47-3d57-499b-a628-0794710b11fd",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "npnMtU7kA3sNSLyr",
          "name": "OpenAi Chatbot"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $json.thread_id }}",
        "tableName": "n8n_chat_histories_zl"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        2340,
        0
      ],
      "id": "6f6fde27-44f5-4300-9004-5d83c53afd58",
      "name": "Postgres Chat Memory",
      "credentials": {
        "postgres": {
          "id": "GLfIWU3rbAidDMPe",
          "name": "Postgres account"
        }
      }
    },
    {
      "parameters": {
        "threadId": "={{ $('MergeMessage').last().json.thread_id }}",
        "message": "={{ $json.output }}",
        "quote": {},
        "mentions": {}
      },
      "type": "n8n-nodes-zalos-user.zaloSendMessage",
      "typeVersion": 4,
      "position": [
        2100,
        260
      ],
      "id": "20699b06-8ca9-47dd-af9b-fb7066d7f6a4",
      "name": "Zalo Send Message",
      "credentials": {
        "zaloApi": {
          "id": "fkZrS93MRhu2vFWX",
          "name": "Zalo API Credentials"
        }
      }
    },
    {
      "parameters": {
        "tableId": "zl_chats",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "from_id",
              "fieldValue": "={{ $('MergeMessage').item.json.from_id }}"
            },
            {
              "fieldId": "to_id",
              "fieldValue": "={{ $('MergeMessage').item.json.to_id }}"
            },
            {
              "fieldId": "thread_id",
              "fieldValue": "={{ $json.threadId }}"
            },
            {
              "fieldId": "timestamp",
              "fieldValue": "={{ $now.toMillis() }}"
            },
            {
              "fieldId": "message_id",
              "fieldValue": "={{ $json.response.message.msgId }}"
            },
            {
              "fieldId": "text",
              "fieldValue": "={{ $json.messageContent.msg }}"
            },
            {
              "fieldId": "status",
              "fieldValue": "done"
            },
            {
              "fieldId": "d_name",
              "fieldValue": "={{ $('MergeMessage').last().json.d_name }}"
            },
            {
              "fieldId": "is_bot",
              "fieldValue": "true"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        2320,
        240
      ],
      "id": "e81d1c50-8450-440a-8f22-4355817e103f",
      "name": "SaveToChats1",
      "credentials": {
        "supabaseApi": {
          "id": "XnneQjbtAW4FyfV2",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "threadId": "={{ $('MergeMessage').item.json.thread_id }}",
        "message": "={{ JSON.stringify($('IfNotImage').item.json.text) }}",
        "quote": {},
        "mentions": {},
        "attachments": {
          "attachment": [
            {
              "imageUrl": "={{ $json.image }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-zalos-user.zaloSendMessage",
      "typeVersion": 4,
      "position": [
        2860,
        1120
      ],
      "id": "c6beffbe-0d59-46ad-b231-4b728b907b57",
      "name": "Zalo Send Message1",
      "credentials": {
        "zaloApi": {
          "id": "fkZrS93MRhu2vFWX",
          "name": "Zalo API Credentials"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {
          "temperature": 0.2
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        1380,
        800
      ],
      "id": "31b470fc-9ed3-4f49-8ef4-1731008d9086",
      "name": "OpenAI Chat Model2",
      "credentials": {
        "openAiApi": {
          "id": "npnMtU7kA3sNSLyr",
          "name": "OpenAi Chatbot"
        }
      }
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"array\",\n  \"items\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"text\": {\n        \"type\": \"string\"\n      },\n      \"image\": {\n        \"type\": \"array\",\n        \"items\": {\n          \"type\": \"string\",\n          \"format\": \"uri\"\n        }\n      }\n    },\n    \"required\": [\"text\", \"image\"]\n  }\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        1560,
        800
      ],
      "id": "456f8217-a8dc-4ad3-af70-fba7fef0d1ef",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.output }}",
        "hasOutputParser": true,
        "messages": {
          "messageValues": [
            {
              "message": "Chuyển đoạn nội dung dưới đây thành mảng JSON theo format: [{ \"text\": \"nd\", \"image\": [\"url1\", \"url2\"] }] Với mỗi mục, \"text\" là phần mô tả của hình ảnh và \"image\" là mảng chứa link các ảnh trong mục đó. Bỏ qua định dạng Markdown, chỉ lấy nội dung và link ảnh."
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        1380,
        600
      ],
      "id": "38a1eeeb-7354-4ec8-9921-c2e85decbc12",
      "name": "Basic LLM Chain",
      "retryOnFail": true
    },
    {
      "parameters": {
        "fieldToSplitOut": "output",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        1740,
        600
      ],
      "id": "c2822eff-15e2-422b-af6d-17d4c8eb9d41",
      "name": "Split Out2"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        1960,
        600
      ],
      "id": "1495a680-4070-466e-8b6a-b6216d7b787d",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "fieldToSplitOut": "image",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        2020,
        920
      ],
      "id": "82614023-e58b-4e7c-975d-99435a37b31f",
      "name": "Split Out3"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/1tbbkYaSAG8GIx8Ul1kL_3yOC6f9d7leiTwL2eYSzUiU/edit?gid=0#gid=0",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "data",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1tbbkYaSAG8GIx8Ul1kL_3yOC6f9d7leiTwL2eYSzUiU/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.6,
      "position": [
        2480,
        0
      ],
      "id": "b21a11ce-d49b-44de-bfd0-a76d891336f5",
      "name": "data",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "FTFDT8ZBWVzqLvQP",
          "name": "Google Sheets account 2"
        }
      }
    },
    {
      "parameters": {
        "tableId": "zl_chats",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "from_id",
              "fieldValue": "={{ $('MergeMessage').item.json.from_id }}"
            },
            {
              "fieldId": "to_id",
              "fieldValue": "={{ $('MergeMessage').item.json.to_id }}"
            },
            {
              "fieldId": "thread_id",
              "fieldValue": "={{ $json.threadId }}"
            },
            {
              "fieldId": "timestamp",
              "fieldValue": "={{ $now.toMillis() }}"
            },
            {
              "fieldId": "message_id",
              "fieldValue": "={{ $json.response.attachment[0].msgId }}"
            },
            {
              "fieldId": "text",
              "fieldValue": "={{ $json.messageContent.msg }}"
            },
            {
              "fieldId": "status",
              "fieldValue": "done"
            },
            {
              "fieldId": "d_name",
              "fieldValue": "={{ $('MergeMessage').last().json.d_name }}"
            },
            {
              "fieldId": "is_bot",
              "fieldValue": "true"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        3220,
        1120
      ],
      "id": "10031b74-1a65-4ab8-9a86-a985da926575",
      "name": "SaveToChats2",
      "credentials": {
        "supabaseApi": {
          "id": "XnneQjbtAW4FyfV2",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        3680,
        1120
      ],
      "id": "451a188f-947c-4b75-9152-e3b4f2d4ce95",
      "name": "Wait",
      "webhookId": "49f92e25-7578-4763-84df-ed87c3dad3e7"
    },
    {
      "parameters": {
        "respondWith": "allIncomingItems",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.2,
      "position": [
        1380,
        -480
      ],
      "id": "32475796-2500-49c6-81c0-6038a5ce491c",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "table": "zl_n8n_debounce",
        "key": "={{ $json.thread_id }}",
        "cooldownLogic": true
      },
      "type": "n8n-nodes-debounce.debouncePostgres",
      "typeVersion": 1,
      "position": [
        1820,
        -480
      ],
      "id": "69a6ba88-8ea1-4c0b-bbba-95b1b6343aaa",
      "name": "Debounce Postgres",
      "credentials": {
        "postgres": {
          "id": "GLfIWU3rbAidDMPe",
          "name": "Postgres account"
        }
      }
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "zalo_on_message",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        1160,
        -480
      ],
      "id": "18a4a7e8-1fb7-42f6-a3c1-26b6b1b641e7",
      "name": "OnMessage",
      "webhookId": "ef7c2705-2b91-46bf-bd98-7d6bc8165d40"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "3688a7eb-5667-4758-8bc4-67d82423784d",
              "leftValue": "={{ $json.output }}",
              "rightValue": "https?://[^\\s\"']+",
              "operator": {
                "type": "string",
                "operation": "notRegex"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1120,
        240
      ],
      "id": "9944c010-c3ab-42da-9c68-3675e379db95",
      "name": "IfExistLink"
    },
    {
      "parameters": {
        "content": "## Lưu tin nhắn\n- Lưu lại tin nhắn vào csdl",
        "height": 220,
        "width": 320
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2260,
        160
      ],
      "typeVersion": 1,
      "id": "47e4cee9-d585-498d-9b01-1779edcb4f0e",
      "name": "Sticky Note9"
    },
    {
      "parameters": {
        "content": "## Phân tách tin nhắn có kèm ảnh\n- Sử dụng AI để phân tách tin nhắn kèm ảnh",
        "height": 240,
        "width": 520
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1360,
        500
      ],
      "typeVersion": 1,
      "id": "bda3affd-4faa-467d-b1ff-bada4afcc7e1",
      "name": "Sticky Note10"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1120,
        600
      ],
      "id": "333ba24e-9ffa-4828-849f-29118ca1bc2c",
      "name": "Tin nhắn có ảnh"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1680,
        260
      ],
      "id": "cd6edcf0-bcf6-4e60-8593-4893f408813b",
      "name": "Tin nhắn không ảnh"
    },
    {
      "parameters": {
        "content": "## Trả lời tin nhắn\n- Nếu đoạn tin nhắn này không có ảnh",
        "height": 220,
        "width": 340
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2460,
        520
      ],
      "typeVersion": 1,
      "id": "02a680a4-b14e-4acf-a847-04679b9ec6a2",
      "name": "Sticky Note11"
    },
    {
      "parameters": {
        "threadId": "={{ $('MergeMessage').last().json.thread_id }}",
        "message": "={{ JSON.stringify($('IfNotImage').item.json.text) }}",
        "quote": {},
        "mentions": {}
      },
      "type": "n8n-nodes-zalos-user.zaloSendMessage",
      "typeVersion": 4,
      "position": [
        2600,
        600
      ],
      "id": "106c50c8-e37f-42e8-a5d0-a7a072f2d4e4",
      "name": "Zalo Send Message2",
      "credentials": {
        "zaloApi": {
          "id": "fkZrS93MRhu2vFWX",
          "name": "Zalo API Credentials"
        }
      }
    },
    {
      "parameters": {
        "tableId": "zl_chats",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "from_id",
              "fieldValue": "={{ $('MergeMessage').item.json.from_id }}"
            },
            {
              "fieldId": "to_id",
              "fieldValue": "={{ $('MergeMessage').item.json.to_id }}"
            },
            {
              "fieldId": "thread_id",
              "fieldValue": "={{ $json.threadId }}"
            },
            {
              "fieldId": "timestamp",
              "fieldValue": "={{ $now.toMillis() }}"
            },
            {
              "fieldId": "message_id",
              "fieldValue": "={{ $json.response.attachment[0].msgId }}"
            },
            {
              "fieldId": "text",
              "fieldValue": "={{ $json.messageContent.msg }}"
            },
            {
              "fieldId": "status",
              "fieldValue": "done"
            },
            {
              "fieldId": "d_name",
              "fieldValue": "={{ $('MergeMessage').last().json.d_name }}"
            },
            {
              "fieldId": "is_bot",
              "fieldValue": "true"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        2880,
        600
      ],
      "id": "82821ce5-fc1f-4b9e-920b-a609fe950984",
      "name": "SaveToChats3",
      "retryOnFail": false,
      "credentials": {
        "supabaseApi": {
          "id": "XnneQjbtAW4FyfV2",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "4a008533-4c98-4124-b3b5-e13b3f1e22a9",
              "leftValue": "={{ $json.image }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        2260,
        600
      ],
      "id": "a1a08792-2034-4f75-9f63-72537576f5ef",
      "name": "IfNotImage"
    },
    {
      "parameters": {
        "content": "## Lưu tin nhắn\n- Lưu lại tin nhắn vào csdl",
        "height": 220,
        "width": 580
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2820,
        520
      ],
      "typeVersion": 1,
      "id": "3dcdd162-0700-474d-b7ce-7933bd5e5257",
      "name": "Sticky Note12"
    },
    {
      "parameters": {
        "content": "## Phân tách\n- Phân tách link ảnh nếu đoạn tin có nhiều link ảnh",
        "height": 260,
        "width": 200
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1980,
        800
      ],
      "typeVersion": 1,
      "id": "441bbda1-2377-47c4-9891-025b1b3f5159",
      "name": "Sticky Note13"
    },
    {
      "parameters": {
        "content": "## Phân loại link ảnh\n- xem link ảnh là link drive hay link self host",
        "height": 260
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2200,
        800
      ],
      "typeVersion": 1,
      "id": "bc53a5bf-7dbc-45e4-82e0-f02b27f90771",
      "name": "Sticky Note14"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        2600,
        820
      ],
      "id": "85cafbdc-5fc3-45c7-9a2b-ec2a7f1c4cf1",
      "name": "Link ảnh server cá nhân"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "4472944c-60c5-4af8-a5cd-6d502e9921c4",
              "name": "=image",
              "value": "=https://dxunek.datadex.vn/webhook/f6084433-b03b-4c23-9e67-704ca3ba2812?url={{ $json.image }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2600,
        1120
      ],
      "id": "3741d2ff-e86e-436b-84a9-9b7574033caf",
      "name": "Link ảnh drive"
    },
    {
      "parameters": {
        "content": "## Trả lời tin nhắn\n- Trả lời tin nhắn kèm theo ảnh",
        "height": 240,
        "width": 260
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2820,
        1020
      ],
      "typeVersion": 1,
      "id": "d2713a32-cc19-4488-b9ef-900c789af305",
      "name": "Sticky Note15"
    },
    {
      "parameters": {
        "content": "## Lưu tin nhắn\n- Lưu lại tin nhắn vào csdl",
        "height": 240,
        "width": 300
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3100,
        1020
      ],
      "typeVersion": 1,
      "id": "1d903604-8170-4781-85ca-e576f520c2a0",
      "name": "Sticky Note16"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "cbcd35cb-2d2b-4d3f-b0e2-d2b9411a4c7c",
              "name": "message_id",
              "value": "={{ $json.body.message_id }}",
              "type": "string"
            },
            {
              "id": "3a94490b-3090-44a5-b63d-003235c06a74",
              "name": "text",
              "value": "={{ $json.body.text }}",
              "type": "string"
            },
            {
              "id": "05c893f0-f84d-4d19-a457-65b7aa38b3f9",
              "name": "d_name",
              "value": "={{ $json.body.d_name }}",
              "type": "string"
            },
            {
              "id": "4065e882-8075-42e3-92a6-e21827ee00da",
              "name": "from_id",
              "value": "={{ $json.body.from_id }}",
              "type": "string"
            },
            {
              "id": "a86f5164-d6ab-431e-a997-9316e88fe084",
              "name": "to_id",
              "value": "={{ $json.body.to_id }}",
              "type": "string"
            },
            {
              "id": "f39b34cc-5087-4765-8a91-eb573b902382",
              "name": "thread_id",
              "value": "={{ $json.body.threadld }}",
              "type": "string"
            },
            {
              "id": "d40c524c-6c85-4ff4-bdf5-a57bf2701162",
              "name": "key",
              "value": "={{ $json.body.key }}",
              "type": "string"
            },
            {
              "id": "b691f74d-e71a-4021-84d2-37b5f1c860ed",
              "name": "timestamp",
              "value": "={{ $json.body.timestamp }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1600,
        -480
      ],
      "id": "b920a0d6-8895-4f1c-acfa-91558014788f",
      "name": "BodyData"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ encodeURI($json.image) }}",
                    "rightValue": "/https?:\\/\\/[^\\s]+?\\.(jpg|jpeg|png|gif)(\\?[^\\s]*)?/gi",
                    "operator": {
                      "type": "string",
                      "operation": "regex"
                    },
                    "id": "5bfc1fd6-bf94-4cae-b1fe-266c29502ad6"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "link"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "4aa7cbe6-2423-490c-8b4d-9bbc8b951b75",
                    "leftValue": "={{ $json.image }}",
                    "rightValue": "https?://(?:drive\\.google\\.com|docs\\.google\\.com)/[^\\s\"']+",
                    "operator": {
                      "type": "string",
                      "operation": "regex"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "driver"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        2300,
        920
      ],
      "id": "efc08384-470f-4fbc-99ad-20b20539a0f1",
      "name": "Switch2"
    },
    {
      "parameters": {
        "content": "## Chờ người dùng trả lời\n- Người dùng có thể trả lời ngắt quãng",
        "height": 260,
        "width": 300
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1780,
        -580
      ],
      "typeVersion": 1,
      "id": "0ca751c8-ad56-40c8-8701-56fb7e04db61",
      "name": "Sticky Note17"
    },
    {
      "parameters": {
        "content": "## Get All Message\n- Lấy ra toàn bộ tin nhắn của người dùng",
        "height": 240,
        "width": 320
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1080,
        -300
      ],
      "typeVersion": 1,
      "id": "fdb94708-eb88-4a3b-8214-d011ad78215d",
      "name": "Sticky Note18"
    },
    {
      "parameters": {
        "content": "## Cập nhật trạng thái\n- Đổi trạng thái pending sang done",
        "height": 240,
        "width": 340
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1420,
        -300
      ],
      "typeVersion": 1,
      "id": "c366e83b-7012-4305-acc9-4cc6b8692388",
      "name": "Sticky Note19"
    },
    {
      "parameters": {
        "content": "## Gộp tin nhắn\n- Gộp toàn bộ tin nhắn lại thành 1 tin nhắn\n",
        "height": 240,
        "width": 360
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1780,
        -300
      ],
      "typeVersion": 1,
      "id": "c030c099-33a8-480f-98ba-90f0f119e07f",
      "name": "Sticky Note20"
    },
    {
      "parameters": {
        "content": "## AI Agent\n- Sử dụng AI Agent để trả lời tin nhắn",
        "height": 240,
        "width": 420
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2160,
        -300
      ],
      "typeVersion": 1,
      "id": "1b0f7d43-9053-47a3-a26a-2590f79b3a1f",
      "name": "Sticky Note21"
    },
    {
      "parameters": {
        "content": "## Phân nhánh\n- Kiểm tra xem trong nội dung trả lời có ảnh hay không để phân nhánh",
        "height": 220,
        "width": 520
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1080,
        160
      ],
      "typeVersion": 1,
      "id": "2729f8a7-0937-4638-aa91-b22d96e65be5",
      "name": "Sticky Note22"
    },
    {
      "parameters": {
        "content": "## Trả lời tin nhắn\n- Nếu nội dung câu trả lời không có ảnh. Thì ta gửi luôn câu trả lời về cho người dùng",
        "height": 220,
        "width": 620
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1620,
        160
      ],
      "typeVersion": 1,
      "id": "eb732ee1-e485-4a0b-a4d3-e2fe04a7e73c",
      "name": "Sticky Note23"
    },
    {
      "parameters": {
        "path": "f6084433-b03b-4c23-9e67-704ca3ba2813",
        "responseMode": "lastNode",
        "responseData": "firstEntryBinary",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -520,
        -560
      ],
      "id": "322cc763-b9ed-44f7-a7aa-50cdbdb4aef9",
      "name": "DownloadFile",
      "webhookId": "f6084433-b03b-4c23-9e67-704ca3ba2812"
    },
    {
      "parameters": {
        "content": "## Tạo link ảnh drive\n- Nhớ thay link được lấy từ webhook DownloadFile",
        "height": 240,
        "width": 340
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2460,
        1020
      ],
      "typeVersion": 1,
      "id": "e8341440-72f4-4b76-83af-3dadb67bf7c1",
      "name": "Sticky Note27"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        3220,
        600
      ],
      "id": "0627b660-8de7-4308-b3a4-80f76fe5468b",
      "name": "No Operation, do nothing"
    }
  ],
  "pinData": {},
  "connections": {
    "CreateIncludedTable": {
      "main": [
        [
          {
            "node": "CreateDebounceTable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CreateChatsTable": {
      "main": [
        [
          {
            "node": "CreateIncludedTable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CreateDebounceTable": {
      "main": [
        []
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "CreateChatsTable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IfPersonNotReply": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          },
          {
            "node": "MergeMessage",
            "type": "main",
            "index": 0
          },
          {
            "node": "UpdateDoneMessage",
            "type": "main",
            "index": 0
          },
          {
            "node": "GetAllMessage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo Message Trigger": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SaveToChats": {
      "main": [
        [
          {
            "node": "GetUserIncluded",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetUserIncluded": {
      "main": [
        [
          {
            "node": "IfDoesNotExist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IfDoesNotExist": {
      "main": [
        [
          {
            "node": "SendOnMessage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data": {
      "main": [
        [
          {
            "node": "FindById2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data2": {
      "main": [
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FindById": {
      "main": [
        [
          {
            "node": "IfExistsMessage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IfExistsMessage": {
      "main": [
        [],
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "SaveMessage": {
      "main": [
        [
          {
            "node": "InsertOrUpdateIncluded",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FindById2": {
      "main": [
        [
          {
            "node": "IfExistsMessage2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IfExistsMessage2": {
      "main": [
        [],
        [
          {
            "node": "SaveToChats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch1": {
      "main": [
        [
          {
            "node": "Data2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Data3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Data3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Data3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data3": {
      "main": [
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "SaveMessage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait2": {
      "main": [
        [
          {
            "node": "FindById",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetAllMessage": {
      "main": [
        [
          {
            "node": "UpdateDoneMessage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UpdateDoneMessage": {
      "main": [
        [
          {
            "node": "MergeMessage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MergeMessage": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "IfExistLink",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Zalo Send Message": {
      "main": [
        [
          {
            "node": "SaveToChats1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo Send Message1": {
      "main": [
        [
          {
            "node": "SaveToChats2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Split Out2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out2": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "IfNotImage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out3": {
      "main": [
        [
          {
            "node": "Switch2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "data": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "SaveToChats2": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Respond to Webhook": {
      "main": [
        [
          {
            "node": "BodyData",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Debounce Postgres": {
      "main": [
        [
          {
            "node": "GetAllMessage",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "OnMessage": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IfExistLink": {
      "main": [
        [
          {
            "node": "Tin nhắn không ảnh",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Tin nhắn có ảnh",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tin nhắn có ảnh": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tin nhắn không ảnh": {
      "main": [
        [
          {
            "node": "Zalo Send Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo Send Message2": {
      "main": [
        [
          {
            "node": "SaveToChats3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SaveToChats3": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IfNotImage": {
      "main": [
        [
          {
            "node": "Zalo Send Message2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Split Out3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Link ảnh server cá nhân": {
      "main": [
        [
          {
            "node": "Zalo Send Message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Link ảnh drive": {
      "main": [
        [
          {
            "node": "Zalo Send Message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BodyData": {
      "main": [
        [
          {
            "node": "Debounce Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch2": {
      "main": [
        [
          {
            "node": "Link ảnh server cá nhân",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Link ảnh drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DownloadFile": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No Operation, do nothing": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "21da3de0-2fd9-4529-8b5d-35859ca31a2b",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "588a021bb54b760204dc9fed657516230744845e005fe72c0f4b0664fd815974"
  },
  "id": "PbNAsk2PsUEAQkt5",
  "tags": []
}