{
  "name": "Zalo User Demo Connect Telegram",
  "nodes": [
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "data",
        "options": {
          "fileName": "={{ $('Zalo User Login').item.json.code }}.png",
          "mimeType": ""
        }
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        740,
        120
      ],
      "id": "8c0c3ffb-51dc-4882-949e-bb1dd7a92228",
      "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": [
        1620,
        120
      ],
      "id": "838fc217-1785-4450-a617-2037f8c02991",
      "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": [
        520,
        120
      ],
      "id": "905afc4f-ae9b-45a0-a742-5f2d61ae5e24",
      "name": "Prepare QR code"
    },
    {
      "parameters": {
        "path": "f4484d62-a494-4ebb-8799-7c1c2f39d888",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        80,
        120
      ],
      "id": "bbbb31eb-02e2-40a4-a091-079b651fca38",
      "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": [
        960,
        120
      ],
      "id": "cc29ed99-7367-455c-80f9-0508786491a3",
      "name": "Download QR"
    },
    {
      "parameters": {
        "content": "## Zalo Login Via QR Code",
        "height": 280,
        "width": 1800
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "dbf07424-c299-44cb-9aac-2f260f7f6716",
      "name": "Sticky Note"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        80,
        640
      ],
      "id": "abb8b877-b0a1-4c52-8ad1-e759229f0977",
      "name": "When clicking \u2018Test workflow\u2019"
    },
    {
      "parameters": {
        "content": "## Receive events from Zalo User and trigger workflows",
        "height": 240,
        "width": 700,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        300
      ],
      "id": "5cb971f9-467d-42b8-995d-62d6b0345edb",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## Get All Online Friends",
        "height": 240,
        "width": 700,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        560
      ],
      "id": "87b262d5-4476-469c-bb32-5d0930989fda",
      "name": "Sticky Note2"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-zalo-user.zaloUserLogin",
      "typeVersion": 2,
      "position": [
        300,
        120
      ],
      "id": "8ff7791e-9883-4268-a16c-34b7fe4bf157",
      "name": "Zalo User Login"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-zalo-user.zaloUserSaveLogin",
      "typeVersion": 1,
      "position": [
        1400,
        120
      ],
      "id": "a26c50c0-7b15-4aab-bf32-71551e64941a",
      "name": "Zalo User Save Login"
    },
    {
      "parameters": {
        "operation": "getAllFriends"
      },
      "type": "n8n-nodes-zalo-user.zaloUserInteract",
      "typeVersion": 1,
      "position": [
        300,
        640
      ],
      "id": "54ad63de-8461-42d8-b396-966026fbe165",
      "name": "Zalo User Interact",
      "credentials": {
        "zaloUserCredentialsApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "sendStickerMessage",
        "userId": "=123",
        "stickerKeywords": "hello"
      },
      "type": "n8n-nodes-zalo-user.zaloUserInteract",
      "typeVersion": 1,
      "position": [
        520,
        640
      ],
      "id": "75cf83d5-6c98-400f-bc47-36b7b127d605",
      "name": "Zalo User Interact1",
      "credentials": {
        "zaloUserCredentialsApi": {
          "name": "<your credential>"
        }
      },
      "disabled": true
    },
    {
      "parameters": {
        "amount": 30
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1180,
        120
      ],
      "id": "a96efa3f-e013-4754-85b9-dfb8f5e2d380",
      "name": "Wait 30s"
    },
    {
      "parameters": {
        "events": [
          "init",
          "update",
          "activate"
        ]
      },
      "type": "n8n-nodes-zalo-user.zaloUser",
      "typeVersion": 2,
      "position": [
        160,
        360
      ],
      "id": "3afb9227-cc2a-4398-a6f0-c9819eb70a9b",
      "name": "Zalo User Trigger",
      "credentials": {
        "zaloUserCredentialsApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "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": [
        380,
        360
      ],
      "id": "02fb0e27-b971-432a-adc1-058827c2aca3",
      "name": "Telegram",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        820,
        360
      ],
      "id": "beb593ce-5c5c-4c62-b32b-b6645fd397f1",
      "name": "Telegram Trigger",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "userId": "={{ $json.message.reply_to_message.text.match(/###(\\d+)###/)[1] }}",
        "message": "={{ $json.message.text }}"
      },
      "type": "n8n-nodes-zalo-user.zaloUserInteract",
      "typeVersion": 1,
      "position": [
        1020,
        360
      ],
      "id": "90be3a9f-47d7-4db6-9193-171d77bbb990",
      "name": "Zalo User Interact2",
      "credentials": {
        "zaloUserCredentialsApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## Anwser Zalo messages via Telegram",
        "height": 240,
        "width": 840,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        740,
        300
      ],
      "id": "40701bd8-b881-40a3-a64b-89e32a20588f",
      "name": "Sticky Note3"
    }
  ],
  "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 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
          }
        ]
      ]
    },
    "When clicking \u2018Test workflow\u2019": {
      "main": [
        [
          {
            "node": "Zalo User Interact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zalo User Interact": {
      "main": [
        [
          {
            "node": "Zalo User Interact1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "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
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3a75dab6-0822-4f3e-b827-80a657b1896b",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "LNBNpPauYGtb62M8",
  "tags": []
}