twilio icon indicating copy to clipboard operation
twilio copied to clipboard

Twiml voice calls

Open TechWilk opened this issue 5 years ago • 3 comments
trafficstars

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.

TechWilk avatar Oct 28 '20 21:10 TechWilk

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

atymic avatar Oct 29 '20 21:10 atymic

@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 avatar Mar 23 '21 09:03 andy-shi88

also added fixes for the tests 62f90b3

andy-shi88 avatar Mar 23 '21 10:03 andy-shi88