Skip to main content

Day Night

Posted by brian on Fri, 08/12/2011

Hi,

ST 6.1.1.11 AST 1.6.2.14

I've searched and can't find the solution.

We have setup schedules for a customer for their main inbound numbers and this is fine.

They also want to be able to manually force 'night' mode. I can see I can check for variable in script.

Is this checking for -1 true and 0 false?

Also how would I create a feature code to set a variable to true and false?

I did search through forums and couldn't see any definitive answer.

Apologies if this is answered already.

Regards
Brian


Submitted by eeman on Fri, 08/12/2011 Permalink

use 'operator managed routes' instead of 'scheduled routes'

theres a script in feature codes called set-daynight to set your various modes

Submitted by brian on Sat, 08/13/2011 Permalink

Hi Erik,

Apologies, I didn't explain myself very well, was onsite.

They want to use schedules so I need to use scheduled based routing

I have setup a new variable FORCE_CLOSED

I've created a new script to set this variable.


exten => s,1,Answer
exten => s,n(begin),Playback(tl/welcome-mode-menu)
exten => s,n,Playback(tl/after-tone-choose)
exten => s,n,Playback(tl/to-set)
exten => s,n,Playback(tl/night-mode)
exten => s,n,Playback(press-1)
exten => s,n,Playback(tl/to-set)
exten => s,n,Playback(tl/day-mode)
exten => s,n,Playback(press-2)
exten => s,n,Read(MODE,beep,1,,,7)
exten => s,n,GotoIf($["${MODE}" != ""]?${MODE},1)
exten => s,n,Goto(s,begin)

exten => 1,1,Set(DB(TL/TENANT/${tenant}/FORCE_CLOSED)=1)
exten => 1,n,Playback(system)
exten => 1,n,Playback(has-been-set-to)
exten => 1,n,Playback(tl/night-mode)
exten => 1,n,Wait(1)
exten => 1,n,Playback(goodbye)
exten => 1,n,Hangup

exten => 2,1,Set(DB(TL/TENANT/${tenant}/FORCE_CLOSED)=)
exten => 2,n,Playback(system)
exten => 2,n,Playback(has-been-set-to)
exten => 2,n,Playback(tl/day-mode)
exten => 2,n,Wait(1)
exten => 2,n,Playback(goodbye)
exten => 2,n,Hangup

exten => _X,1,Playback(invalid)
exten => _X,n,Goto(s,begin)

The variable is set:

asterisk -rx "database show"

/TL/TENANT//FORCE_CLOSED : 1

In my inbound route I am going to an IVR Except when this variable is set FORCE_CLOSED but it seems to ignore the variable..

Should I be setting it to something other than 1 ?

Thanks
Brian.

Submitted by brian on Mon, 08/15/2011 Permalink

Hi Erik,

I have setup the route to only do the first step unless the variable is set.

It's set to 1

asterisk -rx "database show" |grep FORCE
/TL/TENANT//FORCE_CLOSED : 1

It still does the first step ignoring the check for the variable.

This is my inbound.include


exten => 12345678,1,Set(DIALED_PUBLIC_NUMBER=${EXTEN})
exten => 12345678,2,Set(DIALED_NUMBER=${EXTEN})
exten => 12345678,3,GotoIf($["${FORCE_CLOSED}" != ""]?7)
exten => 12345678,4,GotoIfTime(9:00-13:00,mon-fri,*,*?from-outside-12345678-OfficeOpen,${EXTEN},1)
exten => 12345678,5,GotoIfTime(14:00-17:30,mon-thu,*,*?from-outside-12345678-OfficeOpen,${EXTEN},1)
exten => 12345678,6,GotoIfTime(14:00-17:00,fri,*,*?from-outside-12345678-OfficeOpen,${EXTEN},1)
exten => 12345678,7,NoOp(${EXTEN})
exten => 12345678,8,GotoIfTime(*,*,*,*?from-outside-12345678-tl-allhours,${EXTEN},1)

What am I missing?

Thanks
Brian

Submitted by brian on Thu, 08/18/2011 Permalink

Hi Erik,

Apologies to bump, am I missing something glaringly obvious or is this a bug in either Asterisk or TL?

