laravel-notification-channels / twilio

Twilio notifications channel for Laravel
https://laravel-notification-channels.com
227 stars 36 forks source link

Twiml voice calls #111

Open TechWilk opened 4 years ago

TechWilk commented 4 years ago

Twilio now supports sending TwiML along with the initial request to create a call, rather than needing an external url to fetch TwiML from. It would be nice to support this alongside the existing url() method.

https://www.twilio.com/docs/voice/tutorials/how-to-make-outbound-phone-calls-php

Example use case:

You have a system which you want to be able to send a text-based notification to a phone. i.e. call a phone -> read out a message -> then hang up.

This can now be achieved by sending the message directly from the laravel notification, the same way you would a SMS, instead of also needing to handle urls and routing. It leaves open the whole TwiML flexibilty for more complex call chains by accepting an instance of VoiceResponse.

Previously this would be difficult for a system which didn't allow incoming network requests from the net, especially those behind a firewall, since you potentially need an entirely different system would need to handle the TwiML url responses.


Tests

I've been struggling to get the existing unit tests to pass Error: Class 'Orchestra\Testbench\TestCase' not found (I have run composer install. Will add new ones when I get past this. EDIT: So it seems github-actions doesn't get that message, so must be something on my local box. I'll take another go at it over the weekend. Any thoughts still appreciated! :)

I've opened this PR to get comments while I finish it off. There are several ways it could be implemented & happy to adjust to your style if that's preferred.

atymic commented 4 years ago

Looks awesome! Let me know when you are ready and i'll review.

andy-shi88 commented 3 years ago

@TechWilk for the Error: Class 'Orchestra\Testbench\TestCase' not found issue,

if you look into the .github/workflows/php.yml [Run Integration Tests] it installs composer require --dev --no-interaction "orchestra/testbench:^5.1" before running the tests (which is not included in the composer.json), try running that locally and it should solve the dependency issue.

andy-shi88 commented 3 years ago

also added fixes for the tests 62f90b3