laravel-notification-channels / Twilio

Licence: mit
Twilio notifications channel for Laravel

Projects that are alternatives of or similar to Twilio

Builder
Prepare your Laravel apps incredibly fast, with various commands, services, facades and boilerplates.
Stars: ✭ 1,009 (+615.6%)
Mutual labels:  laravel, notifications
Server Monitor App
A PHP application to monitor the health of your servers
Stars: ✭ 141 (+0%)
Mutual labels:  laravel, notifications
Laravel Notification
Example package for using the (still under development) Messages API from Nexmo as a notification channel in Laravel
Stars: ✭ 44 (-68.79%)
Mutual labels:  laravel, notifications
Laravel Notify
Flexible Flash notifications for Laravel
Stars: ✭ 787 (+458.16%)
Mutual labels:  laravel, notifications
Facebook
📨 Facebook Notifications Channel for Laravel
Stars: ✭ 120 (-14.89%)
Mutual labels:  laravel, notifications
Laravel Smsgateway Notification Channel
SMS Gateway notification channel for Laravel
Stars: ✭ 13 (-90.78%)
Mutual labels:  laravel, notifications
Notifier
NO LIBRARIES socket per page bridge for your Laravel application. (CLIENT PART INCLUDED)
Stars: ✭ 57 (-59.57%)
Mutual labels:  laravel, notifications
Larametrics
A self-hosted metrics and notifications platform for Laravel apps
Stars: ✭ 517 (+266.67%)
Mutual labels:  laravel, notifications
Sms
Laravel SMS Gateway Integration Package
Stars: ✭ 112 (-20.57%)
Mutual labels:  twilio, laravel
Project
⭐️ Antares Project Application Skeleton. This is the very first place you should start. It allows you to create a brand new awesome project in easy few steps.
Stars: ✭ 84 (-40.43%)
Mutual labels:  laravel, notifications
Laravel Server Monitor
Don't let your servers just melt down
Stars: ✭ 595 (+321.99%)
Mutual labels:  laravel, notifications
Laravel Fcm
Firebase Cloud Messaging (FCM) sender for Laravel
Stars: ✭ 129 (-8.51%)
Mutual labels:  laravel, notifications
Laravel Failed Job Monitor
Get notified when a queued job fails
Stars: ✭ 582 (+312.77%)
Mutual labels:  laravel, notifications
Authy
Rinvex Authy is a simple wrapper for @Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.
Stars: ✭ 34 (-75.89%)
Mutual labels:  twilio, phone
Twilio Csharp
Twilio C#/.NET Helper Library for .NET Framework 3.5+ and supported .NET Core versions
Stars: ✭ 541 (+283.69%)
Mutual labels:  twilio, phone
Laravel Fcm
🌐 A Laravel package to send Push Notifications to one or many devices of the user.
Stars: ✭ 56 (-60.28%)
Mutual labels:  laravel, notifications
Webpush
Webpush notifications channel for Laravel.
Stars: ✭ 437 (+209.93%)
Mutual labels:  laravel, notifications
Snooze
A package to simplify automating future notifications and reminders in Laravel
Stars: ✭ 515 (+265.25%)
Mutual labels:  laravel, notifications
Laravel Console Logger
Logging and Notifications for Laravel Console Commands.
Stars: ✭ 79 (-43.97%)
Mutual labels:  laravel, notifications
Laravel Phone
Phone number functionality for Laravel
Stars: ✭ 1,806 (+1180.85%)
Mutual labels:  laravel, phone

Twilio notifications channel for Laravel

Latest Version on Packagist Software License Build Status StyleCI Quality Score Code Coverage Total Downloads

This package makes it easy to send Twilio notifications with Laravel 5.5+, 6.x and 7.x

You are viewing the 3.x documentation. Click here to view the 2.x documentation.

Contents

Installation

You can install the package via composer:

composer require laravel-notification-channels/twilio

Configuration

Add your Twilio Account SID, Auth Token, and From Number (optional) to your .env:

TWILIO_USERNAME=XYZ # optional when using auth token
TWILIO_PASSWORD=ZYX # optional when using auth token
TWILIO_AUTH_TOKEN=ABCD # optional when using username and password
TWILIO_ACCOUNT_SID=1234 # always required
TWILIO_FROM=100000000 # optional default from
TWILIO_ALPHA_SENDER=HELLO # optional
TWILIO_DEBUG_TO=23423423423 # Set a number that call calls/messages should be routed to for debugging
TWILIO_SMS_SERVICE_SID=MG0a0aaaaaa00aa00a00a000a00000a00a # Optional but recommended 

Advanced configuration

Run php artisan vendor:publish --provider="NotificationChannels\Twilio\TwilioProvider"

/config/twilio-notification-channel.php

Suppressing specific errors or all errors

Publish the config using the above command, and edit the ignored_error_codes array. You can get the list of exception codes from the documentation.

If you want to suppress all errors, you can set the option to ['*']. The errors will not be logged but notification failed events will still be emitted.

Recommended Configuration

Twilio recommends always using a Messaging Service because it gives you access to features like Advanced Opt-Out, Sticky Sender, Scaler, Geomatch, Shortcode Reroute, and Smart Encoding.

Having issues with SMS? Check Twilio's best practices.

Upgrading from 2.x to 3.x

If you're upgrading from version 2.x, you'll need to make sure that your set environment variables match those above in the config section. None of the environment variable names have changed, but if you used different keys in your services.php config then you'll need to update them to match the above, or publish the config file and change the env key.

You should also remove the old entry for twilio from your services.php config, since it's no longer used.

The main breaking change between 2.x and 3.x is that failed notification will now throw an exception unless they are in the list of ignored error codes (publish the config file to edit these).

You can replicate the 2.x behaviour by setting 'ignored_error_codes' => ['*'], which will case all exceptions to be suppressed.

Usage

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

use NotificationChannels\Twilio\TwilioChannel;
use NotificationChannels\Twilio\TwilioSmsMessage;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [TwilioChannel::class];
    }

    public function toTwilio($notifiable)
    {
        return (new TwilioSmsMessage())
            ->content("Your {$notifiable->service} account was approved!");
    }
}

You can also send an MMS:

use NotificationChannels\Twilio\TwilioChannel;
use NotificationChannels\Twilio\TwilioMmsMessage;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [TwilioChannel::class];
    }

    public function toTwilio($notifiable)
    {
        return (new TwilioMmsMessage())
            ->content("Your {$notifiable->service} account was approved!")
            ->mediaUrl("https://picsum.photos/300");
    }
}

Or create a Twilio call:

use NotificationChannels\Twilio\TwilioChannel;
use NotificationChannels\Twilio\TwilioCallMessage;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [TwilioChannel::class];
    }

    public function toTwilio($notifiable)
    {
        return (new TwilioCallMessage())
            ->url("http://example.com/your-twiml-url");
    }
}

In order to let your Notification know which phone are you sending/calling to, the channel will look for the phone_number attribute of the Notifiable model. If you want to override this behaviour, add the routeNotificationForTwilio method to your Notifiable model.

public function routeNotificationForTwilio()
{
    return '+1234567890';
}

Available Message methods

TwilioSmsMessage

  • from(''): Accepts a phone to use as the notification sender.
  • content(''): Accepts a string value for the notification body.
  • messagingServiceSid(''): Accepts a messaging service SID to handle configuration.

TwilioCallMessage

  • from(''): Accepts a phone to use as the notification sender.
  • url(''): Accepts an url for the call TwiML.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].