I am hoping to implement this for another couple of customers and I have a sale going through for another TL ST and this is a dealbreaker so I need to know if it will work or not.

Thanks.

Regards
Brian

Submitted by eeman on Fri, 08/19/2011 Permalink

your not setting the variables correctly..

the value of FORCE_CLOSE needs to ether be

FORCE_CLOSE=

or

FORCE_CLOSE=1

if FORCE_CLOSE is anything but an empty variable.. it skips that step in the dialplan.

Submitted by brian on Fri, 08/19/2011 Permalink

HI Erik,

The variable is set:

asterisk -rx "database show"
/TL/TENANT//FORCE_CLOSED : 1

In my inbound route I am going to an IVR Except when this variable is set FORCE_CLOSED but it seems to ignore the variable.

What could I be missing?.

Thanks
Brian

Submitted by eeman on Sat, 08/20/2011 Permalink

its not a database key.. its a global variable. Your script needs to set a global variable (which btw, does not remain during a reload)

go into Global Variables and add a variable called FORCE_CLOSED and set it to 1

Submitted by brian on Sat, 08/20/2011 Permalink

Thanks Erik,

So now I'm setting global variable FORCE_CLOSED to 1 and checking it in the inbound route.

It still ignores it...

When I set it in my script I see this in the console:

== Setting global variable 'FORCE_CLOSED' to '1'

All good.

I try the inbound route and it still goes to the script even though I have 'except when this variable is set' FORCE_CLOSED.

I've even set it to 1 in the pbx settings and it still ignores it.

What else can I check?

Thanks
Brian

Submitted by eeman on Sat, 08/20/2011 Permalink

paste the dialplan from inbound.include, inbound_actions.include

also show the applicable CLI output when you call and it checks the gotoIF statement.

Submitted by brian on Sat, 08/20/2011 Permalink

Hi Erik,

See attached.

Doesn't seem to check it at all.

I'm using STE 6.1.1.11 and Asterisk 1.6.2.14

inbound.include

exten => 12345678,1,Set(DIALED_PUBLIC_NUMBER=${EXTEN})
exten => 12345678,2,Set(DIALED_NUMBER=${EXTEN})
exten => 12345678,3,GotoIf($["${FORCE_CLOSED}" != ""]?7)
exten => 12345678,4,GotoIfTime(9:00-13:00,mon-fri,*,*?from-outside-12345678-OfficeOpen,${EXTEN},1)
exten => 12345678,5,GotoIfTime(14:00-17:30,mon-thu,*,*?from-outside-12345678-OfficeOpen,${EXTEN},1)
exten => 12345678,6,GotoIfTime(14:00-17:00,fri,*,*?from-outside-12345678-OfficeOpen,${EXTEN},1)
exten => 12345678,7,NoOp(${EXTEN})
exten => 12345678,8,GotoIf($["${FORCE_CLOSED}" != ""]?10)
exten => 12345678,9,GotoIfTime(*,*,*,*?from-outside-12345678-tl-allhours,${EXTEN},1)
exten => 12345678,10,NoOp(${EXTEN})
exten => 12345678,11,GotoIfTime(*,*,*,*?from-outside-12345678-tl-allhours,${EXTEN},1)

inbound_actions.include

[from-outside-12345678-OfficeOpen]
exten => 12345678,1,Set(MOH=${DB(TL/MOH/default${TL_DASH}${tenant})})
exten => 12345678,n,GotoIf($["${MOH}" = ""]?nomoh)
exten => 12345678,n,Set(CHANNEL(musicclass)=${MOH})
exten => 12345678,n(nomoh),Macro(tl-menu,CityIVR,)
[from-outside-12345678-tl-allhours]
exten => 12345678,1,Set(MOH=${DB(TL/MOH/default${TL_DASH}${tenant})})
exten => 12345678,n,GotoIf($["${MOH}" = ""]?nomoh)
exten => 12345678,n,Set(CHANNEL(musicclass)=${MOH})
exten => 12345678,n(nomoh),Macro(tl-menu,CityAfterhours,)
[from-outside-12345678-tl-allhours]
exten => 12345678,1,Set(MOH=${DB(TL/MOH/default${TL_DASH}${tenant})})
exten => 12345678,n,GotoIf($["${MOH}" = ""]?nomoh)
exten => 12345678,n,Set(CHANNEL(musicclass)=${MOH})
exten => 12345678,n(nomoh),Macro(tl-goto-userextension,200,)

