0
votes

I am sending an sms message in an after save parse cloud code function. I would like to send an image along with it.

var twilio = require('twilio')("***************","*****************");

twilio.sendSms({
    to: "+1234567890",
    from: "+1234567890",
    body: url,
    mediaUrl: url
  }, function(err, responseData) {
    if (err) {
      console.log(err);
    } else {
      console.log(responseData.from);
      console.log(responseData.body);
    }
  }
);

I'm not getting any errors. Messages are delivered nicely, URL shows in body and is clickable (links to image), but the picture does NOT show up in the message.

  1. Yes, my account has MMS capabilities.
  2. No, those are not the actual numbers I have in my code.
  3. Yes, my to number is verified.
  4. Yes, I am able to receive MMS with picture when using twilio's API Explorer interface.

Any help is greatly appreciated. Thanks!

UPDATE

twilio.sendMessage({
  to: "+12672574729",
  from: "+12013807380",
  body: url,
  mediaUrl: url
}, function(err, responseData) {
    if (err) {
      console.log(err);
    } else {
      console.log(responseData.from);
      console.log(responseData.body);
    }
  }
);

With the above change, I'm getting this error:

Input: {"object":{"Picture":{"__type":"File","name":"tfss-36cd9d55-e561-45ec-b65b-a04f872cb37d-alarm_9132015_00_sm.jpg","url":"http://files.parsetfss.com/104aa614-342a-4c1e-8c67-b7718c3e6325/tfss-36cd9d55-e561-45ec-b65b-a04f872cb37d-alarm_9132015_00_sm.jpg"},"createdAt":"2015-09-23T00:26:05.333Z","objectId":"vYeP2YYVEg","updatedAt":"2015-09-23T00:26:05.333Z"}}
Result: TypeError: Object [object Object] has no method 'sendMessage'
1
twilio.sendMessage doesn't allow for mediaUrl, only SMSAlexKoren

1 Answers

0
votes

Twilio developer evangelist here.

The sendSms function uses a deprecated endpoint that does not support media messages.

The good news is that you can use the sendMessage function instead. It takes the same object as an argument and will send the media as well.