Im trying to build what seemed like a simple SMS messaging application using Twilio's api and running into a few strange momments.
So I have an SMS object that stores the messages and i wrote a simple trigger on there to actually call the code that sends the message.
Which works for one offs, but if i try to create a bunch of sms messages all at once i get an error saying i cant do more then 10 @future calls at once, and sadly because of the way twilio works each sms message has to be its own callout.
So i assume the answer is to batch the @future calls? but is there a way to have a trigger start a batch job??
Best Answer
Yes, you can start a batch from a trigger, but I would advise against it. From the documentation:
A better solution would be to have a status on the SMS object and then have a scheduled job that then executes a batch for you.