{
  "name": "My workflow",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-zalo-user.zaloUserLogin",
      "typeVersion": 1,
      "position": [
        740,
        -20
      ],
      "id": "da8cadde-1dfc-4c47-bac3-14b163f65d72",
      "name": "Zalo User Login"
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "data",
        "options": {
          "fileName": "={{ $('Zalo User Login').item.json.code }}.png",
          "mimeType": ""
        }
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        1200,
        -20
      ],
      "id": "b400e1a9-2a76-4373-855a-053a5fbd64b1",
      "name": "Save QR code"
    },
    {
      "parameters": {
        "resource": "credential",
        "name": "={{ $json.context.uid }} - {{ $json.context.cookie.cookies[0].creation }}",
        "credentialTypeName": "zaloUserCredentialsApi",
        "data": "={{ JSON.stringify({\n\t\"cookie\": JSON.stringify({\n\t\t\t\"url\": \"https://chat.zalo.me\",\n\t\t\t\"cookies\": $json.context.cookie.cookies || \"\"\n\t}),\n\t\"imei\": $json.context.imei || \"\",\n\t\"userAgent\": $json.context.userAgent || \"\",\n    \"supportCode\": $json.supportCode || \"\"\n}) }}\n",
        "requestOptions": {}
      },
      "type": "n8n-nodes-base.n8n",
      "typeVersion": 1,
      "position": [
        2080,
        -20
      ],
      "id": "61b2b561-a3a5-4657-8505-5ee98ef03337",
      "name": "Save Login data to credential",
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "return {\"data\": $json.image}"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        980,
        -20
      ],
      "id": "6043120d-e411-4018-aa88-716d1ae9c98b",
      "name": "Prepare QR code"
    },
    {
      "parameters": {
        "path": "f4484d62-a494-4ebb-8799-7c1c2f39d888",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        540,
        -20
      ],
      "id": "fa99f5e0-83f8-42c4-a6d9-2781beefb6c7",
      "name": "Zalo Login"
    },
    {
      "parameters": {
        "respondWith": "binary",
        "options": {
          "responseHeaders": {
            "entries": [
              {
                "name": "Content-Disposition",
                "value": "=attachment; filename=\"{{$binary.data.fileName}}\""
              }
            ]
          }
        }
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1420,
        -20
      ],
      "id": "550e1886-bdcc-4e8f-acf5-5c107b7bc124",
      "name": "Download QR"
    },
    {
      "parameters": {
        "content": "## Zalo Login Via QR Code",
        "height": 280,
        "width": 1800
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        460,
        -140
      ],
      "id": "be235647-ff86-4491-8739-ee4032e959f8",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Receive events from Zalo User and trigger workflows",
        "height": 240,
        "width": 700,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        460,
        160
      ],
      "id": "d1cf28a5-cd5e-481c-ad20-189bf88c761c",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## Get All Online Friends",
        "height": 240,
        "width": 700,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        460,
        420
      ],
      "id": "1f5d01d9-222d-471b-b301-cbaf2dcd2b33",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "operation": "getAllFriends"
      },
      "type": "n8n-nodes-zalo-user.zaloUserInteract",
      "typeVersion": 1,
      "position": [
        760,
        500
      ],
      "id": "1c81e3b4-18af-41e8-b06d-ed86cf89c724",
      "name": "Zalo User Interact",
      "disabled": true
    },
    {
      "parameters": {
        "amount": 30
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1640,
        -20
      ],
      "id": "e26147a0-50d8-4f85-ad82-5aa05c4f3eed",
      "name": "Wait 30s"
    },
    {
      "parameters": {
        "events": [
          "init",
          "update",
          "activate"
        ]
      },
      "type": "n8n-nodes-zalo-user.zaloUser",
      "typeVersion": 2,
      "position": [
        620,
        220
      ],
      "id": "45a909f3-498a-49b1-a9d9-04cad321b0c3",
      "name": "Zalo User Trigger",
      "disabled": true
    },
    {
      "parameters": {
        "chatId": "nhapchatid",
        "text": "={{ $json.data.dName }} ###{{ $json.threadId }}###: {{ $json.data.content }}\n",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        840,
        220
      ],
      "id": "0f7d77b1-0bdb-47cb-839a-aa839a88b707",
      "name": "Telegram",
      "disabled": true
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        1280,
        220
      ],
      "id": "6e6f066b-ec36-4ac8-8b86-9288057d671b",
      "name": "Telegram Trigger",
      "disabled": true
    },
    {
      "parameters": {
        "userId": "={{ $json.message.reply_to_message.text.match(/###(\\d+)###/)[1] }}",
        "message": "={{ $json.message.text }}"
      },
      "type": "n8n-nodes-zalo-user.zaloUserInteract",
      "typeVersion": 1,
      "position": [
        1480,
        220
      ],
      "id": "804101a8-2ad2-46e2-8eb0-756a68d98b52",
      "name": "Zalo User Interact2",
      "disabled": true
    },
    {
      "parameters": {
        "content": "## Anwser Zalo messages via Telegram",
        "height": 240,
        "width": 840,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1200,
        160
      ],
      "id": "22f743ce-3c55-4bc5-9129-ac1cbb37c345",
      "name": "Sticky Note3"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-zalo-user.zaloUserSaveLogin",
      "typeVersion": 1,
      "position": [
        1860,
        -20
      ],
      "id": "3a48571f-ab31-4722-a416-742212b56208",
      "name": "Zalo User Save Login"
    }
  ],
  "connections": {
    "Save QR code": {
      "main": [
        [
          {
            "node": "Download QR",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare QR code": {
      "main": [
        [
          {
            "node": "Save QR code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download QR": {
      "main": [
        [
          {
            "node": "Wait 30s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo User Interact": {
      "main": [
        []
      ]
    },
    "Wait 30s": {
      "main": [
        [
          {
            "node": "Zalo User Save Login",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo User Trigger": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Zalo User Interact2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo Login": {
      "main": [
        [
          {
            "node": "Zalo User Login",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo User Login": {
      "main": [
        [
          {
            "node": "Prepare QR code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo User Save Login": {
      "main": [
        [
          {
            "node": "Save Login data to credential",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "6566731c-bd87-4d20-88cd-6fff5ae58d5a",
  "id": "tonbM7Q0pKJMFiPy",
  "tags": []
}