Setting Variable from Dial Plan

-- User entered '1'
-- Executing [s@macro-tl-set-force-closed:11] GotoIf("SIP/200-00000807", "1?1,1") in new stack
-- Goto (macro-tl-set-force-closed,1,1)
-- Executing [1@macro-tl-set-force-closed:1] Set("SIP/200-00000807", "GLOBAL(FORCE_CLOSED)=1") in new stack
== Setting global variable 'FORCE_CLOSED' to '1'

CLI when calling in:

== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
== Using SIP VRTP TOS bits 136
== Using SIP VRTP CoS mark 4
== Using UDPTL TOS bits 184
== Using UDPTL CoS mark 5
-- Executing [12345678@from-outside:1] Wait("SIP/SIP_PROVIDER-00000809", "1") in new stack
-- Executing [12345678@from-outside:2] Set("SIP/SIP_PROVIDER-00000809", "__INCOMINGCLI=987654321") in new stack
-- Executing [12345678@from-outside:3] Goto("SIP/SIP_PROVIDER-00000809", "from-outside-redir,12345678,1") in new stack
-- Goto (from-outside-redir,12345678,1)
-- Executing [12345678@from-outside-redir:1] Set("SIP/SIP_PROVIDER-00000809", "DIALED_PUBLIC_NUMBER=12345678") in new stack
-- Executing [12345678@from-outside-redir:2] Set("SIP/SIP_PROVIDER-00000809", "DIALED_NUMBER=12345678") in new stack
-- Executing [12345678@from-outside-redir:3] GotoIf("SIP/SIP_PROVIDER-00000809", "1?7") in new stack
-- Goto (from-outside-redir,12345678,7)
-- Executing [12345678@from-outside-redir:7] NoOp("SIP/SIP_PROVIDER-00000809", "12345678") in new stack
-- Executing [12345678@from-outside-redir:8] GotoIf("SIP/SIP_PROVIDER-00000809", "1?10") in new stack
-- Goto (from-outside-redir,12345678,10)
-- Executing [12345678@from-outside-redir:10] NoOp("SIP/SIP_PROVIDER-00000809", "12345678") in new stack
-- Executing [12345678@from-outside-redir:11] GotoIfTime("SIP/SIP_PROVIDER-00000809", "*,*,*,*?from-outside-12345678-tl-allhours,12345678,1") in new stack
-- Goto (from-outside-12345678-tl-allhours,12345678,1)
-- Executing [12345678@from-outside-12345678-tl-allhours:1] Set("SIP/SIP_PROVIDER-00000809", "MOH=default") in new stack
-- Executing [12345678@from-outside-12345678-tl-allhours:2] GotoIf("SIP/SIP_PROVIDER-00000809", "0?nomoh") in new stack
-- Executing [12345678@from-outside-12345678-tl-allhours:3] Set("SIP/SIP_PROVIDER-00000809", "CHANNEL(musicclass)=default") in new stack
-- Executing [12345678@from-outside-12345678-tl-allhours:4] Macro("SIP/SIP_PROVIDER-00000809", "tl-menu,CityAfterhours,") in new stack
-- Executing [s@macro-tl-menu:1] Set("SIP/SIP_PROVIDER-00000809", "CALLERID(name)=987654321") in new stack
-- Executing [s@macro-tl-menu:2] Goto("SIP/SIP_PROVIDER-00000809", "CityAfterhours,s,1") in new stack
-- Goto (CityAfterhours,s,1)
== Channel 'SIP/SIP_PROVIDER-00000809' jumping out of macro 'tl-menu'
-- Executing [s@CityAfterhours:1] GotoIf("SIP/SIP_PROVIDER-00000809", "0?start") in new stack
-- Executing [s@CityAfterhours:2] Set("SIP/SIP_PROVIDER-00000809", "TL_LEVEL=1") in new stack
-- Executing [s@CityAfterhours:3] Answer("SIP/SIP_PROVIDER-00000809", "") in new stack
-- Executing [s@CityAfterhours:4] NoOp("SIP/SIP_PROVIDER-00000809", "") in new stack
-- Executing [s@CityAfterhours:5] Set("SIP/SIP_PROVIDER-00000809", "TIMEOUT(digit)=2") in new stack
-- Digit timeout set to 2.000
-- Executing [s@CityAfterhours:6] Set("SIP/SIP_PROVIDER-00000809", "TIMEOUT(response)=4") in new stack
-- Response timeout set to 4.000
-- Executing [s@CityAfterhours:7] BackGround("SIP/SIP_PROVIDER-00000809", "ogm/City_AFTERHOURS") in new stack
-- Playing 'ogm/City_AFTERHOURS.slin' (language 'en')

