Zalo User Login

Generate QR Code for Zalo login

Check Login Status

AI-generated

Overview

This node facilitates user login to the Zalo platform by generating a QR code for scanning and checking the login status. It supports three main operations:

  • Generate QR Code: Immediately creates a QR code that users scan with their Zalo mobile app to initiate login.
  • Check Login Status: Verifies if the user has successfully logged in after scanning the QR code.
  • Generate QR + Wait for Login: Generates a QR code and waits (polls) until the user completes the login process.

Typical use cases include automating authentication workflows where Zalo user sessions are required, such as integrating Zalo messaging or services into an n8n workflow. For example, a workflow could generate a QR code, send it to a user, then check periodically if the user has logged in, finally extracting session data for further API calls.

Properties

Name Meaning
Debug Mode Boolean flag to enable debug information in the output when performing the "Check Login Status" operation.

Note: The "Debug Mode" property is only applicable when the operation is set to "Check Login Status".

Output

The node outputs JSON data and may include binary data depending on the operation:

  • Generate QR Code (generateQR):

    • json:
      • success: Indicates if QR generation was successful.
      • message: Confirmation message.
      • operation: The operation performed ("generateQR").
      • qrTimeout: Timeout duration for scanning.
      • timestamp: ISO timestamp of the operation.
      • status: Status string, e.g., "qr_ready".
      • nextSteps: Array of instructions guiding the user on what to do next.
    • binary:
      • qrCode: Contains the QR code image data in PNG format, including:
        • data: Base64-encoded PNG image.
        • mimeType: "image/png".
        • fileName: "zalo_qr_code.png".
        • fileExtension: "png".
  • Check Login Status (checkStatus):

    • json:
      • cookie: A string representing the extracted session cookie or status message.
      • instructions: Steps to use the cookie for creating credentials.
      • If debug mode is enabled, additional detailed debug information about session file existence, parsing, and cookie extraction steps is included under a debug field.
  • Generate QR + Wait for Login (generateAndWait):

    • Similar to generateQR but the node waits for the user to complete login within the timeout period.
    • Outputs either the session cookie upon successful login or timeout/failure messages.
    • Includes the QR code binary data as above.

If any operation fails, the output JSON contains:

  • success: false
  • error: Error message string
  • message: General failure message
  • timestamp: ISO timestamp of the error occurrence

Dependencies

  • Requires access to the local filesystem to read/write session and QR code files (zalo_session.json, qr.png).
  • Uses an external library (imported as zca-js) to interact with Zalo's login API and generate QR codes.
  • No explicit external API keys or credentials are handled directly by this node; instead, it produces session cookies that can be used to create separate Zalo User Credentials in n8n.
  • The node expects to run in an environment where it can write/read files in the current working directory.

Troubleshooting

  • Common Issues:

    • QR code file not generated or missing (qr.png): The node waits up to 30 seconds for the QR code file to appear. If it does not, the operation fails.
    • Session file missing or corrupted (zalo_session.json): The node reports no session found or parse errors. Regenerating the QR code usually resolves this.
    • Login timeout: When waiting for login, if the user does not scan and confirm within the timeout, the node returns a timeout message.
    • Cookie extraction failure: If the session data structure changes or is incomplete, the node may fail to extract a valid cookie string.
  • Error Messages:

    • "Failed to generate QR code file": Indicates the QR code image was not created in time.
    • "Login failed or in progress": The user has not completed login yet or login failed.
    • "Error reading session": The session file could not be parsed or read.
    • "Operation failed": Generic catch-all for unexpected errors during execution.
  • Resolutions:

    • Ensure the environment allows file system operations.
    • Retry generating the QR code if session or QR code files are missing or corrupted.
    • Use the debug mode to get detailed insights into session file contents and cookie extraction steps.
    • Follow the provided instructions carefully to create Zalo User Credentials using the extracted cookie.

Links and References


This summary is based solely on static analysis of the provided source code and input properties.

Discussion