randhipp/wafvel-notification

Laravel Notification Channel - Whatsapp chat - using POST request to wafvel.com API

dev-main 2020-12-29 14:56 UTC

This package is auto-updated.

Last update: 2024-04-29 04:53:25 UTC


README

This package makes it easy to send whatsapp using the Laravel notification system.

Installation

You can install the package via composer:

composer require randhipp/wafvel-notification

Usage

Now you can use the channel in your via() method inside the notification:

use Wafvel\Notification\WafvelChannel;
use Wafvel\Notification\WafvelMessage;
use Illuminate\Notifications\Notification;

class ProjectCreated extends Notification
{
    protected $data;

    public function __construct($data = null)
    {
        $this->data = $data;
    }

    public function via($notifiable)
    {
        return [WafvelChannel::class];
    }

    public function toWafvel($notifiable)
    {
        $message = $this->data ?? "Your Chat Message\nNew Line";

        return WafvelMessage::create()
            ->token('') // bot token, if not specified will using env value WAFVEL_BOT_TOKEN
            ->phone('628123456789') // format : 628123456789 => {countrycode:id}{phonenumber_without_leading_zero:08123456789}
            ->message($message);
    }
}

Available methods

  • token(''): Accepts a token from wafvel.com - register free!
  • phone(''): Accepts a recipient phone number
  • message(''): Accepts a string value for the message

Security

If you discover any security related issues, please email randhi.pp@gmail.com instead of using the issue tracker.

Credits

This Project based on Webhook Notification Channel by Marcel Pociot

License

The MIT License (MIT). Please see License File for more information.