GotoIfTime Dialplan Issue

I have two problems working with GotoIfTime and dial plans not working as I would expect.

Firstly I have created a context called [test-context]. I have placed an extension in that context.

At the top of that context I have a include statement which calls a outbound route, as defined in the freepbx gui. The gui outbound route calls one of my trunks after asking the user for a pin number.

The first problem: If I comment out the GotoIfTime line in the test-context, it seems to work just fine. When a user calls outbound, the script calls the GUI based outbound route and asks the user for a PIN number, All good!.. But if I have the GotoIfTime included as below, even if outside of the time specified it no longer will call the include statement? Why is this?

Second Problem: When the GotoIfTime is activated, it jumps to the new context [in-hours] and then ONLY executes the single line listed in the last parameter of the GotoIfTime statement. So in this case it says “sorry” then returns to the calling context and continues on from the the next statement. What I want it to do is to jump to the [in-hours] context if the GotoIfTime is active and execute all commands in the [in-hours] context?

include => outrt-009-Test_context

exten => _X.,1,answer()
exten => _X.,2,GotoIfTime(09:00-12:00|mon-fri||?in-hours,${EXTEN},1)
exten => _X.,3,playback,yes-dear
exten => _X.,4,hangup()

exten => _07.,1,Dial(IAX2/079294000@079294000/${EXTEN},20)
exten => _09.,2,Dial(IAX2/09742351@079742351/${EXTEN},20)
exten => _X.,3,Dial(IAX2/079292200@079292200/${EXTEN},20)
exten => _X.,4,hangup()

Any help would be Fantastic as I’m a bit of a newbee with custom contexts.


Alan Scott

Use the same extension pattern for all lines in in_hours.

Only extensions beginning 07 will match the first line, and be actioned, but extensions matching 07 will not match the second line, so processing in that context will terminate.

So are you saying that if no match is found in line 1, the context will be exited?

Why would the context not be exected line by line until a match is found?

Alan Scott


No you context needs to look like this

exten => _07.,1,Dial(IAX2/079294000@079294000/${EXTEN},20)
exten => _07,2,hangup()
exten => _09.,1,Dial(IAX2/09742351@079742351/${EXTEN},20)
exten => _09,2,hangup()
exten => _X.,1,Dial(IAX2/079292200@079292200/${EXTEN},20)
exten => _X.,2,hangup()