Node.js Helper
The Plivo Node.js helper simplifies the process of making Plivo API calls and generating Plivo XML. Please note that this is the legacy
version.
If you are looking for the latest
version, you can get it here.
Prerequisites
Installation
Quick Installation
Run the following command for a quick installation of the helper.
$ npm install plivo
Manual Installation
Install the helper manually from Github.
$ cd ~/.node_libraries # or the directory where node modules are stored in your OS.
$ git clone git://github.com/plivo/plivo-node.git plivo-node
Using the library
Initializing the RestAPI client
You can use RestAPI
to initialize a REST client that can make API requests to Plivo.
1
2
3
4
5
6
var plivo = require('plivo');
var p = plivo.RestAPI({
authId: 'Your AUTH_ID',
authToken: 'Your AUTH_TOKEN'
});
Send an SMS
The snippet below shows how you can send an SMS.
1
2
3
4
5
6
7
8
9
10
var params = {
'src': '1111111111',
'dst' : '2222222222',
'text' : "Hello, how are you?"
};
p.send_message(params, function (status, response) {
console.log('Status: ', status);
console.log('API Response:\n', response);
});
Check out Message API documentation for more details.
Make an Outbound Phone Call
You can make outbound phone calls to landlines, mobiles, and SIP endpoints (e.g., softphones), in any of our 200+ coverage countries
1
2
3
4
5
6
7
8
9
10
11
var params = {
'to': '2222222222',
'from' : '1111111111',
'answer_url' : "https://s3.amazonaws.com/static.plivo.com/answer.xml",
'answer_method' : "GET"
};
p.make_call(params, function (status, response) {
console.log('Status: ', status);
console.log('API Response:\n', response);
});
Check out Call API documentation for more details.
Examples
Take a look at the Node examples on GitHub.
Reporting Issues
Please report issues or submit patches using the Github Issue Tracker or Customer Support.
License
The Plivo Node Helper Library is written by the Plivo Team and is distributed under the MIT License.