Let me start by saying that I'm new to Meteor and Twilio, so it's likely that I've overlooked something simple.
I'm utilizing the Twilio API bindings from this source in an attempt to send an SMS message within a Meteor.methods function. Here's the code snippet I'm working with:
if (Meteor.isClient) {
Template.twilioPlayground.events({
"click button": function() {
Meteor.call("sendSMS");
}
});
}
Meteor.methods({
sendSMS: function () {
twilio = Twilio('my account sid here...', 'my auth token here...');
twilio.sendSms({
to:'+7199634882',
from: '+17194530451',
body: 'This is a test'
}, function(err, responseData) { //function executed upon response from Twilio
if (!err) {
console.log(responseData.from); // outputs "+14506667788"
console.log(responseData.body); // outputs "word to your mother."
}
});
}
});
When triggering the event, I encounter this error:
ReferenceError: Twilio is not defined...
I have added the mrt:moment and mrt:twilio-meteor packages to the project without any additional setup. Any assistance would be greatly appreciated.