CTRLK

Shared components

Zalo over API

|

View as Markdown

Zalo messages

Infobip supports Zalo through its dedicated API. Use the Infobip Zalo API to send notification messages to your customer base. After registering templates, use the Zalo API message method to formulate your request.

You can send multiple template messages in a single API request. Add supplementary options to your send request to use additional features.

Message options [#message-options-zalo-messages]

Additional message options can be applied to your API request.

Scheduling messages [#scheduling-messages-zalo-messages]

Every communication can be scheduled. You can set a start date, time, and time zone. Use this feature to avoid disturbing customers at inconvenient times or to send messages only during a specific period for optimal conversion.

json
1 
2 "SendAt": "2015-07-07T17:00:00.000+01:00"

An additional scheduling option is to set a sending speed limit. For example, you can limit the sending speed when sending messages in bulk to deliver messages over a longer period of time. This helps prevent overwhelming your system or agents with an influx of responses from end customers. You can set the number (amount) of messages that are sent periodically. Available time units are: minutes, hours, and days.

json
1 
2 "sendingSpeedLimit": { "amount": 30, "timeUnit": "HOUR" }

You can configure a message delivery window to control when messages can be delivered. Specify the start time (hour/minute), end time (hour/minute), and applicable days of the week. Messages outside the configured window are not delivered. All times are expressed in UTC.

json
1 
2 "deliveryTimeWindow": {"days": [ "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY" ],"from": { "hour": 6, "minute": 0 },"to": { "hour": 15, "minute": 30 }}

Validity period [#validity-period-zalo-messages]

There is a specific time period for messages during which the system tries to deliver them. For example, when you want to send a message to your audience and some users have their cell phones turned off, the system retries delivery to these users until the validity period passes. The default and maximum validity period is 48 hours. It does not need to be set for each request. To set a shorter period, define it under Validity period. Available time units are: seconds, minutes, and hours. Default value is minutes.

json
1 
2 "validityPeriod": { "amount": 30, "timeUnit": "MINUTES" }

SMS failover [#sms-failover-zalo-messages]

Add a failover to SMS option in case your Zalo message does not reach the end user within the defined period. You can also set a validity period for the SMS message. When sending by UID with SMS failover, define the phone number associated with the UID so the SMS message can reach the recipient.

json
1 
2 "smsFailover": { "sender": "41793026726", "text": "Failover message text", "validityPeriod": { "amount": 2, "timeUnit": "HOURS" } }

Platform [#platform-zalo-messages]

Zalo API works seamlessly with CPaaS X. This gives you greater flexibility in managing your configurations and resources in whatever manner that suits your needs. For more information about CPaaS X, see CPaaS X documentation.

json
1 
2 "platform": {"entityId": "priorityCustomer","applicationId": "clientTestEnvironment"}

Encryption [#encryption-zalo-messages]

Use encryption to encode the message content before transmitting it for processing. Zalo retranslates the encrypted content on their side. All template values must be encrypted using Cipher Type: RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING and Base64 encoded. Use the RSA key generated by "Get existing RSA key" or "Create a new RSA key" methods when encrypting messages.

json
1 
2 "encrypted": true

Webhooks [#webhooks-zalo-messages]

Use the webhooks > delivery > url parameter to define the URL where API responses are sent. Define the URL under the webhooks parameter of the API request.

json
1 
2 "webhooks": {"delivery": { "url": "https://www.example.com/zalo" },}


Zalo delivery reports

Delivery reports for sent Zalo messages are forwarded to your webhook endpoint. Configure the endpoint URL per message using the webhooks > delivery > url parameter, or contact your account manager to set a default endpoint.

For more information, see Receive delivery reports.



Zalo logs

Get logs for Zalo messages. None of the query parameters is mandatory. Use any combination of parameters to filter results.

NOTE

Zalo logs are available for the last 48 hours.

For more information, see Get Zalo logs.



OA follower messages

The Zalo Official Account (OA) API enables direct messaging with OA followers using the Zalo user ID (UID). UID messages are sent through the same API as ZBS Template Messages. Unlike ZBS template messages, OA follower messages do not require pre-approved templates and support a variety of content types for both outbound and inbound communication.

NOTE

Zalo OA follower messaging is available in Inbox, part of AgentOS. To enable this feature, contact your Infobip account manager.

Outbound message types

Send the following message types from the OA to Zalo users through the API.

Message typeDescription
TextPlain text message
Text + imageText message with an attached image
FileFile attachment
StickerSticker from the Zalo sticker library
GIFAnimated GIF image
User information requestForm requesting user contact details
NOTE

Quote and reply messages are supported as part of the text message type. Set the quote parameters in the API request to reply to a specific user message.

Inbound message types

Receive the following message types from Zalo users through inbound message webhooks. These webhooks use a payload that differs from the native Zalo webhook payload.

Message typeWebhook event
Textuser_send_text
Imageuser_send_image
Audiouser_send_audio
Videouser_send_video
Fileuser_send_file
Linkuser_send_link
Stickeruser_send_sticker
Locationuser_send_location
Business carduser_send_business_card


OA webhook events

Zalo OA provides webhook events for message delivery tracking.

EventDescription
DeliveryMessage was delivered to the user
SeenUser viewed a message from the OA
CTA clickUser clicked a call-to-action button in a message


RSA encryption

The Zalo Send API supports sending encrypted notification messages. All template values must be encrypted using Cipher Type RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING and Base64 encoded. Zalo stores the private key and decrypts the content on their side.

RSA key management [#rsa-key-management]

Before encrypting messages, obtain an RSA public key through the Zalo API.

Generate a new key. The RSA key generation API creates a public and private key pair. Only the public key is returned. The private key is stored by Zalo to decrypt the content.

Retrieve an existing key. If you have already generated an RSA key, use the public key get API to retrieve it.

Encrypt and send messages [#encrypt-and-send-messages]

Convert the public key string to byte array format using Base64 encoding. Encrypt all template values using the public key with Cipher Type RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING and Base64 encode the result.

To send encrypted content, set the encrypted parameter to true in the API request.

json
1 
2 "encrypted": true

Was this page helpful?