Communication API for SMS
This is an ipm package, which contains one or more reusable assets within the ipm Community. The 'package.json' in this repo is a ipm spec's package.json, here, which is a superset of npm's package.json spec, here.
- Create an account on https://twilio.com
- Obtain your Username, Password, and Origin Number
- Configure your constants in the TwilioConstants library.
- Test using the example service TwilioExampleSendSMS.
This library gives user the ability to send sms using the Twilio API.
-
TwilioSMSLib
- Library for sending SMS Messages. It can be accessed using the Twilio object. -
TwilioConstants
- A constants library to have a centralized location for constants like API-key.
TwilioExampleSendSMS
- An example service showing how to use the twilio library to send SMS.
TwilioTestSetup
- Tests if the constants for this package are set or not.
- callback :
function
This callback is displayed as part of this Library.
- Twilio :
Object
Sends a text message using Twilio's REST API.
This callback is displayed as part of this Library.
Kind: global typedef
Param | Type |
---|---|
err | Object |
resp | Object |
Sends a text message using Twilio's REST API.
Kind: global typedef
Param | Type | Description |
---|---|---|
user | string |
Twilio API account ex. "BC218b72987d86855a5adb921370115a20" |
pass | string |
Twilio API passcode ex. "4579ac6ba4fae7b452c03c64aeae40e7" |
sourceNumber | string |
Origin phone number of text message, ex "(+1 512-713-2783)" |
Example
var twconf = TWILIO_CONFIG;
var twilio = Twilio(twconf.USER, twconf.PASS, twconf.SOURCE_NUMBER);
Send SMS message
Kind: static method of Twilio
Param | Type | Description |
---|---|---|
text | string |
text body |
recipientNumber | string |
Formatted phone number ex. "(+1 339-987-2816)" |
callback | callback |
ex. function(err, data){} |
Example
var twconf = TWILIO_CONFIG;
var twilio = Twilio(twconf.USER, twconf.PASS, twconf.SOURCE_NUMBER);
twilio.sendSMS(text, recipientNumber, function(err, data){
if(err){
resp.error(err);
}
resp.success(data);
});