A lightweight scalable application framework for creating Plivo apps with NodeJS.
npm install plivode
var plivode = require('plivode'); new plivode.App({ appID: '[your Plivo app ID]', authID: '[your Plivo auth ID]', authToken: '[your Plivo auth token]', rootUrl: '[the root URL this app is accessible by Plivo]' }) .on('answer', function(params, response) { response .speak('Hello, world!') .send(); });
« Try Me: Send a sms to (949) 484-8425 |
var plivode = require('plivode'); new plivode.App({ ... }) .on('message', function(params, response) { // When a sms is received, make an call to the number that sent // the sms, passing the text of the sms to the "parrot" action. var callFrom = '[your Plivo phone number]', callTo = params.From, answerAction = ['parrot', params.Text]; this.Call.outbound(callFrom, callTo, answerAction); // Send a blank response back, so Plivo knows we processed // the message and not to resend it. response.send(); }) .on('parrot/:message', function(params, response) { // The user answered the return call, so speak the text // of the sms that they sent, and repeat it 3 times. response .speak(params.message, { loop: 3 }) .send(); });