npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

twilio-api

v0.3.3

Published

Add voice and SMS messaging capabilities to your Node.JS applications with node-twilio-api - a high-level Twilio helper library to make Twilio API requests, handle incoming requests, and generate TwiML

Downloads

91

Readme

Add voice and SMS messaging capabilities to your Node.JS applications with node-twilio-api!

node-twilio-api

A high-level Twilio helper library to make Twilio API requests, handle incoming requests, and generate TwiML.

Also ships with Connect/Express middleware to handle incoming Twilio requests.

IMPORTANT: You will need a Twilio account to get started (it's not free). Click here to sign up for an account

Install

This project is in an alpha stage. You cannot install it (yet). Use at your own risk!

Features and Library Overview

Only voice calls are supported at this time, but I plan to implement the entire Twilio API over the next few months.

  • Manage accounts and subaccounts
    • Client.getAccount
    • Client.createSubAccount
    • Client.listAccounts
    • Account.load
    • Account.save
    • Account.closeAccount
    • Account.suspendAccount
    • Account.activateAccount
  • List available local and toll-free numbers
    • Account.listAvailableLocalNumbers
    • Account.listAvailableTollFreeNumbers
  • Manage Twilio applications
    • Account.getApplication
    • Account.createApplication
    • Account.listApplications
    • Application.load
    • Application.save
    • Application.delete
  • List calls and modify live calls
  • Place calls
    • Application.makeCall
  • Receive calls
    • Application incomingCall Event
  • Generate TwiML responses without writing any XML - I am a XML hater.

Todo

  • List and manage valid outgoing phone numbers
  • List and provision incoming phone numbers
  • Support for Twilio Connect Applications
  • List and manage conferences, conference details, and participants
  • Send/receive SMS messages
    • List SMS short codes and details
  • Access recordings, transcriptions, and notifications
  • Respond to fallback URLs

Usage

  1. Create a Client using your Account SID and Auth Token.
  2. Select your main account or a subaccount.
  3. Do stuff...
    • Call API functions against that account (i.e. place a call)
    • Write logic to generate TwiML when Twilio sends a request to your application (i.e. when an incoming call rings)
var express = require('express'),
    app = express.createServer();
var twilioAPI = require('twilio-api'),
	twilio = new twilioAPI.Client(ACCOUNT_SID, AUTH_TOKEN);
twilio.function(err, twapp) {
	if(err) throw err;
	var from = "+15105555555", to = "+16175551212";
	twapp.makeCall(from, to, {
		'timeout': 40
	});
	app.use(twapp.middleware() );
});

API Overview

Applications

twilio.createApp(...)

Creates an application

twilio.loadApp([account_sid, auth_token,] app_sid, callback)

Loads an Application instance and returns it to the callback. callback is of the form: callback(err, twapp) where twapp is the loaded twilio.Application instance

A valid application must have a VoiceUrl, VoiceMethod, StatusCallback, StatusCallbackMethod, SmsUrl, SmsMethod, and SmsStatusCallback. Fallback URLs are ignored at this time.

twilio.Application

twapp.makeCall(from, to, options[, onConnectCallback])

from - The phone number or client identifier to use as the caller id. If using a phone number, it must be a Twilio number or a Verified outgoing caller id for your account to - The phone number or client identifier to call. options - An object containing any additional options - sendDigits - A string of keys to dial after connecting to the number. Valid digits in the string include: any digit (0-9), '#', '*' and 'w' (to insert a half second pause). - ifMachine - Tell Twilio to try and determine if a machine (like voicemail) or a human has answered the call. Possible values are 'Continue', 'Hangup', and null (the default). - timeout - The integer number of seconds that Twilio should allow the phone to ring before assuming there is no answer. Default is 60 seconds, the maximum is 999 seconds.

Phone numbers should be formatted with a '+' and country code e.g., +16175551212 (E.164 format).

voiceRequest Event

Triggered when Twilio contacts this server and requests a TwiML response. This event will be triggered for incoming and outgoing calls.

outgoingCall Event

Triggered when Twilio connects an outgoing call placed with makeCall. You typically do not need to listen for this event; Instead, pass a onConnectCallback to the makeCall function.

incomingCall Event

Triggered when the Twilio

twapp.middleware()

Returns Connect/Express middleware that handles any request to VoiceURL, StatusCallback, SmsUrl, or SmsStatusCallback using the appropriate GET/POST methods for each.

Disclaimer

Blake Miner is not affliated with Twilio, Inc. in any way. Use this software AT YOUR OWN RISK. See LICENSE for more details.