{
  "name": "share-zalo-gemini-telegram",
  "nodes": [
    {
      "parameters": {
        "content": "## Zalo Login Via QR Code",
        "height": 420,
        "width": 2120
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -2200,
        0
      ],
      "id": "8d09edf1-a7ec-4119-af5c-021ffb009ffd",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Receive events from Zalo User and trigger workflows",
        "height": 1120,
        "width": 2120,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -2200,
        460
      ],
      "id": "153c5a07-6c60-4dac-abd7-460d459445fa",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        360,
        140
      ],
      "id": "9c22ea98-117c-489d-8bc1-3c86f1a5445a",
      "name": "Telegram Trigger",
      "webhookId": "f633db3f-190b-47b9-b6c1-c4fe2c56a9dd",
      "credentials": {
        "telegramApi": {
          "id": "VMH1B0Iv1DKRYn0e",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "content": "## Anwser Zalo messages via Telegram",
        "height": 420,
        "width": 2140,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "a4713cca-2fa4-4d25-83ba-55e40487bc10",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "events": [
          "message",
          "group_event",
          "reaction",
          "undo"
        ]
      },
      "type": "n8n-nodes-zalo-user-v3.zaloUser",
      "typeVersion": 2,
      "position": [
        -2120,
        890
      ],
      "id": "5ab4050c-7f3f-4037-8e3e-90fd2a053cb0",
      "name": "Zalo User Trigger",
      "credentials": {
        "zaloUserCredentialsApi": {
          "id": "vPnUgM2zqR0sRXXi",
          "name": "Zalo 4343 - 2025-04-22T07:21:22.558Z"
        }
      }
    },
    {
      "parameters": {
        "threadId": "={{ $json.message.reply_to_message.text.match(/###(\\d+)###/)[1] }}",
        "message": "={{ $json.message.text }} \n\n[Sent from Telegram]",
        "threadType": "={{ $json.message.reply_to_message.text.match(/###\\d+###(\\d+)###/)[1] }}"
      },
      "type": "n8n-nodes-zalo-user-v3.zaloUserInteract",
      "typeVersion": 1,
      "position": [
        1000,
        260
      ],
      "id": "b5104b23-96e9-43b6-b1d0-30d78bce70b1",
      "name": "Zalo User Interact1",
      "credentials": {
        "zaloUserCredentialsApi": {
          "id": "vPnUgM2zqR0sRXXi",
          "name": "Zalo 4343 - 2025-04-22T07:21:22.558Z"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "593f613c-0692-43db-829c-b2546961cfd7",
                    "leftValue": "={{ $json.data.msgType }}",
                    "rightValue": "webchat",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Text"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.data.msgType }}",
                    "rightValue": "chat.photo",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "00a6326f-480c-49a4-afc1-83783ff90ebc"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Photo"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "9e03dd92-64d0-4230-ae06-2ad7f996aae4",
                    "leftValue": "={{ $json.data.msgType }}",
                    "rightValue": "chat.video.msg",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Video"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "50fa8978-a63e-41be-ab37-d52ff2f16f08",
                    "leftValue": "={{ $json.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": "9561b879-177e-47f1-859f-02ceeb31c5a3",
                    "leftValue": "={{ $json.data.msgType }}",
                    "rightValue": "share.file",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "File"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "5a67fed7-cb8b-449d-bfcb-0ffbda8f5c61",
                    "leftValue": "={{ $json.data.msgType }}",
                    "rightValue": "chat.recommended",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Link"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -1900,
        827
      ],
      "id": "33d82c45-1472-4c56-ae96-dfc781dfd74c",
      "name": "Switch"
    },
    {
      "parameters": {
        "operation": "sendPhoto",
        "chatId": "-000THAYIDVAODAY000",
        "file": "={{ $json.data.content.href }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -1680,
        590
      ],
      "id": "bfebd770-8535-4b21-bdff-f8f56a4b8575",
      "name": "Telegram1",
      "webhookId": "1b41c06f-3f5b-4373-b4a9-49613329fda8",
      "disabled": true
    },
    {
      "parameters": {
        "operation": "sendVideo",
        "chatId": "-000THAYIDVAODAY000",
        "file": "={{ $json.data.content.href }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -1680,
        990
      ],
      "id": "bee5dd99-2d20-48ff-b714-5c8575b031c0",
      "name": "Telegram2",
      "webhookId": "ef4d3180-f528-4814-9a1c-18279403a327",
      "disabled": true
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('If').item.json.data.dName }}: {{ $('If').item.json.data.content.substring(4)  }}",
        "options": {
          "systemMessage": "=Bạn là Thành AI, trợ lý ảo thông minh và tận tâm của Minh Thành.\nNhiệm vụ của bạn là hỗ trợ Thành trả lời tin nhắn một cách thân thiện, cởi mở và chuyên nghiệp.\n\n## date time now: {{ $json.currentDate }}\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.8,
      "position": [
        -1240,
        540
      ],
      "id": "c83a78b0-73b1-46f2-be1e-f51589616218",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.0-flash",
        "options": {
          "maxOutputTokens": 8192,
          "topP": 1
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1212,
        760
      ],
      "id": "845b24f4-4e93-4aba-bf19-adc4c6e3476f",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "id": "v0r1UMgepiALH7TB",
          "name": "Google Gemini(PaLM) Api account 2"
        }
      }
    },
    {
      "parameters": {
        "chatId": "-000THAYIDVAODAY000",
        "text": "={{ $('AI Agent').item.json.output.substring(0, 2000).replace(/[!@#$%^_&*()]/g, '') }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -644,
        640
      ],
      "id": "ec0dc0f2-82a9-495b-b911-ebadfb6c320a",
      "name": "Telegram3",
      "webhookId": "bd03b8b4-9ae1-4d7a-918f-540561ad4e3b",
      "disabled": true
    },
    {
      "parameters": {
        "threadId": "={{ $('Zalo User Trigger').item.json.threadId }}",
        "message": "=[Thành AI]: {{ $json.output.substring(0, 2000).replace(/[!@#$%^&*()]/g, ''); }}",
        "threadType": "={{ $('Zalo User Trigger').item.json.type }}"
      },
      "type": "n8n-nodes-zalo-user-v3.zaloUserInteract",
      "typeVersion": 1,
      "position": [
        -864,
        640
      ],
      "id": "bd074a7f-9cce-4b27-adbe-f46391df3be2",
      "name": "Zalo User Interact2",
      "credentials": {
        "zaloUserCredentialsApi": {
          "id": "vPnUgM2zqR0sRXXi",
          "name": "Zalo 4343 - 2025-04-22T07:21:22.558Z"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "926995b0-3eab-4d01-a696-a2b23ad33dc2",
              "leftValue": "={{ $json.data.content }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            },
            {
              "id": "91c38034-452d-4d49-bb31-ada7df029480",
              "leftValue": "={{ $json?.data?.content?.toLowerCase() }}",
              "rightValue": "/ai",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -1680,
        790
      ],
      "id": "ce1de0a2-bc90-4012-934d-2b1c1966999d",
      "name": "If"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-zalo-user-v3.zaloUserLogin",
      "typeVersion": 3,
      "position": [
        -1780,
        120
      ],
      "id": "0bf36b95-7426-4aeb-bd2b-2da01e6024e1",
      "name": "Zalo Login Via QR Code",
      "credentials": {
        "n8nApi": {
          "id": "gMfvC5Mv0JtH9Jv4",
          "name": "n8n account 2"
        }
      }
    },
    {
      "parameters": {
        "chatId": "-000THAYIDVAODAY000",
        "text": "={{ $json.data.dName }} ###{{ $json.threadId }}###{{ $json.type }}###: {{ $json.data.content }}\n",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -1162,
        940
      ],
      "id": "7f69948e-9eb1-49ee-bac2-ebee27b40fdf",
      "name": "Telegram4",
      "webhookId": "aafb6f74-04f3-407c-b31e-fb7dd740e4a7",
      "disabled": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "f398f8ad-d922-4481-a22a-59b54b5f03b0",
              "leftValue": "={{ $json.message.photo }}",
              "rightValue": "",
              "operator": {
                "type": "array",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        720,
        140
      ],
      "id": "8add1145-2097-4498-a383-1dbce2c2de9b",
      "name": "If3"
    },
    {
      "parameters": {
        "threadId": "={{ $('Telegram Trigger').item.json.message.reply_to_message.text.match(/###(\\d+)###/)[1] }}",
        "message": " [Sent from Telegram]",
        "threadType": "={{ $('Telegram Trigger').item.json.message.reply_to_message.text.match(/###\\d+###(\\d+)###/)[1] }}",
        "attachmentsParameter": {
          "attachmentPaths": [
            {
              "attachmentPath": "=https://api.telegram.org/file/[BOT_TOKEN]/{{ $json.result.file_path }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-zalo-user-v3.zaloUserInteract",
      "typeVersion": 1,
      "position": [
        1220,
        60
      ],
      "id": "f2fd7495-0fea-4c00-b895-2a217f7eaf43",
      "name": "Zalo User Interact3",
      "credentials": {
        "zaloUserCredentialsApi": {
          "id": "vPnUgM2zqR0sRXXi",
          "name": "Zalo 4343 - 2025-04-22T07:21:22.558Z"
        }
      }
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $('Telegram Trigger').item.json.message.photo[3].file_id }}",
        "download": false
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        980,
        60
      ],
      "id": "c3adcf3c-6060-4daf-8d94-7a552e8cdfaf",
      "name": "Telegram6",
      "webhookId": "ec51a5cf-bfd1-4e7c-8611-e2fd698893f5",
      "credentials": {
        "telegramApi": {
          "id": "VMH1B0Iv1DKRYn0e",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        100,
        660
      ],
      "id": "72e528b8-4cc8-46f2-bda3-1fb5f26bd32a",
      "name": "When clicking ‘Test workflow’"
    },
    {
      "parameters": {
        "content": "## Get All Group And Save To Google Sheets",
        "height": 460,
        "width": 2140,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        460
      ],
      "id": "235cf361-d11d-4f70-b193-817c676a920a",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/1DHJ7uKWsqEoWPFktUBM7bmBkv1tX2KA77-jyZqJ96L4/edit?usp=sharing",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "groups",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1DHJ7uKWsqEoWPFktUBM7bmBkv1tX2KA77-jyZqJ96L4/edit#gid=0"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {
            "Group ID": "={{ $json.response.gridInfoMap[Object.keys($json.response.gridInfoMap)[0]].groupId }}",
            "Name": "={{ $json.response.gridInfoMap[Object.keys($json.response.gridInfoMap)[0]].name }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Group ID",
              "displayName": "Group ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Name",
              "displayName": "Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1700,
        580
      ],
      "id": "a429e7d3-d7d6-42e2-b8f9-c08743feb3d3",
      "name": "Google Sheets",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "C7okTeJflblAUZ1o",
          "name": "Google Sheets gmail"
        }
      }
    },
    {
      "parameters": {
        "fieldToSplitOut": "groups",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        820,
        660
      ],
      "id": "fe27bf60-60b7-4b49-bc4e-e8bb45273050",
      "name": "Split Out"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        1040,
        660
      ],
      "id": "01384c7c-74c2-400c-bff7-79e5235b1bae",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "amount": 3
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1920,
        660
      ],
      "id": "7507c56d-5890-41ad-b3ed-84f01180e3eb",
      "name": "Wait",
      "webhookId": "033e056b-5913-491b-9b5e-b4d714e2e7ea"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "557c6478-4fb8-4b61-a3b8-de5d81d566ef",
              "name": "groups",
              "value": "={{ Object.keys($json.response.gridVerMap )}}",
              "type": "array"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        600,
        660
      ],
      "id": "cd3d4b77-0d3b-4cda-ae0c-3bb02b4dfee6",
      "name": "Group Array"
    },
    {
      "parameters": {
        "resource": "get",
        "operation": "getAllGroups"
      },
      "type": "n8n-nodes-zalo-user-v3.zaloUserInteract",
      "typeVersion": 1,
      "position": [
        380,
        660
      ],
      "id": "9a027fe0-710b-4896-a3df-2cccea4bee26",
      "name": "Zalo User Interact5",
      "credentials": {
        "zaloUserCredentialsApi": {
          "id": "vPnUgM2zqR0sRXXi",
          "name": "Zalo 4343 - 2025-04-22T07:21:22.558Z"
        }
      }
    },
    {
      "parameters": {
        "resource": "get",
        "operation": "getGroupInfo",
        "groupIdsParameter": {
          "groupIdValues": [
            {
              "groupId": "={{ $json.groups }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-zalo-user-v3.zaloUserInteract",
      "typeVersion": 1,
      "position": [
        1260,
        580
      ],
      "id": "c93b373b-4462-4e0f-b246-336b71857748",
      "name": "Zalo User Interact4",
      "credentials": {
        "zaloUserCredentialsApi": {
          "id": "vPnUgM2zqR0sRXXi",
          "name": "Zalo 4343 - 2025-04-22T07:21:22.558Z"
        }
      }
    },
    {
      "parameters": {
        "content": "## Get All User From Group And Save To Google Sheets",
        "height": 600,
        "width": 2140,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        980
      ],
      "id": "0807fe9c-3b23-4dc4-bd62-db15bec5a818",
      "name": "Sticky Note5"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/1DHJ7uKWsqEoWPFktUBM7bmBkv1tX2KA77-jyZqJ96L4/edit?usp=sharing",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": 543487203,
          "mode": "list",
          "cachedResultName": "members",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1DHJ7uKWsqEoWPFktUBM7bmBkv1tX2KA77-jyZqJ96L4/edit#gid=543487203"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1660,
        1140
      ],
      "id": "996ce4a4-25a3-4ff2-9abd-a67f0197d20b",
      "name": "Google Sheets1",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "C7okTeJflblAUZ1o",
          "name": "Google Sheets gmail"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        1000,
        1220
      ],
      "id": "a9103384-d5dc-474a-b3e2-bee89fe0d56d",
      "name": "Loop Over Items1"
    },
    {
      "parameters": {
        "amount": "={{ Math.floor(Math.random() * (30 - 10 + 1)) + 10 }}"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1880,
        1220
      ],
      "id": "8e85ef95-fef9-44db-bc71-83365f500b36",
      "name": "Wait1",
      "webhookId": "c36f6779-191f-465b-99a5-82c217f5f36f"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "557c6478-4fb8-4b61-a3b8-de5d81d566ef",
              "name": "groups",
              "value": "={{ $json.response.gridInfoMap[$json.response.gridInfoMap.keys().first()].memVerList }}",
              "type": "array"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        560,
        1220
      ],
      "id": "a2d5e3b6-8cce-4b7d-91c1-0b5dea3ba712",
      "name": "Group Array1"
    },
    {
      "parameters": {
        "resource": "get",
        "operation": "getGroupInfo",
        "groupIdsParameter": {
          "groupIdValues": [
            {
              "groupId": "=7469786504792335585"
            }
          ]
        }
      },
      "type": "n8n-nodes-zalo-user-v3.zaloUserInteract",
      "typeVersion": 1,
      "position": [
        340,
        1220
      ],
      "id": "8417c797-b9a9-4670-82a3-dd70e0f30e2b",
      "name": "Zalo User Interact6",
      "credentials": {
        "zaloUserCredentialsApi": {
          "id": "vPnUgM2zqR0sRXXi",
          "name": "Zalo 4343 - 2025-04-22T07:21:22.558Z"
        }
      }
    },
    {
      "parameters": {
        "resource": "get",
        "operation": "getUserInfo",
        "userId": "={{ $json.groups.split(\"_\")[0] }}"
      },
      "type": "n8n-nodes-zalo-user-v3.zaloUserInteract",
      "typeVersion": 1,
      "position": [
        1220,
        1140
      ],
      "id": "17323ad2-04e3-4794-aafd-2d54b83be7a5",
      "name": "Zalo User Interact7",
      "retryOnFail": true,
      "waitBetweenTries": 5000,
      "credentials": {
        "zaloUserCredentialsApi": {
          "id": "vPnUgM2zqR0sRXXi",
          "name": "Zalo 4343 - 2025-04-22T07:21:22.558Z"
        }
      }
    },
    {
      "parameters": {
        "fieldToSplitOut": "groups",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        780,
        1220
      ],
      "id": "65912bf3-9440-4a97-ae14-f942035bb1a6",
      "name": "Split Out2"
    },
    {
      "parameters": {
        "fieldToSplitOut": "response.changed_profiles",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        1440,
        1140
      ],
      "id": "26f6dcac-924e-400f-ada0-cf7bab16afa4",
      "name": "Split Out1"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 2,
      "position": [
        -1460,
        640
      ],
      "id": "eee47cbc-07b5-48bc-89ca-33505119b8c2",
      "name": "Date & Time"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Zalo User Trigger').item.json.data.idTo }}",
        "contextWindowLength": 1000
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        -1092,
        760
      ],
      "id": "3310e6a1-985b-401f-b090-78db7ca7a05e",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "3c6607fa-7767-4bc7-aa68-9c7c1099e499",
              "leftValue": "={{ $json.data.content }}",
              "rightValue": "Sent from Telegram",
              "operator": {
                "type": "string",
                "operation": "notContains"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -1460,
        940
      ],
      "id": "880fc14c-fd5f-4013-b7ca-22fc7639aee4",
      "name": "If1"
    },
    {
      "parameters": {
        "chatId": "-000THAYIDVAODAY000",
        "text": "={{ $json.data.content.title }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -1680,
        1190
      ],
      "id": "3a5174ea-4dd8-468f-8173-544dc722842a",
      "name": "Telegram",
      "webhookId": "16565654-591d-41dd-bbec-09f254329c22",
      "disabled": true
    },
    {
      "parameters": {
        "fieldToSplitOut": "response.gridInfoMap",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        1480,
        580
      ],
      "id": "3d584200-0fd0-4a34-8080-d8f0329378bd",
      "name": "Split Out3"
    }
  ],
  "pinData": {},
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "If3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo User Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram2",
            "type": "main",
            "index": 0
          }
        ],
        [],
        [],
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Zalo User Interact2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo User Interact2": {
      "main": [
        [
          {
            "node": "Telegram3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Date & Time",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If3": {
      "main": [
        [
          {
            "node": "Telegram6",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Zalo User Interact1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram6": {
      "main": [
        [
          {
            "node": "Zalo User Interact3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Zalo User Interact5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Zalo User Interact4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Group Array": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo User Interact5": {
      "main": [
        [
          {
            "node": "Group Array",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo User Interact4": {
      "main": [
        [
          {
            "node": "Split Out3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets1": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [],
        [
          {
            "node": "Zalo User Interact7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Group Array1": {
      "main": [
        [
          {
            "node": "Split Out2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo User Interact6": {
      "main": [
        [
          {
            "node": "Group Array1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo User Interact7": {
      "main": [
        [
          {
            "node": "Split Out1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out2": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out1": {
      "main": [
        [
          {
            "node": "Google Sheets1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Telegram4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out3": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3f3c06cb-1da2-4d62-8413-8e501c06a818",
  "meta": {
    "instanceId": "bbf85f6bf60f4f428f9bb800a84af65104d12b54938b900d8e31b5ec5fa02d99"
  },
  "id": "sK5iU6Tz1SxNmgIS",
  "tags": []
}
