1.2.4 • Published 10 years ago

shoutapi v1.2.4

Weekly downloads
4
License
MPL-2.0
Repository
github
Last release
10 years ago

shoutapi

Node.js module to interact with official Shoutpoint Api. This is a very early package and is under very active development. The Shoutpoint API is also very fresh and is likely going to change. Don't expect any of the methods or endpoints to be stable.

npm install shoutapi

Client

The shoutapi.client object contains methods for direct use with the Shoutpoint apis: Dials, LiveCalls, LiveIVRs, and PhoneNumbers. Currently, only parts of the PhoneNumbers, Dials, and LiveIVRs apis have been implemented..

var shoutapi = require('shoutapi');

var token = 'YOUR_SHOUTPOINT_API_KEY';

// Setup client
var client = shoutapi(token).client;

// Output available phone numbers.
client.numbers.available({search_by: 'area-code', search_on: '949'}, console.log);

client.numbers.list(api, callback)

List numbers attached to api.

ParamTypeDescription
apiStringAPI name. ex. Dials, LiveCalls, LiveIVRs, PhoneNumbers.
callbackFunctionCallback function will receive error, response.

client.numbers.available(opts, callback)

List numbers that are available for use.

ParamTypeDescription
optsObjectAcceptable options are search_by and search_on.
callbackFunctionCallback function will receive error, response.

client.numbers.assign(api, numbers, callback)

Assign a number to an inbound api.

ParamTypeDescription
apiStringAPI name. ex. Dials, LiveCalls, LiveIVRs, PhoneNumbers.
numbersString | ArrayA phone number presented as a string or an array of numbers presented as strings.
callbackFunctionCallback function will receive error, response.

client.numbers.park(numbers, callback)

Park unassigned numbers for later use.

ParamTypeDescription
numbersString | ArrayA phone number presented as a string or an array of numbers presented as strings.
callbackFunctionCallback function will receive error, response.

client.numbers.release(api, numbers, callback)

Release numbers from an inbound api.

ParamTypeDescription
apiStringAPI name. ex. Dials, LiveCalls, LiveIVRs, PhoneNumbers.
numbersString | ArrayA phone number presented as a string or an array of numbers presented as strings.
callbackFunctionCallback function will receive error, response.

client.dials.connect(body, callback)

Dial a phone number.

ParamTypeDescription
bodyObjectA JSON object of the following form found here.
callbackFunctionCallback function will receive error, response.

client.dials.sms(body, callback)

Send an sms message.

ParamTypeDescription
bodyObjectA JSON object of the following form found here.
callbackFunctionCallback function will receive error, response.

client.dials.ctt(body, callback)

Initiate a ClickToTalk Call.

ParamTypeDescription
bodyObjectA JSON object of the following form found here.
callbackFunctionCallback function will receive error, response.

client.ivrs.get(number, callback)

Get the callback configuration for a specific IVR number.

ParamTypeDescription
numberStringA phone number presented as a string.
callbackFunctionCallback function will receive error, response.

client.ivrs.list(callback)

Get the callback configuration for all configured numbers.

ParamTypeDescription
callbackFunctionCallback function will receive error, response.

client.ivrs.config(body, callback)

Configure any number of callbacks for inbound numbers.

ParamTypeDescription
bodyObjectA JSON object of the following form found here.
callbackFunctionCallback function will receive error, response.

client.ivrs.list(callback)

Remove all callback configurations for IVRs.

ParamTypeDescription
callbackFunctionCallback function will receive error, response.

Events

The shoutapi.server object is an event emitter that provides a restify-type route. This route accepts callback style messages and emits events for type, status, and regex entries for to_no, from_no, and app_id. Since many events can be emitted for the same message, care should be taken not to duplicate responses.

npm install shoutapi restify
var shout = require('shoutapi')('YOUR-SHOUTPOINT-API-KEY').server,
    restify = require('restify'),
    server = restify.createServer();

// Configure restify server and route
server.use(restify.bodyParser({ mapParams: false }));
server.post('/', shout.route);

// Create a listener for 'init_call' type.
shout.on('init_call', function (data) {
  console.log('A call has been initialized.', data.message);

  var actions = [
    {
      type: 'SAY',
      params: {
        text: 'You have reached your destination. Here is a text message.',
      }
    },
    {
      type: 'SMS',
      params: {
        no: data.message.from_no,
        caller_id_no: data.message.to_no,
        message: 'Wherein I send you a text message.'
      }
    },
    {
      type: 'HANGUP'
    }
  ];

  data.res.send({actions: actions});
  data.next();
});

server.listen(80, function() {
  console.log('%s listening at %s', server.name, server.url);
});

Not all features of the client or server have been implemented as this is a proof of concept.

1.2.4

10 years ago

1.2.3

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago