Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Zalo Zns

Security covered Under active development

This module integrates with the Zalo ZNS service to send notifications. It allows configuration of Zalo API credentials and provides tools to send and manage ZNS messages, including webhook support for status updates.

Zalo Zns

Contents of this file

  • Introduction
  • Requirements
  • Configuration
  • Maintainers

Introduction

Integrate Zalo Zns service to send Zns notification.

Requirements

This module requires Drupal core >= 10.0.

"zaloplatform/zalo-php-sdk": "^4.0" (have to apply patch fix_deprecated_in_zalo_sdk.patch)

Optional modules: drupal/restui, drupal/message_notify

Configuration

Set up Zalo ZNS

Set up on Drupal

  • Config App ID, App secret, OA secret key (Optional, for webhook), Development mode at /admin/config/system/zalo-zns-settings
  • or set app_id, app_secret, oa_secret_key and development_mode config in settings.php
      $config['zalo_zns.settings']['app_id'] = '21365**********387'; // Required
      $config['zalo_zns.settings']['app_secret'] = '457k*********vnkh'; // Required
      $config['zalo_zns.settings']['development_mode'] = TRUE; // Required
      $config['zalo_zns.settings']['oa_secret_key'] = 'AMX*******4fHgZ'; // Optional, for webhook
    
  • Enable rest resource Zalo OA Callback, allow anonymous access.
  • Go to /zalo-zns/zalo-access-token-request to get link to request access token.
  • Click on the generated link, it will redirect to Zalo page to login and grant permission.
  • After that, Zalo will send request to webhook Zalo OA Callback and access token will be stored in system.
  • Use service highlands_coffee_egift.helper call function sendZnsNotification to send ZNS notification.

Use Module Message and Message Notify to Send and Manage ZNS notifications.

  • Create a message template.
  • Add Text(plain) field, machine name field_send_to to store the destination of notification.
  • Add List(text) field, machine name field_status with allowed values as below to store the status of notification.
      draft|Draft
      sent|Sent
      success|Success
      failed|Failed
    
  • Add parameter fields, Text(plain) fields, Ex. field_name, field_code, ....
  • In Message Text, set the template as below:
      template_id|293305
      template_data.name|[message:field_name:value]
      template_data.code|[message:field_code:value]
    
  • name and code in example above are mapping with template parameters in registered ZNS template.
  • Example Code to notify Zns:
      /** @var \Drupal\message_notify\MessageNotifier $notifier */
      $notifier = \Drupal::service('message_notify.sender');
      $message = Message::create([
        'template' => <template_id>,
        'field_send_to' => 84937662221, // Have to be a vietnam format phone number
        'field_name' => 'Du Giang',
        'field_code' => 'abcd1234',
      ]);
      $message->save();
      $notifier->send($message, [], 'zalo_zns');
    

Webhook update status after user receive ZNS message notification

  • Enable rest resource Zalo Notification Webhook, allow anonymous access.
  • Config OA secret key at /admin/config/system/zalo-zns-settings
  • or set app_id, app_secret, oa_secret_key and development_mode config in settings.php
      $config['zalo_zns.settings']['oa_secret_key'] = 'AMX*******4fHgZ';
    

Cron job

  • Enable Default cron Handler of Zalo ZNS to renew refresh token weekly.

Maintainers

Current maintainers:

Drupal 10 · not 11

Ask your assistant about Zalo Zns

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • rest Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
3
Tracked since
Nov 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
1.0.2 Stable 10 Dec 24, 2023
1.0.1 Stable 10 Nov 17, 2023
1.0.0 Stable 10 Nov 17, 2023