exotel
v1.0.1
Published
Exotel API helper
Downloads
16
Readme
Exotel API helper for node
Currently supports:
- Sending SMS
- Checking SMS status
More features are coming in. Contributions welcome.
Installation
npm install exotel
Usage
var exotel = require('exotel')({
id : // exotel id,
token: // exotel token
});
exotel.sendSMS('9999999999', 'Hi', function (err, res) {
// ...
});
Documentation
###sendSMS(mobile, msg, [statusCallback], callback) Sends an SMS
####Arguments
mobile
(String): 10-digit mobile numbermsg
(String): Message body[statusCallback]
(String): An optional URL to call when the message reaches a terminal state (delivered or failed)callback
(Function): Called ascallback(err, result)
- whereresult
is a JSON version of the Exotel xml response:
{
Sid : '<sms_id>',
DateUpdated: '2014-07-30 09:44:56',
DateCreated: '2014-07-30 09:44:56',
DateSent : '1970-01-01 05:30:00',
AccountSid : '<account_id>',
To : '<recipient_mobile>',
From : '/<account_id>',
Body : 'Hi!',
BodyIndex : '',
Status : '<status>', // "queued", "sending", "sent" .. etc.
Direction : 'outbound-api',
Price : '',
ApiVersion : '',
Uri : '/v1/Accounts/<account_id>/Sms/Messages/<sms_id>'
}
###checkSMS(sid, callback) Check SMS status
####Arguments
sid
(String): Sid insendSMS
resultcallback
(Function): Called ascallback(err, result)
- whereresult
is the same SMS data as above
Testing
Install dev dependencies and run:
EXOTEL_ID=<id> EXOTEL_TOKEN=<token> MOBILE=<recipient> npm test