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

@avaya/cpaas

v0.9.1

Published

Node.js helper library for Avaya CPaaS

Downloads

38

Readme

@avaya/cpaas

This Node.js library is an open source tool built to simplify interaction with the Avaya CPaaS telephony platform. Avaya CPaaS makes adding voice and SMS to applications fun and easy.

For more information about Avaya CPaaS, please visit: Avaya OneCloud™️ CPaaS

To read the official documentation visit Avaya CPaaS Docs


Installation

$ npm install @avaya/cpaas

Usage

REST

See the Avaya CPaaS REST API documentation for more information.

Send SMS Example

var cpaas = require('@avaya/cpaas');
var enums = cpaas.enums;

var connector = new cpaas.SmsConnector({
    accountSid: '{AccountSid}',
    authToken: '{AuthToken}'
});

//send sms message
connector.sendSmsMessage({
    to: '+123456',
    from: '+654321',
    body: 'Hello from Avaya CPaaS!',
    statusCallback: 'http://mycallback.url.com',
    statusCallbackMethod: enums.HttpMethod.GET,
    allowMultiple: true
}).then(function (data) {
    console.log(data);
});

Configuration

First a configuration must be defined by specifying your Avaya CPaaS credentials. This configuration is passed to cpaas.Connectors from which you can then access all of the specific connectors:

var cpaas = require('@avaya/cpaas');
var connectors = new cpaas.Connectors({
    accountSid: '{AccountSid}',
    authToken: '{AuthToken}'
});
var smsConnector = connectors.sms;
var conferencesConnector = connectors.conferences;

Alternatively you can instantiate a single connector directly like this:

var cpaas = require('@avaya/cpaas');
var callsConnector = new cpaas.CallsConnector({
    accountSid: '{AccountSid}',
    authToken: '{AuthToken}'
});

All of the REST API requests are implemented as promises:

callsConnector.makeCall({
    /* makeCall parameters */
}).then(function(result) { 
    /* do something with result */
}).catch(function(err){
    /* handle errors */
});

Request parameters

Request parameters are passed as parameters to connector object methods as shown previously. All of the connector methods have an optional parameter called accountSid which you can specify per request. If not specified, the accountSid defined in the configuration is used automatically.

var cpaas = require('@avaya/cpaas');
var usagesConnector = new cpaas.UsagesConnector({
    accountSid: '{AccountSid}',
    authToken: '{AuthToken}'
});
//explicit accountSid
var usage = usagesConnector.viewUsage({
    accountSid: '{ExplicitAccountSid}',
    usageSid: '{UsageSid}'
});

//accountSid from configuration used automatically
var usage = usagesConnector.viewUsage({
    usageSid: '{UsageSid}'
});

Response data

Visit the Avaya CPaaS Docs page for more information about the returned data.

InboundXML

InboundXML is an XML dialect which enables you to control phone call flow. For more information please visit the Avaya CPaaS InboundXML documentation.

This library helps you generate InboundXML with a set of functions located under cpaas.inboundXml. Valid InboundXML documents have only one <Response> element at the root level and the rest of the instructions are contained inside.

InboundXML is generated by calling cpaas.inboundXml.build(), which returns a promise, on an XML definition object creating by using the other methods. The generated XML is automatically checked against a schema. The schema checking will be done only if the libxml-xsd library is present (included as an optional dependency).

<Say> Example
var cpaas = require('@avaya/cpaas');
var ix = cpaas.inboundXml;
var enums = cpaas.enums;

var xmlDefinition = ix.response({content: [
    ix.say({
        language: enums.Language.EN,
        loop: 3,
        text: 'Welcome to Avaya CPaaS!',
        voice: enums.Voice.FEMALE
    })
]});

ix.build(xmlDefinition).then(function(xml){
    console.log(xml);
}).catch(function(err){
    console.log('The generated XML is not valid!', err);
});

will render

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
    <Say loop="3" voice="female" language="en">Welcome to Avaya CPaaS!</Say>
</Response>