I figured out a happy medium. Still doesn’t do exactly what I want, but it’s still not too bad. In my dialplan, I’m utilizing ExecIfTime. Here is an example in extensions.conf:
[from-siptrunk]
exten => inbound-calls,Verbose(1,Playing sound.)
same => n,Answer
same => n,ExecIfTime(20:00-23:59,sun,,?Playback(silence/1&please-try-call-later&silence/1))
same => n,ExecIfTime(0:00-23:59,mon-sat,,?Playback(silence/1&please-try-call-later&silence/1))
same => n,ExecIfTime(0:00-10:54,sun,,?Playback(silence/1&please-try-call-later&silence/1))
same => n,ExecIfTime(10:55-13:10,sun,,?MusicOnHold(ulawstream))
same => n,ExecIfTime(13:11-17:54,sun,,?Playback(silence/1&please-try-call-later&silence/1))
same => n,ExecIfTime(17:55-19:59,sun,,?MusicOnHold(ulawstream))
same => n,Hangup()
So what is going on here is that from 10:55 am to 1:10 pm & 5:55 pm to 7:59 pm MusicOnHold (the livestream) will play. All other times that someone calls in, they will hear the message please-try-call-later.gsm and Asterisk will then hang up. I figured out that between the brackets for Playback(), you choose a .gsm file (except you don’t put .gsm at the end) that is located in /var/lib/asterisk/sounds/en
. I plan to create my own gsm sound file and use that instead (ie, I will tell the caller when to call back).
So the only thing I would like to do is have Asterisk hang up when the time slot for ExecIfTime ends, but I haven’t figured that out yet. I tested it, and Asterisk says it hung up, but it didn’t (I’m still connected by phone).
Additionally, I had to set the proper time zone on my GCP compute instance. I did this by first choosing my appropriate time zone, and then (assuming something like America/New_York):
sudo timedatectl set-timezone America/New_York
And to check to make sure the time zone is correct:
timedatectl