4

I just signed up for a Twilio trial account. I'm not seeing any feature speaking to how I can create and save multiple SMS messages for later and schedule when to send them to a group. Is this possible? Or is there a better software for this?

linkgtaylor
  • 123
  • 2
  • 8
  • 1
    Twilio evangelist here. There is nothing built in to the Twilio platform that lets you schedule SMS's. How you can do this yourself really depends on of you want something packaged or you want to build it yourself, what OS and programming stack you want to use, etc. – Devin Rader Feb 10 '15 at 16:49

2 Answers2

2

Twilio evangelist here.

Looking at your profile, seems your preferred language is PHP, so what I would suggest is using one of the many PHP libraries for cron tasks such as PHPCron, PHPJobScheduler or with the Piwik Platform.

With Piwik you could do something like:

class Tasks extends \Piwik\Plugin\Tasks
{
    public function schedule()
    {
        $this->daily('myTask');   // method will be executed once every day
    }

    public function myTask()
    {
        You SMS messages to be sent here
    }
}

With this, you can schedule as many tasks as you'd like, and have the SMS's sent at the time you want them to be sent.

There are going to be task schedulers to pretty much every single platform, and you could even do those via cron tasks.

Marcos Placona
  • 21,468
  • 11
  • 68
  • 93
  • Thanks Marcos. I may have to modify PHP Jobscheduler to do the job. Only that it will take longer and wouldn't be as robust. – linkgtaylor Feb 18 '15 at 01:38
  • Is there now an easy way to do this with Python? I need to send SMS notifications a few times a day to my customers and I have the corresponding times, phone numbers and more stored in a csv. Alternatively, is there another bulk SMS service, besides twilio, that offers scheduled send times? Thanks for advice! – NeStack Aug 13 '20 at 14:32
0

I'm a little late to this question, but I'd like to suggest to anyone that arrives here now: check out the at command. From PHP, your server can execute command line calls to at and schedule tasks with absolute or relative temporal specificity.

Relative MWE:

shell_exec('echo "php /path/to/my/twilio_script.php" | at now + 10 minutes');

Absolute MWE:

shell_exec('echo "php /path/to/my/twilio_script.php" | at 3:35 PM 10/29/2019');

You have to mind permissions (check your etc/at.deny and that your server has permissions to execute your script), and the quotations if your script has any command line arguments. But it avoids the creation of a bunch of Cron jobs.

You could also create files to execute (scroll down a couple of answers) with at - these could be individual messages to send using twilio. It's not my favorite approach, but I suppose there are situations that it would be better-suited over the other approach. But I'd recommend a Cron cleanup script to remove all of the one-time use files.

Tee
  • 126
  • 6