Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.
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:

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

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 Release date
1.0.2 Stable Dec 24, 2023
1.0.1 Stable Nov 17, 2023
1.0.0 Stable Nov 17, 2023