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!
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/user/account/apps/add and use its Sid
as the TWIML_APP_SID
environment variable wherever you run this app.
See the end of the "Local development" section for details on the exact URL to use in your TwiML 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.
First you need to install either Node.js or io.js, both of which should also install npm.
-
This sample application stores data in a MongoDB database using Mongoose. You can download and run MongoDB yourself (OS X, Linux, Windows).
On OS X, maybe the easiest way to get MongoDB running locally is to install via Homebrew.
$ brew install mongodb
You should then be able to run a local server with:
$ mongod
To run the app locally, clone this repository and cd
into its directory:
-
First clone this repository and
cd
into its directory:git clone [email protected]:TwilioDevEd/browser-calls-node.git cd browser-calls-node
-
Install dependencies:
npm install
-
Edit the sample configuration file
.env
to match your configuration.Once you have edited the
.env
file, if you are using a UNIX operating system, just use the source command to load the variables into your environment:
$ source .env
-
Run the application.
node .
Alternatively you might also consider using nodemon for this. It works just like the node command, but automatically restarts your application when you change any source code files.
npm install -g nodemon nodemon .
-
Run the application.
$ npm start
To actually forward incoming calls, your development server will need to be publicly accessible. We recommend using ngrok to solve this problem.
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:
http://88b37ada.ngrok.io/call/connect
- Check it out at http://localhost:3000
That's it
You can run the tests locally by typing
mocha test
- No warranty expressed or implied. Software is as is. Diggity.
- MIT License
- Lovingly crafted by Twilio Developer Education.