zapmizer / laravel-notification-zapmizer
A Laravel package to send WhatsApp notifications using Zapmizer API
v1.0.1
2024-07-18 18:07 UTC
README
Installation
You can install the package via composer:
composer require zapmizer/laravel-notification-zapmizer
Now publish config file
php artisan vendor:publish --provider="Notification\Zapmizer\ZapmizerServiceProvider" --tag=config --force
Setting up your Zapmizer account
- Create a API TOKEN.
- Paste your API token in your
zapmizer.php
config file. - Add environment viariables with values
ZAPMIZER_API_TOKEN="JGk2PJWYppWeCmxoGjMafasdxVfbXCS3W5OWLpnII56b32dc4" ZAPMIZER_FROM_NUMBER="558181643260"
Usage
In every Notification you wish to notify via WhatsApp, you must add a toZapmizer function and add 'zapmizer' drive into via's array:
/** * Get the notification's delivery channels. * * @return array<int, string> */ public function via(object $notifiable): array { return ['mail', 'zapmizer']; } /** * Get the WhatsApp representation of the notification. */ public function toZapmizer(object $notifiable) { $message = 'This is a message!' . PHP_EOL; //WID must follow the WhatsApp pattern, example: 558181643260; 558181643260@c.us 128172192@g.us(groups) return ZapmizerMessage::create(from: config('zapmizer.from_number'), to: $notifiable->wid)->type('chat')->text($message)->send(); }