Zalo Zns
Security covered
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 Callbackand access token will be stored in system. - Use service
highlands_coffee_egift.helpercall functionsendZnsNotificationto 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_toto store the destination of notification. - Add List(text) field, machine name
field_statuswith 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] nameandcodein 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 keyat /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:
- Du Giang (@sangdu2326)
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.