Zalo Send Message icon

Zalo Send Message

Gửi tin nhắn qua API Zalo sử dụng kết nối đăng nhập bằng cookie

Overview

This node integrates with the Zalo platform to send text-to-speech (TTS) messages directly to a user or group chat. It converts input text into speech audio using Zalo's TTS API and then sends the generated voice message through the Zalo messaging API. This is useful for automating voice notifications, alerts, or personalized audio messages in Zalo conversations.

Practical examples include:

  • Sending automated voice reminders or announcements to a group.
  • Delivering personalized voice messages to individual users.
  • Converting dynamic text content into speech and sending it as an audio message without manual intervention.

Properties

Name Meaning
Thread ID The unique identifier of the user or group chat where the TTS message will be sent.
Type Specifies whether the thread is a User (0) or a Group (1).
Text The text content that will be converted into speech audio.
Voice (Giọng đọc) The voice profile used for speech synthesis. Options include various male/female voices from different Vietnamese regions:
- Phụ nữ miền Nam 1
- Phụ nữ miền Bắc 1
- Đàn ông miền Nam
- Đàn ông miền Bắc
- Phụ nữ miền Bắc 2
- Phụ nữ miền Nam 2
EnCode Output The audio encoding format for the output speech. Options: WAV (0), MP3 (1), AAC (2).
Speed Playback speed of the synthesized speech, ranging from 0.8 (slower) to 1.2 (faster).

Output

The node outputs a JSON object containing:

  • success: Boolean indicating if the operation was successful.
  • message: Confirmation string, e.g., "TTS voice message sent successfully."
  • response: The raw response from the Zalo messaging API after sending the voice message.
  • threadId: The ID of the user or group thread where the message was sent.
  • threadType: Numeric value representing the thread type (User=0, Group=1).
  • ttsUrl: The URL of the generated speech audio file returned by the Zalo TTS API.

No binary data is output directly; instead, the node uses URLs referencing the audio files hosted by Zalo.

Dependencies

  • Requires valid credentials for two APIs:
    • An API key credential for the Zalo TTS service to convert text to speech.
    • An API key credential for the Zalo messaging API authenticated via cookie, IMEI, and user agent.
  • The node makes HTTP POST requests to https://api.zalo.ai/v1/tts/synthesize for TTS conversion.
  • Uses the Zalo SDK client to send voice messages to specified threads.
  • Requires proper configuration of these credentials within n8n before use.

Troubleshooting

  • Zalo login error: If the node fails to initialize the Zalo API client, verify that the provided cookie, IMEI, and user agent credentials are correct and active.
  • Missing or invalid TTS API key: The node throws an error if the Zalo TTS API key is not set or invalid. Ensure the API key credential is created and linked properly.
  • Failed to get audio URL: If the TTS API response does not contain a valid audio URL, check the input text and parameters for correctness and retry.
  • HTTP request errors: Network issues or incorrect API endpoints can cause failures. Confirm network connectivity and API endpoint availability.
  • Invalid thread ID or type: Sending messages to non-existent or unauthorized threads may fail. Verify the thread ID and type correspond to valid Zalo users or groups.
  • Playback speed out of range: The speed parameter must be between 0.8 and 1.2; values outside this range may cause errors.

Links and References

Discussion