JAYbranding

Zalo OA API & ZNS Integration: The Ultimate Digital Customer Care Strategy

In Vietnam, if your customers aren't on Facebook, they are almost certainly using Zalo. With over 75 million active users, Zalo is no longer just a chat app—it has become the #1 digital business storefront for Vietnamese enterprises through Zalo Official Account (OA). In particular, ZNS (Zalo Notification Service) is a game-changing API solution for sending customer care notifications at 40–50% lower costs than traditional SMS, while delivering rich content complete with your brand logo.

1. What Are Zalo OA & ZNS?

- Zalo OA (Official Account): A business profile on Zalo (similar to a Facebook Page) where customers can chat, place orders, and read articles. - ZNS (Zalo Notification Service): An API that enables businesses to send notification messages (OTPs, order updates, appointment reminders) directly to customers' phone numbers even if they have NOT followed your OA yet.

2. How to Register for ZNS

- Register a Zalo OA: Visit oa.zalo.me. (Business license required). - Verify Your OA: To use the API, your OA must have the gold verified badge. - Create an App (App ID): Go to developers.zalo.me to obtain your `App ID` and `Secret Key`. - Top Up & Register Message Templates: ZNS does not allow free-form messaging. You must create a template (e.g., "Hello A, order B has been delivered") and submit it to Zalo for approval.

3. Technical Guide: Sending ZNS via API

Step 1: Get an Access Token (OAuth 2.0)

Zalo uses a relatively strict Refresh Token mechanism. Each Access Token is valid for only 25 hours. <code>// Function to get a new Access Token from Refresh Token function getZaloAccessToken($refreshToken) { $appId = "YOUR_APP_ID"; $secretKey = "YOUR_SECRET_KEY"; $url = "https://oauth.zalo.me/v4/access_token"; $data = [ 'app_id' => $appId, 'grant_type' => 'refresh_token', 'refresh_token' => $refreshToken ]; $headers = [ 'Content-Type: application/x-www-form-urlencoded', 'secret_key: ' . $secretKey ]; // ... (CURL code to send POST request) ... // Returns JSON containing the new access_token and new refresh_token }</code></pre>

Step 2: Call the ZNS Messaging API

<p>Endpoint: <code>https://business.openapi.zalo.me/message/template</code> <code>$accessToken = "RETRIEVED_ACCESS_TOKEN"; $templateId = "123456"; // Approved template ID $phone = "84909123456"; // Customer phone number (84...) $templateData = [ 'customer_name' => 'Nguyen Van A', 'order_code' => 'DH9999', 'date' => '30/01/2026' ]; $body = [ 'phone' => $phone, 'template_id' => $templateId, 'template_data' => $templateData, 'tracking_id' => 'TRACK_' . time() ]; $ch = curl_init('https://business.openapi.zalo.me/message/template'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'access_token: ' . $accessToken, 'Content-Type: application/json' ]); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); $result = curl_exec($ch); // Check result: error = 0 means success</code></pre>

4. Common "Headache" Issues When Integrating Zalo

- Expired Token Errors: Many developers overlook automated token refreshing. If your website has low traffic and the token expires before anyone triggers a refresh, the API connection breaks. You should set up a Cronjob to refresh tokens periodically. - Rate Limits: Zalo enforces strict request limits. Sending requests too rapidly will result in temporary blocks. - Undelivered Messages: If a customer blocks messages from strangers or hasn't used Zalo in a long time, ZNS delivery will fail. You need an SMS Fallback mechanism in place.

5. JAYbranding's Zalo Automation Solution

<p>We provide a comprehensive Zalo Marketing module: - ✅ Auto Refresh Token: Dedicated server infrastructure ensures your token stays "alive" 24/7. - ✅ Smart Fallback: Sends via Zalo first -> If delivery fails (after 15s) -> Automatically falls back to SMS Brandname. Maximizes cost efficiency. - ✅ Zalo Mini App: Integrates a full e-commerce app directly inside Zalo to leverage its massive ecosystem. 📞 Automate your customer care with ZNS today! Hotline: 0989 971 131

Zalo API FAQ

[faqs] #### How much does it cost to send a ZNS message? Around 200 - 300 VND per message (significantly cheaper than standard SMS at 500 - 800 VND). You are only charged for successfully delivered messages. #### Can ZNS be used to send promotional content? Yes, though approval is much stricter and pricing is higher than customer care notifications. ZNS is generally best used for order updates and OTPs. [/faqs]