Call Forwarding [Day/Time Based & Dynamic State] CFWD Redirect
Call Forwarding [Day/Time Based & Dynamic State] CFWD Redirect
Call Forwarding
Hello guys,
How can I dial a number, and have something enabled, or a rule set to true?
Is there any way to store a value? I remember there being some sort of database or flat file system to save values.
Scenario:
Dial Plan - Hard Coded CFWD 20:00 to 08:00 to 12345
Dynamic - Dial Plan/DTMF, VSP #, CFWD On/Off to xxxxx
For example:
Dial a prefix, dial VSP index no., * on / # off, and key in destination xxxx, # to end, if * on.
* save value 1
# save value 0
For example: Dial 88* - 3 - * - 98984343 #
or another: Dial 88* - 11 - # (OFF, no more keys req'd)
Then need something at start of dial plan to check value, etc. Also need to check the registered account linked to the rule. So VSP index would link to something, somewhere. Or, hard-code the integers to specific VSP_X.
Database to hold values - i.e. account (1 or all), state (on/off), destination (xxxx), etc.
Really keen to know your thoughts and whether there is anything already built to handle this, without having to use a massive dial plan!
Thank you!
Hello guys,
How can I dial a number, and have something enabled, or a rule set to true?
Is there any way to store a value? I remember there being some sort of database or flat file system to save values.
Scenario:
Dial Plan - Hard Coded CFWD 20:00 to 08:00 to 12345
Dynamic - Dial Plan/DTMF, VSP #, CFWD On/Off to xxxxx
For example:
Dial a prefix, dial VSP index no., * on / # off, and key in destination xxxx, # to end, if * on.
* save value 1
# save value 0
For example: Dial 88* - 3 - * - 98984343 #
or another: Dial 88* - 11 - # (OFF, no more keys req'd)
Then need something at start of dial plan to check value, etc. Also need to check the registered account linked to the rule. So VSP index would link to something, somewhere. Or, hard-code the integers to specific VSP_X.
Database to hold values - i.e. account (1 or all), state (on/off), destination (xxxx), etc.
Really keen to know your thoughts and whether there is anything already built to handle this, without having to use a massive dial plan!
Thank you!
ISP: Southern Phone ADSL2+ $55 Bundle. 22.4/1.2Mbps, ∞GB Bundle [Telstra].
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
Re: Call Forwarding [Day/Time Based & Dynamic State] CFWD Redirect
The DBRead and DBWrite dialplan functions are what you are after http://www.sipsorcery.com/mainsite/Help ... s#Database.
Re: Call Forwarding [Day/Time Based & Dynamic State] CFWD Redirect
BRAIN-STORMING
Requirements:
- Store Timezone offset of SS to local time.
- Store CFWD on time
- Store CFWD off time
- Store SS account user name
- Store Destination SIP URI
- Store CFWD state (on/off)
- Code structure to check on inbound call, if CFWD on/off, and get CFWD'd destination SIP URI.
Requirements:
- Store Timezone offset of SS to local time.
- Store CFWD on time
- Store CFWD off time
- Store SS account user name
- Store Destination SIP URI
- Store CFWD state (on/off)
- Code structure to check on inbound call, if CFWD on/off, and get CFWD'd destination SIP URI.
Database Function UsageExamples:Code: Select all
sys.DBWrite(string key, string value) # Writes a keyed value to the database. string sys.DBRead(string key) # Reads a keyed value from the database. sys.DBDelete(string key) # Deletes a keyed value from the database. List<string> sys.DBGetKeys() # Retrieves a list of all the current user's keys.
Documentation: http://www.sipsorcery.com/mainsite/Help ... s#DatabaseCode: Select all
# Database read, write and delete Example. sys.DBWrite("myKey", "myValue") val = sys.DBRead("myKey") sys.DBDelete("myKey") # Get Keys Example. keys = sys.DBGetKeys() if keys != nil keys.each do |key| sys.Log("Database key #{key}") end end
ISP: Southern Phone ADSL2+ $55 Bundle. 22.4/1.2Mbps, ∞GB Bundle [Telstra].
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
Re: Call Forwarding [Day/Time Based & Dynamic State] CFWD Redirect
I've seen a lot of criticism of the DB functions, saying that the server is often rebooted or the services flushed.
Is there a more reliable method? I think it was in the topic re: seeing active stats, but when checking active stats on inbound call, rules were not applied due to reboot, or flush, etc.
Maybe this is mission impossible... I just would have thought something would be available or 75% given it is such a basic and core feaure.
Cheers Aaron,
Is there a more reliable method? I think it was in the topic re: seeing active stats, but when checking active stats on inbound call, rules were not applied due to reboot, or flush, etc.
Maybe this is mission impossible... I just would have thought something would be available or 75% given it is such a basic and core feaure.
Cheers Aaron,
Aaron wrote:The DBRead and DBWrite dialplan functions are what you are after http://www.sipsorcery.com/mainsite/Help ... s#Database.
ISP: Southern Phone ADSL2+ $55 Bundle. 22.4/1.2Mbps, ∞GB Bundle [Telstra].
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
Re: Call Forwarding [Day/Time Based & Dynamic State] CFWD Redirect
That's news to me. Whereabouts did you see that criticism?Flip wrote:I've seen a lot of criticism of the DB functions, saying that the server is often rebooted or the services flushed.
Is there a more reliable method? I think it was in the topic re: seeing active stats, but when checking active stats on inbound call, rules were not applied due to reboot, or flush, etc.
Maybe this is mission impossible... I just would have thought something would be available or 75% given it is such a basic and core feaure.
Cheers Aaron,
I can't even recall the last time the sipsorcery database function was rebooted and it's irrelevant any way since if it was down then none of the sipsorcery services would work any way so there would be no dialplans running.
Perhaps if the use case for the DB functions was multiple simultaneous dialplans with a large number of reads and writes in each dialplan there could be a problem with data integrity but that's a general problem with data access rather than a reliability issue.
If you need to did happen to need to use a database transaction (which would only be the case for a pretty complicated scenario) there are the extra dialplan functions available: sys.StartTransaction(), sys.COmmitTransaction() and sys.RollbackTransaction().
Re: Call Forwarding [Day/Time Based & Dynamic State] CFWD Redirect
Thanks Aaron,Aaron wrote:Perhaps if the use case for the DB functions was multiple simultaneous dialplans with a large number of reads and writes in each dialplan there could be a problem with data integrity but that's a general problem with data access rather than a reliability issue.
If you need to did happen to need to use a database transaction (which would only be the case for a pretty complicated scenario) there are the extra dialplan functions available: sys.StartTransaction(), sys.COmmitTransaction() and sys.RollbackTransaction().
I cannot find where you posted your example code snippet for the time of day, etc. I guess it doesn't matter, I've included my code snippet below.
I am having difficulty with the logic/syntax of checking both CID and time. e.g. x, y, z || 1, 2 || 3, 4 just doesn't work. I am trying to add some numbers as exceptions to the time of day restrictions.
Code: Select all
# If CLID/CID "contains" xxx... or OOH 6PM-7AM.
if req.Header.from.FromURI.User.to_s !~ /^0411222333/, /^99882121/ || localTime.hour >= 18 && localTime.min > 0 || localTime.hour <= 6 && localTime.min <= 59
sys.Log("Redirecting Out-Of-Hours (OOH) to ____.")
sys.Dial("2233435945@sip2sip.info") # *OOH* VM Destination...
else
sys.Log("No Out-Of-Hours (OOH) Redirection.")
# ...
# ... Inbound Dial Plan Code ...
# ...
sys.Dial("2233435945@sip2sip.info") # *Regular* VM Destination...
end
Code: Select all
# Set Fixed Start/End Hour & Min.
sys.DBWrite("OOH1StaH", "23") # OOH 1 Start Hour - e.g. PM.
sys.DBWrite("OOH1StaM", "00") # OOH 1 Start Minute.
sys.DBWrite("OOH1EndH", "08") # OOH 1 End Hour - e.g. AM.
sys.DBWrite("OOH1EndM", "30") # OOH 1 End Minute.
OOHstartHour = sys.DBRead("OOH1StaH") # etc... # If localTime.hour >= OOHstartHour && localTime.min > OOHstartMin
OOHendHour = sys.DBRead("OOH1EndH") # etc... # If localTime.hour <= OOHendHour && localTime.min <= OOHendMin
sys.DBWrite("OOH1Status", "1") # Set OOH 1 Status On/Off
Code: Select all
sys.DBDelete("OOHxxx","OOHyyy","OOHzzz") # Delete multiple values - i.e. OOH start/end times.
Thank you as always.[/size]
Last edited by Flip on Thu Nov 10, 2016 5:35 pm, edited 1 time in total.
ISP: Southern Phone ADSL2+ $55 Bundle. 22.4/1.2Mbps, ∞GB Bundle [Telstra].
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
Re: Call Forwarding [Day/Time Based & Dynamic State] CFWD Redirect
I guess I could do an IF for not xxx on CLID exclusion list.
Then as it is not on of those CLID, continue to IF time of day.
What do you recommend?
Probably even better if I could build a couple array's - $var[x] - to make it easier to update values. But I know hardly nothing about ruby... Just learning by examples...
Then as it is not on of those CLID, continue to IF time of day.
Code: Select all
If !~ 1234, 2345, 3456 # No. Exclusions
if time.hour && time.min || time.hour && time.min # Block out times
send to OOH VM
else
inbound rules
end
else
inbound rules
end
Probably even better if I could build a couple array's - $var[x] - to make it easier to update values. But I know hardly nothing about ruby... Just learning by examples...
ISP: Southern Phone ADSL2+ $55 Bundle. 22.4/1.2Mbps, ∞GB Bundle [Telstra].
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
Re: Call Forwarding [Day/Time Based & Dynamic State] CFWD Redirect
Try (note the capital F in req.Header.From.FromURI.User):
Deleting DB key-values is a singular operation.
For your regular expressions the "pattern , pattern" syntax is not supported. Unfortunately the Ruby engine that the sipsorcery server uses (IronRuby) is substantially more primitive than the fully blown Ruby distribution. If you want to match multiple expressions in a single regex use the '|' operator:
Code: Select all
if req.Header.From.FromURI.User !~ /^0411222333|^99882121/ || localTime.hour >= 18 && localTime.min > 0 || localTime.hour <= 6 && localTime.min <= 59
For your regular expressions the "pattern , pattern" syntax is not supported. Unfortunately the Ruby engine that the sipsorcery server uses (IronRuby) is substantially more primitive than the fully blown Ruby distribution. If you want to match multiple expressions in a single regex use the '|' operator:
Code: Select all
If !~ /1234|2345|3456/
...
Re: Call Forwarding [Day/Time Based & Dynamic State] CFWD Redirect
Okay, so instead of /^..../, /^....../ (which I thought the "," meant "or" or "either") || /^...../ . . . || /^...../ . . .
use:
/^....|..../
Thanks for the run down on iron ruby and why things do not work.
Appreciate it Aaron!
So what does /^.../, /^.../, /^.../ mean?
Or? Either?
Really? The commands are case sensitive? You know I think I have come across that before. Had problems after bulk selecting some lines of code and setting to lowercase in Notepad++. So if "req.Header.From.FromURI.User" will work, but ".from." won't...
Thanks again mate!
Will post full code snippet once complete for others to utilise...
use:
/^....|..../
Thanks for the run down on iron ruby and why things do not work.
Appreciate it Aaron!
So what does /^.../, /^.../, /^.../ mean?
Or? Either?
Really? The commands are case sensitive? You know I think I have come across that before. Had problems after bulk selecting some lines of code and setting to lowercase in Notepad++. So if "req.Header.From.FromURI.User" will work, but ".from." won't...
Thanks again mate!
Will post full code snippet once complete for others to utilise...
ISP: Southern Phone ADSL2+ $55 Bundle. 22.4/1.2Mbps, ∞GB Bundle [Telstra].
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.