This package makes it easy to send TotalVoice Notifications with Laravel 5.3+.
You can install the package via composer:
composer require hafael/totalvoice-notification-channel
Add the service provider (only required on Laravel 5.4 or lower):
// config/app.php
'providers' => [
...
NotificationChannels\TotalVoice\TotalVoiceServiceProvider::class,
],
Add your TotalVoice Access Token to your config/services.php
:
// config/services.php
...
'totalvoice' => [
'access_token' => env('TOTALVOICE_ACCESS_TOKEN'),
],
...
Now you can use the channel in your via()
method inside the notification:
use NotificationChannels\TotalVoice\TotalVoiceChannel;
use NotificationChannels\TotalVoice\TotalVoiceSmsMessage;
use Illuminate\Notifications\Notification;
class AccountApproved extends Notification
{
public function via($notifiable)
{
return [TotalVoiceChannel::class];
}
public function toTotalVoice($notifiable)
{
return (new TotalVoiceSmsMessage())
->content("Your {$notifiable->service} account was approved!");
}
}
You can also send an TTS (text-to-speech) audio call:
use NotificationChannels\TotalVoice\TotalVoiceChannel;
use NotificationChannels\TotalVoice\TotalVoiceTtsMessage;
use Illuminate\Notifications\Notification;
class AccountApproved extends Notification
{
public function via($notifiable)
{
return [TotalVoiceChannel::class];
}
public function toTotalVoice($notifiable)
{
return (new TotalVoiceTtsMessage())
->content("Your {$notifiable->service} account was approved!");
}
}
Or create a TotalVoice audio call from .mp3 file url:
use NotificationChannels\TotalVoice\TotalVoiceChannel;
use NotificationChannels\TotalVoice\TotalVoiceAudioMessage;
use Illuminate\Notifications\Notification;
class AccountApproved extends Notification
{
public function via($notifiable)
{
return [TotalVoiceChannel::class];
}
public function toTotalVoice($notifiable)
{
return (new TotalVoiceAudioMessage())
->content("http://foooo.bar/audio.mp3");
}
}
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 routeNotificationForTotalVoice
method to your Notifiable model.
public function routeNotificationForTotalVoice()
{
return '+5521999999999';
}
provideFeedback(false)
: Wait for recipient feedback.multipart(false)
: Supports SMS with > 160 < 16,000 char. Sends multiple sms up to 160char to the same number.scheledule(new \DateTime())
: date and time to schedule the sms delivery. null as default sends immediately.content('')
: Accepts a string value for the notification body.
provideFeedback(false)
: Wait for recipient feedback.fakeNumber(null)
: Accepts a phone to use as the notification sender.recordAudio(false)
: Save the call.detectCallbox(false)
: Automatically disconnects within 3 seconds if it falls into the mailbox (vivo, claro, tim, oi).speed(0)
: From -10 to 10. When -10=very slow, 0=normal and 10=very fast.voiceType('br-Vitoria')
: language-Character acronym who will speak.content('')
: Accepts a string value for the notification body.
provideFeedback(false)
: Wait for recipient feedback.fakeNumber('+5521999999999')
: Accepts a phone to use as the notification sender.recordAudio(false)
: Save the call.detectCallbox(false)
: Automatically disconnects within 3 seconds if it falls into the mailbox (vivo, claro, tim, oi).content('http://foooo.bar/audio.mp3')
: Accepts an .mp3 file url for the call.
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email villa655321verde@gmail.com instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.