We are currently in the process of updating this sample template. If you are encountering any issues with the sample, please open an issue at github.com/twilio-labs/code-exchange/issues and we'll try to help you.
Learn how to use Twilio Client to make browser-to-phone and browser-to-browser calls with ease. The unsatisfied customers of the Birchwood Bicycle Polo Co. need your help!
Implementations in other languages:
.NET | Java | Python | Ruby | Node |
---|---|---|---|---|
Done | Done | Done | Done | Done |
- PHP >= 7.2.5 and composer
- Node.js
- SQLite
- A Twilio account - sign up
This application should give you a ready-made starting point for writing your own application. Before we begin, we need to collect all the config values we need to run the application:
Config Value | Description |
---|---|
Account Sid | Your primary Twilio account identifier - find this in the Console. |
Phone number | A Twilio phone number in E.164 format - you can get one here |
App Sid | The TwiML application with a voice URL configured to access your server running this app - create one in the console here. Also, you will need to configure the Voice "REQUEST URL" on the TwiML app once you've got your server up and running. |
API Key / API Secret | Your REST API Key information needed to create an Access Token - create one here. |
This project is configured to use a TwiML App, which allows us to easily set the voice URLs for all Twilio phone numbers we purchase in this app.
Create a new TwiML app at https://www.twilio.com/console/voice/twiml/apps and use its Sid
as the TWILIO_APPLICATION_SID
environment variable wherever you run this app.
Once you have created your TwiML app, configure your Twilio phone number to use it (instructions here).
If you don't have a Twilio phone number yet, you can purchase a new number in your Twilio Account Dashboard.
After the above requirements have been met:
-
Clone this repository and
cd
into itgit clone [email protected]:TwilioDevEd/browser-calls-laravel.git cd browser-calls-laravel
-
Install PHP dependencies
make install
-
Set your environment variables
cp .env.example .env
See Twilio Account Settings to locate the necessary environment variables.
-
Install Node dependencies
npm install
-
Build the frontend assets
npm run dev
-
Run the application
php artisan serve
-
Run the application
make serve
-
Expose the application to the wider Internet using ngrok
$ ngrok http 8000
Once you have started ngrok, update your TwiML app's voice URL setting to use your ngrok hostname, so it will look something like this:
https://<your-ngrok-subdomain>.ngrok.io/support/call
-
To create a support ticket go to the home page. On this page you could fill some fields and create a ticket or you can call to support.
https://<your-ngrok-subdomain>.ngrok.io
Note: Make sure you use the
https
version of your ngrok URL as some browsers won't allow access to the microphone unless you are using a secure SSL connection. -
To respond to support tickets go to the
dashboard
page (you should open two windows or tabs). On this page you could call customers and answers phone calls.https://<your-ngrok-subdomain>.ngrok.io/dashboard
That's it!
If you have Docker already installed on your machine, you can use our docker-compose.yml
to setup your project.
- Make sure you have the project cloned.
- Setup the
.env
file as outlined in the Local Development steps. - Run
docker-compose up
. - Follow the steps in Local Development on how to expose your port to Twilio using a tool like ngrok and configure the remaining parts of your application
You can run the Unit and Feature tests locally by typing:
php artisan test
Additionally to trying out this application locally, you can deploy it to a variety of host services. Here is a small selection of them.
Please be aware that some of these might charge you for the usage or might make the source code for this application visible to the public. When in doubt research the respective hosting service first.
Service | |
---|---|
Heroku |
- The CodeExchange repository can be found here.
This template is open source and welcomes contributions. All contributions are subject to our Code of Conduct.
No warranty expressed or implied. Software is as is.