Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Repository files navigation

twilio-caller

Calling using twilio API from the browser. Useful for testing when developing phone calling based software. Uses @twilio/voice-sdk.

Quick start

In twilio create a new number and an app, e.g. twilio-caller and link it to the number. Also create an API key.

Then create a Function in Twilio with path /twilio-caller/handle-call and set the app's Webhook (Request URL) to the full URL of the function. This function will simply forward the call to @twilio/voice-sdk in the browser:

const assert = require('node:assert');

exports.handler = function(context, event, callback) {
  const callerId = '+123456789'; // Update with your twilio number

  // Only handle outgoing calls
  assert(event.To !== callerId.replaceAll(/[^\d+]/g, ''));

  const twiml = new Twilio.twiml.VoiceResponse();

  // set the callerId (from)
  let dial = twiml.dial({ callerId });

  dial.number(event.To);

  callback(null, twiml);
};

Ref:

Make sure you have Node.js. Now check out this repo and run yarn. Make a .env file with data from Twilio admin:

  • TWILIO_ACCOUNT_SID
  • TWIML_APP_SID
  • TWILIO_API_KEY
  • TWILIO_API_SECRET

Next generate a token:

node --experimental-strip-types makeAccessToken.ts

Start the UI server and open it in your browser.

yarn dev

Useful links

About

Call using twilio API from your browser

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.