Updated 11 February 2020
Nexmo Voice Channel is a package through which one can send and receive the Laravel notifications over a phone call. The Nexmo Voice Channel provides a notification channel for the laravel framework that works with Nexmo’s voice API.
This package provides a notification channel for the Laravel framework that works with Nexmo’s voice API, allowing text-to-speech phone calls. It also provides a fluent interface to construct your message content.
To use this notification channel, you route a notification through VoiceChannel and provide a toVoice() method.
Below is an example of How you can use the toVoice() method.
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32  | 
						use Roomies\NexmoVoiceChannel\Markup\Message; use Roomies\NexmoVoiceChannel\Markup\SayAs; use Roomies\NexmoVoiceChannel\Markup\Sentence; use Roomies\NexmoVoiceChannel\NexmoVoiceChannel; /**  * Get the notification's delivery channels.  *  * @param  mixed  $notifiable  * @return array  */ public function via($notifiable) {     return [NexmoVoiceChannel::class]; } /**  * Get the voice representation of the notification.  *  * @param  mixed  $notifiable  * @return \Roomies\NexmoVoiceChannel\Markup\Message  */ public function toVoice($notifiable) {     return new Message([         new Sentence('Hi, thanks for using Bagisto.'),         new Sentence([             'Your verification code is',             new SayAs('XYZ123')->interpretAs('spell-out')         ]),     ]); }  | 
					
package’s markup types you can use to create a notification:
| 
					 1 2 3 4 5 6 7 8  | 
						new Sentence([     'Hey!',     (new Pause)->time('1s'),     (new Prosody('Hello there!'))->volume('loud'),     (new Substitution(         (new SayAs('US'))->interpretAs('spell-out'),     ))->alias('United States'), ])  | 
					
Apart from this, you can also just return your own SSML markup as a string. This gives you complete control if you need something more custom or have more complex requirements.
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13  | 
						/**  * Get the voice representation of the notification.  *  * @param  mixed  $notifiable  * @return string  */ public function toVoice($notifiable) {     return '<speak>         <s>Hi, thanks for joining Roomies</s>         <s>Your verification code is <say-as interpret-as="spell-out">ABC123</say-as></s>     <speak>'; }  | 
					
Now, let’s dive into the main part for which you guyz are here.
Step 1: Simply use composer to install the package in to your Laravel Project
| 
					 1  | 
						composer require roomies/nexmo-voice-channel  | 
					
Step 2: you need to provide additional credentials in your environment. Note that the private key can be a string or path to the key file.
| 
					 1 2  | 
						NEXMO_APPLICATION_ID= NEXMO_PRIVATE_KEY=  | 
					
Step 3: Finally just add your call from number and voice to config/services.php under the nexmo key.
| 
					 1 2 3  | 
						'nexmo' => [     'call_from' => env('NEXMO_CALL_FROM'),     'call_voice' => env('NEXMO_CALL_VOICE', 'Kimberly'),  | 
					
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.