Thanks for your help.

Brian

Submitted by eeman on Sat, 08/20/2011 Permalink

its working... look here..

exten => 12345678,3,GotoIf($["${FORCE_CLOSED}" != ""]?7)

the execution of it:
Executing [12345678@from-outside-redir:3] GotoIf("SIP/SIP_PROVIDER-00000809", "1?7") in new stack

see how its showing 1?7 .. the 1 means match true, and the 7 is the line its jumping to..

continuing..
exten => 12345678,7,NoOp(${EXTEN})
exten => 12345678,8,GotoIf($["${FORCE_CLOSED}" != ""]?10)

the execution of it...
-- Goto (from-outside-redir,12345678,7)
-- Executing [12345678@from-outside-redir:7] NoOp("SIP/SIP_PROVIDER-00000809", "12345678") in new stack
-- Executing [12345678@from-outside-redir:8] GotoIf("SIP/SIP_PROVIDER-00000809", "1?10") in new stack

again it matches true and jumps to line 10

continuing..
exten => 12345678,10,NoOp(${EXTEN})
exten => 12345678,11,GotoIfTime(*,*,*,*?from-outside-12345678-tl-allhours,${EXTEN},1)

the execution of that:
-- Goto (from-outside-redir,12345678,10)
-- Executing [12345678@from-outside-redir:10] NoOp("SIP/SIP_PROVIDER-00000809", "12345678") in new stack
-- Executing [12345678@from-outside-redir:11] GotoIfTime("SIP/SIP_PROVIDER-00000809", "*,*,*,*?from-outside-12345678-tl-allhours,12345678,1") in new stack
-- Goto (from-outside-12345678-tl-allhours,12345678,1)

as you can see it jumped to your catch-all all-hours script that sends it to the all-hours script you programed..

-- Goto (from-outside-12345678-tl-allhours,12345678,1)
-- Executing [12345678@from-outside-12345678-tl-allhours:1] Set("SIP/SIP_PROVIDER-00000809", "MOH=default") in new stack
-- Executing [12345678@from-outside-12345678-tl-allhours:2] GotoIf("SIP/SIP_PROVIDER-00000809", "0?nomoh") in new stack
-- Executing [12345678@from-outside-12345678-tl-allhours:3] Set("SIP/SIP_PROVIDER-00000809", "CHANNEL(musicclass)=default") in new stack
-- Executing [12345678@from-outside-12345678-tl-allhours:4] Macro("SIP/SIP_PROVIDER-00000809", "tl-menu,CityAfterhours,") in new stack

you sure you havent forgotten to reload? your pasted action script says goto extension 200 but the executed code is showing tl-menu for CityAfterhours which would only happen if that's what it loaded into memory..

however your schedule avoidance for setting a channel variable is definitely working.

Submitted by brian on Mon, 08/22/2011 Permalink

HI Erik,

It's working perfectly, thanks for all your help.

Would their be any downsides to checking for a DB key instead of a global variable?

If not I'll submit a feature request. I think it would make more sense particularly in an MTE enviroment where reloads would render this feature almost unusable.

Thanks again.

Brian

Submitted by eeman on Mon, 08/22/2011 Permalink

the reason the 'operator managed routes' exists was a result of my observation from this. The concern over backward compatibility with existing installations precluded changing the mechanics of the schedule based routes. the only combo I could imagine would be an operator managed route with its day/night/temp settings that runs a custom script that issues a Goto statement to another inbound DID running a schedule based route.