Twilio.sendMessage()

Send a message using the Twilio API

Usage

Hover over inputs/exits for more info.

var Twilio = require('machinepack-twilio');


// Send a message using the Twilio API

Twilio.sendMessage({

accountSid: 'DZe5eafd3c69b1e74example5852c04a9102',

authToken: 'Dafd4example5852c3c69bZe5e1e704a9102',

to: '+16155556789',

body: 'Example message',

mediaUrl: 'http://imgur.com/somePic.jpg',

from: '+16155551234',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// No sender ("From") phone numbers are available to your Twilio account.

noPhoneNumbersAvailable: function () {

 

},

// Either a "body" or "mediaUrl" (or both) must be specified

noBodyOrMediaSpecified: function () {

 

},

// OK.

success: function () {

 

},

});

Inputs

accountSid required

The "account sid" associated with your Twilio account.

'DZe5eafd3c69b1e74example5852c04a9102'
authToken required

The "auth token" associated with your Twilio account.

'Dafd4example5852c3c69bZe5e1e704a9102'
to required

This is the 'To' phone number the message is sending to.

'+16155556789'
body

This is the body of the message being sent

'Example message'
mediaUrl

This is the URL of an image to send

'http://imgur.com/somePic.jpg'
from

This is the 'From' phone number you'd like to use to send the SMS.

'+16155551234'

Exits

error

An unexpected error occurred.

N/A

noPhoneNumbersAvailable

No sender ("From") phone numbers are available to your Twilio account.

noBodyOrMediaSpecified

Either a "body" or "mediaUrl" (or both) must be specified

success

OK.

N/A