Type
magento2-module
Multiple channel notifier engine for Magento 2
magento2-module
OSL-3.0
None
None
None
None
Ok, if you do not have time to read this guide... here you have the short version:
composer require msp/module-notifier-all
bin/magento setup:upgrade
Then open your admin under System > MSP Notifier
menù and enjoy it ;)
MSP Notifier is a framework for Magento 2 allowing users and developers to easily integrate a wide set of communication channels to their stores.
Communication channels can be injected via DI mechanism and quickly configured via Magento admin.
MSP Notifier Project is an extensible module projected around the Domain Driven Development best practices. In other word: it can be considered a set of smaller modules with well defined responsibilities. You can decide to install the whole set of modules or just the ones you need.
Each single component is provided with a full set of API allowing features replacements with full guaranteed backward compatibility.
Before trying to install this package, make sure you are using a Magento version greater than 2.2.0. This module is not backward compatible with 2.0 or 2.1.
Open your SSH console and install via composer:
composer require msp/module-notifier-all
bin/magento setup:upgrade
This will install all the core modules provided by MageSpecialist:
msp/module-notifier
: The basic frameworkmsp/module-notifier-core-adapters
: A set of basic communication channels adapters
msp/module-notifier-admin-push-adapter
: A browser push notification system for Magento adminmsp/module-notifier-event
: An event handler to connect any Magento event to a channelmsp/module-notifier-template
: Twig template manager for messagesmsp/module-notifier-queue
: An asynchronous message dispatcher based on Magento cronIf you want to install single packages you can require just the modules you need. Composer will handle all the required dependencies.
Example:
composer require msp/module-notifier msp/module-notifier-template
bin/magento setup:upgrade
We divide notifier engine into 2 main entities:
An adapter is a set of classes created by a Magento developer to integrate an external messaging software (i.e.: Telegram, Slack, email, ...).
A channel is an adapter configured with a certain set of parameters (e.g.: Telegram Message to John Doe, Slack message to Jane Doe).
If we want for example to send a Telegram message to an imaginary user John Doe, we should create a channel
of type Telegram
and configure it with John Doe chat id
destination.
One adapter can have multiple channels, while a channel have one and only one adapter.
Each adapter or channel are identified by an alphanumeric string called code
.
Adapters codes are wired in the Magento code by their developers, while channels codes can be freely assigned
by the Magento administrator via backend.
GitHub: https://github.com/magespecialist/notifier-core-adapters
Composer: composer require msp/module-notifier-core-adapters
... // TODO
GitHub: https://github.com/magespecialist/notifier-admin-push-adapter
Composer: composer require msp/module-notifier-admin-push-adapter
... // TODO
GitHub: https://github.com/magespecialist/notifier-template
Composer: composer require msp/module-notifier-template
... // TODO
GitHub: https://github.com/magespecialist/notifier-event
Composer: composer require msp/module-notifier-event
... // TODO
GitHub: https://github.com/magespecialist/notifier-queue
Composer: composer require msp/module-notifier-queue
... // TODO
With basic framework you can decide to manually send messages from your code.
Of course this is a developer only feature, if you need something mor human usable, please refer
to the other modules (e.g.: msp/module-notifier-event
).
...
public function __construct(MSP\NotifierApi\Api\SendMessageInterface $sendMessage)
{
$this->sendMessage = $sendMessage;
}
...
public function execute()
{
... // Your code
try {
$this->sendMessage->execute('my_channel_code', 'Hello world!');
} catch (\Exception $e) {
// Do error management here... maybe your channel does not exist?
}
... // Your code
}
You can create your custom adapters and inject them via Magento DI mechanism in MSP\Notifier\Model\AdapterRepository
class.
A quick and simple example can be found in the msp/module-notifier-core-adapters
(https://github.com/magespecialist/notifier-core-adapters).
A validation and custom parameters mechanism is provided via VirtualTypes.
NOTE: In the previous example, a channel with code my_channel_code
must be configured from Magento backend.
A set of Web API is also available if you wish to remotely handle it.
A command line interface is provided to easily integrate this framework from the sysadmin point of view:
bin/magento msp:notifier:send my_channel_code "Hello world!"