You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-1Lines changed: 30 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -131,7 +131,7 @@ class AccountApproved extends Notification
131
131
}
132
132
```
133
133
134
-
Or create a Twilio call:
134
+
Or create a Twilio call, using either an external TwiML url:
135
135
136
136
```php
137
137
use NotificationChannels\Twilio\TwilioChannel;
@@ -153,6 +153,32 @@ class AccountApproved extends Notification
153
153
}
154
154
```
155
155
156
+
Or create a Twilio call, and send a TwiML response directly:
157
+
158
+
```php
159
+
use NotificationChannels\Twilio\TwilioChannel;
160
+
use NotificationChannels\Twilio\TwilioCallMessage;
161
+
use Illuminate\Notifications\Notification;
162
+
use Twilio\TwiML\VoiceResponse;
163
+
164
+
class AccountApproved extends Notification
165
+
{
166
+
public function via($notifiable)
167
+
{
168
+
return [TwilioChannel::class];
169
+
}
170
+
171
+
public function toTwilio($notifiable)
172
+
{
173
+
return (new TwilioCallMessage())
174
+
->twiml(
175
+
(new VoiceResponse())
176
+
->say('Hello world')
177
+
);
178
+
}
179
+
}
180
+
```
181
+
156
182
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.
157
183
158
184
```php
@@ -174,6 +200,9 @@ public function routeNotificationForTwilio()
174
200
175
201
-`from('')`: Accepts a phone to use as the notification sender.
176
202
-`url('')`: Accepts an url for the call TwiML.
203
+
-`twiml(VoiceResponse)`: Accepts a \Twilio\TwiML\VoiceResponse containing the call TwiML.
204
+
205
+
> You can use *either* url() *or* twiml() on a TwilioCallMessage object, not both.
0 commit comments