Usage samples: Zalo Notification Service (ZNS)

❗️

Zalo Notification Service requires templates to be approved by the Zalo team.
Contact [email protected] or your account manager to submit new templates.

πŸ‘

Please see ChatApps Send API for the full API reference.

Sending a notification message

If you want to send a notification text message with custom parameters via ZNS, your request payload should look like this:

{
  "user": {
    "msisdn": "+84123456789"
  },
  "clientMessageId": "<optionalClientMessageId>",
  "type": "template",
  "content": {
    "template": {
      "name": "<insertTemplateId>",
      "language":"en",
      "components":[
      {
        "type": "body",
        "parameters": [
          {
            "type": "text",
            "text": "Ana",
            "name":"customer"
          },
          {
            "type": "text",
            "text": "ChatApps",
            "name": "product"
          },
          {
            "type": "text",
            "text": "24 August 2023",
            "name": "date"
          },
          {
            "type": "text",
            "text": "29012398",
            "name": "order"
          }
          ]
      }]
    }
  },
  "channels": [ { "channel": "ZaloNotification" } ]
}

The corresponding message the user will receive:

Sample notification via ZNS

Sample notification via ZNS


Sending an OTP message

If you want to send an OTP message via ZNS, the request payload will look like the following:

{
  "user": {
    "msisdn": "+84123456789"
  },
  "clientMessageId": "<optionalClientMessageId>",
  "type": "template",
  "content": {
    "template": {
      "name": "<insertTemplateId>",
      "language": "en",
      "components": [
        {
          "type": "body",
          "parameters": [
            {
              "type": "text",
              "name": "otp",
              "text": "23124"
            }
          ]
        }
      ]
    }
  },
  "channels": [
    {
      "channel": "ZaloNotification"
    }
  ]
}

The corresponding message the user will receive:

Sample OTP via ZNS

Sample OTP via ZNS


Optional: Adding SMS Fallback

If you want to add a fallback to SMS, add the following fields to the "content" object in your existing JSON payload:

{
  "fallbackText": "ĐÒy lΓ  OTP của bαΊ‘n: 23124. Đừng chia sαΊ» nΓ³ vα»›i bαΊ₯t cα»© ai.",
  "sms": {
    "encoding": "AUTO",
    "source": "<senderId>"
  }
}

πŸ“˜

You may find out more about SenderID here