How to selectively block a call: Need AGI programming advice

I have written a handful of AGI Perl scripts, so I am familiar with the general procedure, but my current application is different.

My goal is to give my Asterisk users access to a POTS line in a foreign country, in which there is no flat rate. The closest rate available is unlimited number of calls and minutes after 7pm. or something. The gateway is an SPA-3102. My plan is to write an AGI script that catches all calls to that FXO extension, checks the time of the day and day of the week (maybe it is a non-weekend holiday so the call may go thu). If they are trying to call at an expensive time, a recording will tell them to call later and hang up. So far, I can program this, as it is just like the IVRs that I have written in the past.

I need help coding the event in which the call is allowed to continue. How do I program that part? How can I ‘exec()’ the remainder of the call?

TIA,

-Ramon F Herrera

I think you don’t need to write an AGI script to check the time, just check it with GotoIfTime (voip-info.org/wiki-Asterisk+cmd+GotoIfTime) and jump to the appropriate extension based on current day of week and time.

Regards.

Marco Bruni

[quote=“mbruni”]I think you don’t need to write an AGI script to check the time, just check it with GotoIfTime (voip-info.org/wiki-Asterisk+cmd+GotoIfTime) and jump to the appropriate extension based on current day of week and time.

Regards.

Marco Bruni[/quote]

Marco:

Actually, what I need is a fancier version of GotoIfTime, as the caller may be the person who is paying the phone line and should be allowed access any time. There is the issue of non-weekend holidays, which may fall in the cheap, unlimited rates.

You gave me a great idea, however: what I need to do is get a hold of the source code for GotoIfTime()!

Isn’t open source wonderful!

Thanks,

-Ramon