Crmgo Blog

Asterisk GotoIfTime()

Asterisk GotoIfTime()

Description: GotoIfTime(<times>|<weekdays>|<mdays>|<months>?[context|]extension|]pri) If the current time matches the specified time interval, then the call is transferred to the specified extension. Each element for time specification can be set as the '*' character (always matches) or as an interval. If the current time does not match the specified…

Asterisk GotoIfTime()

Description:

GotoIfTime(<times>|<weekdays>|<mdays>|<months>?[context|]extension|]pri)

If the current time matches the specified time interval, the dialplan jumps to the specified extension. Each element for time specification can be set as the '*' character (always matches) or as an interval. If the current time does not match the specified time interval, the command with the next priority will be executed.

How to specify time

Consider the example described in the extensions.conf file:

<time range>|<days of week>|<days of month>|<months>

If you replace any option with the '*' character, it will be ignored during comparison.
For example:

exten => 3000,1,GotoIfTime(9:00-17:00|mon-fri|*|*?open,s,1)

The dialplan will jump to the "open" context, to extension s, to the command with priority 1, if the current time is between 9:00 and 17:00, from Monday to Friday, while the month and day of the month are not checked.

Another example:
exten => s,6,GotoIfTime(*|*|1-3|May?attendant,s,30)

The dialplan will jump to the "attendant" context, to extension s, to the command with priority 30, at any time of day from May 1st to May 3rd. (For example, when the office is closed for the May holidays.)

Note: This post may be AI-assisted and then human-edited. Editorial responsibility: Dmytro Lomaka, Kaltenkirchen.