Twilio Transport
Send an SMS notification using the Twilio API
Setup
Note: You need a Twilio account to use this package
Add the package as a dependency of another package:
1api.use(['dispatch:emissary-transport-twilio'], 'server');
Or just use it in your root application:
$ meteor add dispatch:emissary-transport-twilio
Usage
Configuration/Working the Queue
1var transport = new TwilioTransport({ 2 sid:'<Twilio SID>', 3 from:'<Valid "From" number in your Twilio account>', 4 token:'<Twilio Auth Token>' 5}); 6 7transport.register();
The above will create a new Twilio transport and register it to work "sms"
messages in the Emissary job queue.
Setting up the Webhook
Twilio's API is asynchronous, so you don't know the status of the SMS right away. Instead, Twilio can hit a predefined URL via a webhook when the message status changes. This functionality is built into this package - all you have to do is turn on webhooks on a public-facing server after registering your transport:
1Emissary.enableWebhooks();
Queuing Messages
1Emissary.queueTask('sms', { 2 bodyTemplate:'<Handlebars template>', 3 templateData:{}, 4 transportConfig:{ 5 to:'+15555555555', 6 from:'<optionally specify a different number here than the one you initialized with>' 7 } 8})