Getting Started :: Australian OZ RUBY Dial Plan 2016/2017

Feedback, issues & questions regarding the use of the Telis Wizard and Simple Wizard dial plans.
User avatar
Flip
Posts: 82
Joined: Sun Aug 19, 2012 3:53 am

Getting Started :: Australian OZ RUBY Dial Plan 2016/2017

Post by Flip » Sun Oct 02, 2016 5:02 am

G'day!
This Dial Plan was originally configured for NSW Australia, however you can easily update it to reflect the different states and locations. If you don't know how, read the examples in Steps 1 to 3 below. The purpose of this post is for a simple, yet fully-functional, easy to change dial plan that is specific for Australians.

I have divided up the Dial Plan into segments to make it hopefully easier to read and understand. Copy ALL segments and paste them into SIP Sorcery or Notepad++. Or download the RUBY dial plan at the bottom of the post.

# STEP ONE #
Where are you located? What state do you call from?
#A. NSW 02 & VIC/TAS 03 Local Calls, as of 2015 ACMA:
All local numbers start with '3', '4','5', '6','7','8','9', after the 02/03.
This would appear as "[3456789]" or simply "[3-9]".
They are split up into designated areas and regions:
- 3, 4, 5, 6 (Regional NSW/VIC/TAS)
- 7, 8, 9 (Sydney/Melbourne Metro)
  • NSW/VIC/TAS: 3,4,5,6,7,8,9 = [3-9]
#B. QLD 07 Local Calls, as of 2015 ACMA:
- 2, 3 (Brisbane Metro / Regional QLD)
- 4, 5, 7 (Regional QLD)
  • QLD: 2,3,4,5,7 = [2-57]
#C. NT, SA, WA Local Calls, as of 2015 ACMA:
- 2, 5; (Regional)
- 7; (SA)
- 8; (SA, WA, NT)
- 6, 9; (WA, Islands)
  • N.T.: 2,5,8 = [258]
    S.A.: 2,5,7,8 = [2578]
    W.A.: 2,5,8,9 = [2589]
Choose your local state dial plan above, then find "/^[3-9]\d{7}/" below, and replace the "[3-9]" with your state code "[xxx]" from above. You can search for "Your local calls - Choose your state" to find the block of code to change. Either "____" (simple Cisco/Linksys style) or "/^____/" (regex) can be used. The choice is yours to use one or the other - or both!

But if you want to be lazy, you can of course, just use "[2-9]", but this may conflict with other services (or currently inactive services) in some states.


# STEP TWO #
If you use any carrier-specific call services (or VSP-specific services), that I don't, you can add them. For example:
$ (0)1 0 xxxxx xxxxxxxxxx [Telstra 8-18 digits]
(0)1 8 01xxxx [Telstra 9 digits]
(0)1 2 xxxxx xxxxxxxxxx [Optus 8-18 digits]
(0)x 5550 / (0)x 0550...
etcetera... So add rules as you require!

I have some extra space under step two, so will explain what "${EXTEN}" and "${dst}" mean and which you should use.
For example, you can use either "${EXTEN:2}" or "${dst:2}" - in this example, both will trim the first two characters from the input. Some examples online or on the forums will use EXTEN, others DST. They both mean the same thing - i.e. what was entered on the keypad by the caller when dialling. Personally, I use EXTEN, but the choice is yours. :)


# STEP THREE #
Create a list of your VoIP accounts / Voice Service Providers (VSPs). Once complete, create a list like below:
  • NAME - - LABEL # - - CHEAPEST RATES
    Example - EXA_1 - Mobile 12c.
    PennyTel - PTL_1 - STD 8c, Mobile 7.8c, Int'l.
    MyNetFone - MNF_1 - STD 8c, Int'l.
    TeleCube - TLC_1 - STD 10c, Mobile 5c.
    TeleCube - TLC_2 - STD 1.5c, Mobile 8c.
Insert the "Label" in the "____" fields below, matching the call type for the cheapest rates above.


# STEP FOUR #
OUTBOUND RUBY DIAL PLAN
This plan works on all devices I have used connected to SIP Sorcery (SS). I have included some in-line documentation so newb's can learn and get up and running quickly. The code below is RUBY and can be inserted into Notepad++ to display the syntax, making it easier to read.

Diagnostic/Debugging Output & Logic 'Case' Code Snippet. REQUIRED!

Code: Select all

# DIAGNOSTICS & DEBUGGING OUTPUT
sys.Log("+ - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - +")
sys.Log("+     NEW OUTBOUND CALL INITIATED!   OUTBOUND CALL LEG INFORMATION!     +")
sys.Log("+ - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - +")
sys.Log("o: req.URI: #{req.URI} // req.URI.Host: #{req.URI.Host} // req.URI.Host.to_s: #{req.URI.Host.to_s}")
sys.Log("o: req.URI.User: #{req.URI.User} // req.URI.User.to_s: #{req.URI.User.to_s{}} // req.Header: #{req.Header}")
sys.Log("o: req.URI.ToString: #{req.URI.ToString{}}")
sys.Log("o: req.Header.From: #{req.Header.From}")
sys.Log("o: req.Header.From.FromURI: #{req.Header.From.FromURI}")
sys.Log("o: req.Header.From.FromURI.User: #{req.Header.From.FromURI.User} // req.Header.from.FromURI.Host: #{req.Header.from.FromURI.Host}")
sys.Log("o: req.Header.from.FromURI.User.to_s: #{req.Header.from.FromURI.User.to_s} /// req.Header.From.FromName: #{req.Header.From.FromName}")
sys.Log("o: req.Header.From.ToString: #{req.Header.From.ToString()}")
sys.Log("o: req.Header.To: #{req.Header.To}")
sys.Log("o: req.Header.To.to_s: #{req.Header.To.to_s}")
sys.Log("o: req.Header.To.ToURI: #{req.Header.To.ToURI} // req.Header.To.ToName: #{req.Header.To.ToName}")
sys.Log("o: req.Header.Contact[0]: #{req.Header.Contact[0]}")
sys.Log("o: req.Header.Contact[0].ContactURI: #{req.Header.Contact[0].ContactURI}")
sys.Log("o: req.Header.Contact[0].ContactName: #{req.Header.Contact[0].ContactName}")
sys.Log("o: req.Header.CSeq: #{req.Header.CSeq} // req.Header.CallId: #{req.Header.CallId}")
sys.log("+ - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - +")
sys.Log("")
 
 
# START CALL LOGIC RULES
case req.URI.User
 
Internal Extension Speed Dial Code Snippet. OPTIONAL!

Code: Select all

 # ------------------------------------------------------------------------------------
 # SPEED DIAL # [INTERNAL VIRTUAL EXTENSIONS]
 # ------------------------------------------------------------------------------------
 # >> VSPs: SIPSorcery, and VSPs supporting SIP URI.
 # NOTE: Recommend 3 to 5 digit extensions.  Replace "__Name__" fields with the memorable name you wish to assign people; plus "___@" with destinations. E.g. 202 and Alex and 12345@xxx. So you can then use a SoftPhone and enter just "alex" to dial his/her number(s).
    when /^100/, "__Name__" then sys.Log("==== __Name__ Speed Dial =====")
        sys.Dial("____@sipsorcery.com",25) # 
        sys.Dial("____@sipsorcery.com") # Alternate 'number' if first fails/no answer.
    when /^101/, "__Name__" then sys.Log("==== __Name__ Speed Dial =====")
        sys.Dial("____@sipsorcery.com") # 
    when /^102/, "__Name__" then sys.Log("==== __Name__ Speed Dial =====")
        sys.Dial("____@sipsorcery.com") # 

    when /^111/, "__Name__" then sys.Log("==== __Name__ Speed Dial =====")
        sys.Dial("____@sipsorcery.com") # 
    when /^112/, "__Name__" then sys.Log("==== __Name__ Speed Dial =====")
        sys.Dial("____@sipsorcery.com",25) # 
        sys.Dial("____@sipsorcery.com") # Alternate 'number' if first fails/no answer.

    when /^121/, "__Name__" then sys.Log("==== __Name__ Speed Dial =====")
        sys.Dial("____@sipsorcery.com") # 
    when /^122/, "__Name__" then sys.Log("==== __Name__ Speed Dial =====")
        sys.Dial("____@sipsorcery.com") # 
 
Internal General Speed Dial Code Snippet. OPTIONAL!

Code: Select all

 # ------------------------------------------------------------------------------------
 # SPEED DIAL # [EXTERNAL SIP URI CALLS]
 # ------------------------------------------------------------------------------------
  # >> VSPs: SIPSorcery, PTL_x MNF_x TLC_x, and VSPs supporting SIP URI.
  # [FAMILY & FRIENDS]
    when /^____/ then sys.Dial("____@____")
    when "____" then sys.Dial("____@____")
  # [WORK & CLIENTS]
    when /^____/ then sys.Dial("____@____")
    when "____" then sys.Dial("____@____")
  # [OTHER RULES]
    when /^____/ then sys.Dial("____@____")
    when "____" then sys.Dial("____@____")
 
Override VSP Default Code Snippet. OPTIONAL!

Code: Select all

 # ------------------------------------------------------------------------------------
 # VSP ACCOUNT OVERRIDE PREFIXES # [BYPASS DEFAULT DIALING RULES]
 # ------------------------------------------------------------------------------------
  # >> VSPs: SIPSorcery, SIP Broker, PTL_x MNF_x TLC_x, and VSPs supporting SIP URI.
  # NOTE: I recommend "/^xx\*/" (xx*) over "/^\*xx/" (*xx) as supports more entries.
  # NUMBER + ASTERISK OVERRIDES [Preferred to Avoid Logic Confusion or Hardware Conflicts]
    when /^1\*/ then sys.Dial("${EXTEN:2}@____") # MNF Untimed + DID xxxx xxxx
     when /^2\*/ then sys.Dial("${EXTEN:2}@____") # MNF Trunk
     when /^3\*/ then sys.Dial("${EXTEN:2}@____") # MNF Overflow

    when /^4\*/ then sys.Dial("${EXTEN:2}@____") # PTL Untimed
     when /^5\*/ then sys.Dial("${EXTEN:2}@____") # PTL Timed

    # SIPBroker: International Access to 3rd Party VSP Free Calls
    #  * Int'l PSTN #'s: http://www.sipbroker.com/sipbroker/action/pstnNumbers
    #  * Supported VSPs: http://www.sipbroker.com/sipbroker/action/providerWhitePages
    when /^9\*/, /^\*9/ then sys.Dial("*${EXTEN:2}@sipbroker.com[rm=a]") # *9663. or 9*663. to *663.@sipbroker.com

    # SIPSorcery Internal Dialling
    when /^0\*/, /^\*0/ then sys.Dial("${EXTEN:2}@local") # 0*... or *0... to ...@sipsorcery.com

    when /^10\*/ then sys.Dial("${EXTEN:2}@____") # TLC Untimed Trunk
     when /^11\*/ then sys.Dial("${EXTEN:2}@____") # TLC Timed Trunk

    # when /^__\*/ then sys.Dial("${EXTEN:3}@____") # 
 
Diagnostic & Troubleshooting Code Snippet. RECOMMENDED!

Code: Select all

 # ---------------------------------------------------------------------------------------------
 # VSP & PUBLIC DIAGNOSTIC NUMBERS [MUSIC, ECHO TEST, CLID, DTMF, AUDIO CHANNEL & CONNECTIVITY]
 # ---------------------------------------------------------------------------------------------
 # >> SIPSorcery, SIP Broker, Any VSP SIP URI's.
    when /^311/ then sys.Dial("music@iptel.org")          # Normal - Media/Music
    when /^312/ then sys.Dial("early_music@iptel.org")    # Early Media - Media/Music
    when /^313/ then sys.Dial("echo@iptel.org")           # Echo Test
    when /^314/ then sys.Dial("3246@iptel.org")           # Echo Test
    when /^315/ then sys.Dial("2233435945@sip2sip.info")  # LENNY - 2 Way Audio Test ++ Annoy Marketing Calls!!!!
    when /^316/ then sys.Dial("wbdemo@conf.zipdx.com")    # Wide Band - Media/Music
    when /^317/ then sys.Dial("6414539840@podlinez.net")  # Parliment Question Time
    # when /^318/ then sys.Dial("775@sip.pennytel.com")   # Narrow Band - Media/Music
 
    when /^317/ then sys.Dial("904@mouselike.org")        # 1. Echo, 2. VM, 3 Music, 4. Audio quality sweep test, 5. monitor line test.
    when /^318/ then sys.Dial("4151595@services.sip.is")  # 1. Echo, 2. Hold, 3. Rec + Listen, 4. Read CID. # NOTE: 340ms Latency
    when /^320/ then sys.Dial("201@ideasip.com")          # Welcome Message
    when /^321/ then sys.Dial("301@ideasip.com")          # Echo Test
    when /^322/ then sys.Dial("411@ideasip.com")          # Dial Free Call '411' Numbers & use '*' to connect, IVR AUDIO
    when /^323/ then sys.Dial("8355@ideasip.com")         # TellMe Information Service
    when /^324/ then sys.Dial("8463@ideasip.com")         # Time Service (Eastern Time, US)

    when /^331/ then sys.Dial("0871271201@____")          # Two-way Audio Echo Test.
    when /^332/ then sys.Dial("0871271202@____")          # Radio Paradise Music.
    when /^333/ then sys.Dial("0871271203@____")          # Announce CLI / CLID / CID.
    when /^334/ then sys.Dial("0871271204@____")          # Speaking Day/Date/Time.
    when /^335/ then sys.Dial("0871271205@____")          # Test DTMF Key Tones.

    #when /^3__/ then sys.Dial("____")
=begin
        OFFLINE or BROKEN/FAULTY?
         9901@qxip.net / 9902@qxip.net / 9999@qxip.net
         pirateradio@qxip.net / 13108254321@ucla.edu
         telephreak@voip.telephreak.org / info@intertex.se
         17622600@projectmf.homelinux.com / lenny@sip.itslenny.com
         when /^___/ then sys.Dial("____@tollfree.alcazarnetworks.com") # USA/CA TOLLFREE e.g. 18001231234
         when /^___/ then sys.Dial("hangup$____@conference.freeswitch.org") # https://wiki.freeswitch.org/wiki/Hangup_Causes OR http://www.voip-info.org/wiki/view/Asterisk+variable+hangupcause
=end
 
Australia-based Dial Plan Patterns Code Snippet. REQUIRED!

Code: Select all

 # ------------------------------------------------------------------------------------
 # REGULAR DIALING RULES | [AUSTRALIAN PATTERN EXAMPLES FOR DIALING STANDARD NUMBERS]
 # ------------------------------------------------------------------------------------
   # FYI: ${EXTEN:2} = Remove up to RHS of 2nd Character. EXTEN:X:X (Position, Replace) NOT AVAILABLE! :(
    when /^000/, /^106/, /^112/ then sys.Dial("${EXTEN}@____") # 000S0| 112S0| 106S0 hearing impaired. NOTE: not all VSPs support emergency services!
                sys.Dial("${EXTEN}@____",20) # Backup if 1st fails.
                sys.Dial("${EXTEN}@____",20) # Backup if 2nd fails.
    when /^0011/ then sys.Dial("${EXTEN}@____") # 0011xxxxxxxx.S3| Create for specific country prefixes too!
                sys.Dial("${EXTEN}@____",25) # Backup if 1st fails.

    # when "110", "114", "12[345]" "127x." "14x." "17x." then sys.Dial("${EXTEN}@____") # Patterns: 110 114 124/5 127. 14. 17. Not yet finished!
    when /^12[34]/, /^1234/, /^12455/, /^12456/, /^124937/ then rejectCall(603," ... NO PREMIUM  12xx ...") # 12[34]! 1234!|12455!|12456!|124937!|
    when /^122/, /^1223/, /^12245/ then sys.Dial("${EXTEN}@____") # 12x.S0|1223S0|12245S0|

    when /^10\d{5}/, /^99[0-9]99/ then sys.Dial("${EXTEN}@____") # 1012345, 99299 (Echo Test), 99599 (Balance)
    when /^211/, "TLC211", /^1031000/ then sys.Dial("____@____") # 
    when /^212/, "TLC212", /^1041000/ then sys.Dial("____@____") # 
    when /^213/, "TLC213", /^1051000/ then sys.Dial("____@____") # 

    # *** YOUR LOCAL CALLS - CHOOSE YOUR STATE *** CORRECT AS OF 2016.11 ***
    # NSW 02, VIC/TAS 03 = [3-9]xxxxxxx or /^[3-9]\d{7}/
    # QLD 07 = [2-57]xxxxxxx or /^[2-57]\d{7}/
    # N.T. 08 = [258]xxxxxxx or /^[258]\d{7}/
    # S.A. 08 = [2578]xxxxxxx or /^[2578]\d{7}/
    # W.A. 08 = [2589]xxxxxxx or /^[2589]\d{7}/
    when /^[3-9]\d{7}/ then sys.Dial("${EXTEN}@____") # NSW/VIC/TAS: [3-9] or [346789]xxxxxxxS0|, 
                sys.Dial("${EXTEN}@____",25) # Backup if 1st fails.

    when /^0[2378][2-9]\d{7}/, /^61[2378][2-9]\d{7}/, /^001161[2378][2-9]\d{7}/ then sys.Dial("${EXTEN}@____") # Expanded for States: NSW/VIC/TAS 0[23][3-9]xxxxxxxS0 + QLD 0[7][2-57]xxxxxxxS0 + NT 0[8][258]xxxxxxxS0 + SA 0[8][2578]xxxxxxxS0 + WA 0[8][2589]xxxxxxxS0 (CORRECT AS OF 2016.11)
                sys.Dial("${EXTEN}@____",25) # Backup if 1st fails.
    when /^0[1569]\d{8}/, /^61[1569]\d{8}/, /^001161[1569]\d{8}/ then sys.Dial("${EXTEN}@____") # 0[1569]xxxxxxxxS0| e.g. 0198, 0550 services.
                sys.Dial("${EXTEN}@____",25) # Backup if 1st fails.
    when /^04\d{8}/, /^614\d{8}/, /^0011614\d{8}/ then sys.Dial("${EXTEN}@____") # 0[4]xxxxxxxxS0|
                sys.Dial("${EXTEN}@____",25) # Backup if 1st fails.

    when /^1[38]0[0-2]\d{6}/, /^611[38]0[0-2]\d{6}/, /^1[38]z\d{3}/, /^611[38]z\d{3}/, /^0011611[38][1-9]\d{3}/ then sys.Dial("${EXTEN}@____") # 1[38]00xxxxxxS0|1[38][1-9]xxxS0|
                sys.Dial("${EXTEN}@____",25) # Backup if 1st fails.
    when /^1[9]0[0-26]/, /^611[9]0[0-26]/, /^0011611[9]0[0-26]/ then sys.Respond(403, "NO PREMIUM 1900!!!") # 1[9]0[0126]!
      #? then rejectCall(603,"...")

    when /^1[258]1/, "09xxxxxx." then sys.Dial("${EXTEN}@____") # 1[258]1S0|09xxxxxxS0| ### UPDATED to "/^09\d{6}/ (MNF) /^09\d{12}/ (PTL) OR "09xxxxxx." for 8 and 14 digit MNF numbers! ###
    # when /^77[1578]/, /^888\d{7}/ then sys.Dial("${EXTEN}@VSP_4") # 77[1578]S0| 888xxxxxxxS0| ### UPDATED: PTL closed and sold out to MNF. ###
 
"When All Else Fails" Dial Plan Code Snippet. REQUIRED!

Code: Select all

else
    sys.log("# - - - # - - - # - - - # - - - # - - - # - - - # - - - # - - - #")
    sys.log("... No Rule Match! .. .. No Rule Match! .. .. No Rule Match! ...")
    sys.log("Retrying EXTEN clean-up and without rules...")
    num = req.URI.User.to_s           # Return Dialled Number >> +61 (0)2 9988-1122 <<
    # num = num.downcase.slice(/[^:]+/) # Convert to Lowercase and Slice before ':'.
    num = num.gsub(/[^0-9*#]/,'')     # Strip ALL Text/Symbols (Except: 0-9, # (hash/pound), * (asterisk))
    sys.log("# - - - # - - - # - - - # - - - # - - - # - - - # - - - # - - - #")
    sys.Log("PRIMARY VSP [Cheapest VSP by Default]")
    sys.Dial("#{num}@____", 20)

    sys.Log("SECONDARY VSP [Alternate VSP, 2nd cheapest on average]")
    sys.Dial("#{num}@____", 20)

    sys.Log("TERTIARY VSP [Final Attempt VSP, most expensive]")
    sys.Dial("#{num}@____", 20)
    sys.log("# - - - # - - - # - - - # - - - # - - - # - - - # - - - # - - - #")

  # TO-DO: IF FAILS, SYS.EMAIL: SEND EMAIL NOTIFICATION WITH DEBUG INFO + ERROR + CALL DETAILS + STATS...
  # TO-DO: CREATE A CALL FORWARD SYSTEM THAT IS TURNED ON/OFF BY TIME OF DAY. USE DATABASE STORAGE...

    sys.Respond(404, "#--- Oops! No Destination Found, Destination Timed-Out, or No Dial Plan Matched URI/EXTEN: #{req.Header.To} / #{req.URI.User.to_s}! ---#")

end
DOWNLOAD & UPDATES
SIP SORCERY - GETTING STARTED - AUSTRALIAN DIAL PLAN 2016.10.03 v2.RB.zip
Australian Dial Plan v2 - **UPDATED 2016.10.03**
(3.99 KiB) Downloaded 20 times
The attachment SIP SORCERY - GETTING STARTED - AUSTRALIAN DIAL PLAN 2016.10.01 v1.RB.zip is no longer available
  • Version 2 - 2016.10.03
  • Version 1 - 2016.10.01
_________________________________________________________________________________________________________


FULLY DEFINITIVE* EXPLANATION OF INBOUND & OUTBOUND "SYS.DIAL" OPTION 'THINGS'! *
almost.
  • [cd=#,] Maximum permitted 'Call Duration' to disconnect call leg(s) (in seconds);

    [dt=#,] Specified 'Delay Time' to wait before initiating call leg(s) (in seconds);

    [fd=x,] Override and use custom FROM 'Display Name/Number' Header for call leg:
    • - e.g. "[fd=9876543210]" set '9876543210' as display name/number in Header;
    [fu=x,] Override and use custom FROM 'URI User Name' Header for call leg:
    • - e.g. "[fu=example]" set 'example' as URI User Name in Header;
    [fh=x,] Override and use custom FROM 'URI Host Name' Header for call leg:
    • - e.g. "[fh=host-name]" set 'host-name' as URI Host Name in Header;
    [ma=x,] Do not Mangle the 'SDP' on call leg(s):
    • - 'true' [default];
      - 'false';
    [rm=x,] Call leg redirect mode:
    • - _: No redrect option specified (blank); create new anonymous forward based on 'redirect URI' [default];
      - m: Redirect 'Manually' and permit the dial plan to decide the action;
      - n: Process redirect in 'New Instance' of the same dial plan;
    [tr=x,] Specify whether transfers, or 'REFER' requests, will be accepted:
    • - c: Place a 'Call' (Warning! Exercise caution!);
      - n: 'No' - do not permit the request;
      - p: Allow request and 'Pass-Through'
      [default];
* EXAMPLES *

Code: Select all

sys.Dial("${EXTEN}@Provider_X[cd=600,rm=n]")
The call sequence will be:
- Dial via SIP Provider X.
- Terminate call after ~600 secs (10mins).
- Process redirect in a new instance of the dial plan.

Code: Select all

sys.Dial("${EXTEN}@Provider_Z[dt=5,fd=0987654321]") or fu=#{@cid}
The call sequence will be:
- Dial via SIP Provider Z.
- Delay ~3-5 secs before dialling.
- Override the display dame/number in the header.

Code: Select all

sys.Dial("${EXTEN}@Provider_1 & ${EXTEN}@Provider_2[dt=5] | ${EXTEN}@Provider_3")
The call sequence will be:
- Sys.Dial dials '12345' via "Provider_1". 
- Then after an approx. ~3-5 secs delay, dial '23456' via "Provider_2".
- When both call legs have failed (i.e. no answer, engaged/busy, or timeout), a new call is initiated to '56789' via "Provider_3".
- NOTE: If either of the 2 forwarded calls are answered, all other active (or pending) forwarded calls are cancelled, and the dial plan is terminated.

Code: Select all

sys.Dial("12345@Provider_3[rm=a,cd=3600] & 56789@Provider_2[dt=5,rm=a,cd=600]")
The call sequence will be:
- Dial 12345 via Provider_3, redirect and add new call leg to current call.
- Maximum call duration of 3600sec (60min or 1hr).
- Dial 56789 after a delay of ~3-5sec, redirect and add new call leg to current call.
- Maximum call duration of 600sec (10min).
[/size]
Last edited by Flip on Fri Oct 14, 2016 1:40 pm, edited 8 times in total.
ISP: Exetel ADSL2+ $60 Bundle. 22.4/1.2Mbps, 200/∞ GB [AAPT] + PSTN Bundle [Telstra].
VSP: Telecube¹, SIPTalk², MyNetFone³ via SIPSorcery & Ol' Voxalot. [OMG! Ewww Yuck!! Avoid DIDLogic!!!
H/W: Asus RT-AC66U; Cisco SPA232D, 3 x SPA302's, 2 x SPA901's, SPA3102; Yealink SIP-T46G.

User avatar
Aaron
Site Admin
Posts: 4563
Joined: Thu Jul 12, 2007 12:13 am

Re: Getting Started :: Australian OZ RUBY Dial Plan 2016/2017

Post by Aaron » Sun Oct 02, 2016 11:53 am

Very nice, thanks for posting.

I should incorporate the Australian dialing rules into my own plan rather than being lazy and just using 61 as the prefix.

User avatar
Flip
Posts: 82
Joined: Sun Aug 19, 2012 3:53 am

Re: Getting Started :: Australian OZ RUBY Dial Plan 2016/2017

Post by Flip » Mon Oct 03, 2016 4:01 pm

Aaron wrote:Very nice, thanks for posting.

I should incorporate the Australian dialing rules into my own plan rather than being lazy and just using 61 as the prefix.
Thanks mate. I think we need a snippets library or something. List of names for 10 to 20 PBX features, with how to code it in Ruby, plus examples to get people up and running. Plus link to "Purchase additional call processing" with a summary of how many simultaneous calls inbound / outbound with each example.

Pasting two more Code Snippet simple examples - Round Robin and Call Hunt with various examples, for inbound/outbound processing. Just having to job my memory on some syntax... ;) Hopefully will evolve with more examples in future!

p.s. Are you sure this is right in the KB??? Looking at the variable name, are you sure it doesn't return just the current timezone configured in the owner's profile?
sys.GetTimezone returns a string representation of the dial plan owner's current dial plan as stored on their web profile.
ISP: Exetel ADSL2+ $60 Bundle. 22.4/1.2Mbps, 200/∞ GB [AAPT] + PSTN Bundle [Telstra].
VSP: Telecube¹, SIPTalk², MyNetFone³ via SIPSorcery & Ol' Voxalot. [OMG! Ewww Yuck!! Avoid DIDLogic!!!
H/W: Asus RT-AC66U; Cisco SPA232D, 3 x SPA302's, 2 x SPA901's, SPA3102; Yealink SIP-T46G.

User avatar
Aaron
Site Admin
Posts: 4563
Joined: Thu Jul 12, 2007 12:13 am

Re: Getting Started :: Australian OZ RUBY Dial Plan 2016/2017

Post by Aaron » Tue Oct 04, 2016 9:36 am

Flip wrote: I think we need a snippets library or something. List of names for 10 to 20 PBX features, with how to code it in Ruby, plus examples to get people up and running. Plus link to "Purchase additional call processing" with a summary of how many simultaneous calls inbound / outbound with each example.

Pasting two more Code Snippet simple examples - Round Robin and Call Hunt with various examples, for inbound/outbound processing. Just having to job my memory on some syntax... ;) Hopefully will evolve with more examples in future!
If you were to create a set of Ruby functions on something like https://gist.github.com/ I'd be happy to pull it down to the sipsorcery server so people can use it in their dialplan. And yes I should create more dialplan examples... it's on my list of things.
Flip wrote: p.s. Are you sure this is right in the KB??? Looking at the variable name, are you sure it doesn't return just the current timezone configured in the owner's profile?
sys.GetTimezone returns a string representation of the dial plan owner's current dial plan as stored on their web profile.
I'm pretty sure the help information is correct http://www.sipsorcery.com/mainsite/Help ... s#Timezone. Have you found somethiing different?

User avatar
Flip
Posts: 82
Joined: Sun Aug 19, 2012 3:53 am

Re: Getting Started :: Australian OZ RUBY Dial Plan 2016/2017

Post by Flip » Tue Oct 04, 2016 11:56 am

Hang on... Did you read the quote? "GetTimeZOne returns a string representation of the dial plan owner's current dial plan stored in their web profile"??? What does GetTimeZone have to do with a string representation of the dial plan?

Description is wrong... It has nothing to do with a dial plan.
GetTimeZone gets the time zone settings stored under the user's account. Right? The above makes no sense... sounds like you were rambling :oops:
Aaron wrote:
Flip wrote: p.s. Are you sure this is right in the KB??? Looking at the variable name, are you sure it doesn't return just the current timezone configured in the owner's profile?
sys.GetTimezone returns a string representation of the dial plan owner's current dial plan as stored on their web profile.
I'm pretty sure the help information is correct http://www.sipsorcery.com/mainsite/Help ... s#Timezone. Have you found somethiing different?
Last edited by Flip on Wed Oct 05, 2016 6:24 pm, edited 1 time in total.
ISP: Exetel ADSL2+ $60 Bundle. 22.4/1.2Mbps, 200/∞ GB [AAPT] + PSTN Bundle [Telstra].
VSP: Telecube¹, SIPTalk², MyNetFone³ via SIPSorcery & Ol' Voxalot. [OMG! Ewww Yuck!! Avoid DIDLogic!!!
H/W: Asus RT-AC66U; Cisco SPA232D, 3 x SPA302's, 2 x SPA901's, SPA3102; Yealink SIP-T46G.

User avatar
Aaron
Site Admin
Posts: 4563
Joined: Thu Jul 12, 2007 12:13 am

Re: Getting Started :: Australian OZ RUBY Dial Plan 2016/2017

Post by Aaron » Wed Oct 05, 2016 7:23 am

Flip wrote:Hang on... Did you read the quote? "GetTimeZOne returns a string representation of the dial plan owner's current dial plan stored in their web profile"??? What does GetTimeZone have to do with a string representation of the dial plan?
GetTimeZone gets the time zone settings stored under the user's account. Right? The above makes no sense... sounds like you were rambling :oops:
So it's a grammar imperfection rather than a problem with the dialplan function. I'll re-word it s bit.

User avatar
Flip
Posts: 82
Joined: Sun Aug 19, 2012 3:53 am

Re: Getting Started :: Australian OZ RUBY Dial Plan 2016/2017

Post by Flip » Wed Oct 05, 2016 6:20 pm


FULLY DEFINITIVE* EXPLANATION OF INBOUND & OUTBOUND "SYS.DIAL" OPTION 'THINGS'! *
almost.
  • [cd=#,] Maximum permitted 'Call Duration' to disconnect call leg(s) (in seconds);

    [dt=#,] Specified 'Delay Time' to wait before initiating call leg(s) (in seconds);

    [fd=x,] Override and use custom FROM 'Display Name/Number' Header for call leg:
    • - e.g. "[fd=9876543210]" set '9876543210' as display name/number in Header;
    [fu=x,] Override and use custom FROM 'URI User Name' Header for call leg:
    • - e.g. "[fu=example]" set 'example' as URI User Name in Header;
    [fh=x,] Override and use custom FROM 'URI Host Name' Header for call leg:
    • - e.g. "[fh=host-name]" set 'host-name' as URI Host Name in Header;
    [ma=x,] Do not Mangle the 'SDP' on call leg(s):
    • - 'true' [default];
      - 'false';
    [rm=x,] Call leg redirect mode:
    • - _: No redrect option specified (blank); create new anonymous forward based on 'redirect URI' [default];
      - m: Redirect 'Manually' and permit the dial plan to decide the action;
      - n: Process redirect in 'New Instance' of the same dial plan;
    [tr=x,] Specify whether transfers, or 'REFER' requests, will be accepted:
    • - c: Place a 'Call' (Warning! Exercise caution!);
      - n: 'No' - do not permit the request;
      - p: Allow request and 'Pass-Through'
      [default];
* EXAMPLES *

Code: Select all

sys.Dial("${EXTEN}@Provider_X[cd=600,rm=n]")
The call sequence will be:
- Dial via SIP Provider X.
- Terminate call after ~600 secs (10mins).
- Process redirect in a new instance of the dial plan.

Code: Select all

sys.Dial("${EXTEN}@Provider_Z[dt=5,fd=0987654321]") or fu=#{@cid}
The call sequence will be:
- Dial via SIP Provider Z.
- Delay ~3-5 secs before dialling.
- Override the display dame/number in the header.

Code: Select all

sys.Dial("${EXTEN}@Provider_1 & ${EXTEN}@Provider_2[dt=5] | ${EXTEN}@Provider_3")
The call sequence will be:
- Sys.Dial dials '12345' via "Provider_1". 
- Then after an approx. ~3-5 secs delay, dial '23456' via "Provider_2".
- When both call legs have failed (i.e. no answer, engaged/busy, or timeout), a new call is initiated to '56789' via "Provider_3".
- NOTE: If either of the 2 forwarded calls are answered, all other active (or pending) forwarded calls are cancelled, and the dial plan is terminated.

Code: Select all

sys.Dial("12345@Provider_3[rm=a,cd=3600] & 56789@Provider_2[dt=5,rm=a,cd=600]")
The call sequence will be:
- Dial 12345 via Provider_3, redirect and add new call leg to current call.
- Maximum call duration of 3600sec (60min or 1hr).
- Dial 56789 after a delay of ~3-5sec, redirect and add new call leg to current call.
- Maximum call duration of 600sec (10min).
[/size]
Last edited by Flip on Fri Oct 14, 2016 1:38 pm, edited 2 times in total.
ISP: Exetel ADSL2+ $60 Bundle. 22.4/1.2Mbps, 200/∞ GB [AAPT] + PSTN Bundle [Telstra].
VSP: Telecube¹, SIPTalk², MyNetFone³ via SIPSorcery & Ol' Voxalot. [OMG! Ewww Yuck!! Avoid DIDLogic!!!
H/W: Asus RT-AC66U; Cisco SPA232D, 3 x SPA302's, 2 x SPA901's, SPA3102; Yealink SIP-T46G.

User avatar
Aaron
Site Admin
Posts: 4563
Joined: Thu Jul 12, 2007 12:13 am

Re: Getting Started :: Australian OZ RUBY Dial Plan 2016/2017

Post by Aaron » Sun Oct 09, 2016 6:41 am

Thanks again for the dial plan examples. I've made some small changes and added them to the Help page at http://www.sipsorcery.com/mainsite/Help/DialPlans#Dial.

The only correction to your list is that the only redirect options are m and n. The a option is no longer supported.

You may be interested in the source file which is used to process dial string options https://github.com/sipsorcery/sipsorcer ... criptor.cs.

User avatar
Flip
Posts: 82
Joined: Sun Aug 19, 2012 3:53 am

Re: Getting Started :: Australian OZ RUBY Dial Plan 2016/2017

Post by Flip » Fri Oct 14, 2016 1:34 pm

Aaron wrote:The only correction to your list is that the only redirect options are m and n.
Heheh "Be careful" - you still left it toned down. :P

Okay, so 'a' was removed. Only M and N can be used... What about 'blank'? Oh, so blank is default, and 'n' is not.
Can you provide an example for the "fu=#{@cid}"? Ta.
.

p.s. Hey I'm finding "dt=" not even work. Must be something not right in my inbound rule.

Code: Select all

# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
  # Groups: Grouped to ring sets of accounts for testing... 
  acAta = "1111@local&2222@local&3333@local" # ATA devices
  acSoft = "5555@local&6666@local&7777@local" # Softphone & Mobile Phone Apps
  acTest = "1234@local&2345@local&3456@local" # Test Accounts
  acAll = "#{acSoft}&#{acAta}[dt=5]&#{acTest}" # 
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
  sys.Dial("#{acSoft}&#{acAta}[dt=5]&#{acTest}|VM@Voicemail.VM,25") #
You previously said you could combine "[dt=]" and ",X". However, even when I remove the ,X threshold, it still fails to acknowledge the [dt=x].

So right now it "should" ring the Softphones, then after 5 secs - start dialing the ATAs and Test devices... But it still rings everything!? Five (5) extensions ring immediately after dialing... No delay :(
Have you some ideas?
Aaron wrote:You may be interested in the source file which is used to process dial string options https://github.com/sipsorcery/sipsorcer ... criptor.cs.
I'll check it out. Not ventured into the source code to date... ;)
ISP: Exetel ADSL2+ $60 Bundle. 22.4/1.2Mbps, 200/∞ GB [AAPT] + PSTN Bundle [Telstra].
VSP: Telecube¹, SIPTalk², MyNetFone³ via SIPSorcery & Ol' Voxalot. [OMG! Ewww Yuck!! Avoid DIDLogic!!!
H/W: Asus RT-AC66U; Cisco SPA232D, 3 x SPA302's, 2 x SPA901's, SPA3102; Yealink SIP-T46G.

User avatar
Aaron
Site Admin
Posts: 4563
Joined: Thu Jul 12, 2007 12:13 am

Re: Getting Started :: Australian OZ RUBY Dial Plan 2016/2017

Post by Aaron » Mon Oct 17, 2016 9:19 am

Flip wrote: So right now it "should" ring the Softphones, then after 5 secs - start dialing the ATAs and Test devices... But it still rings everything!? Five (5) extensions ring immediately after dialing... No delay :(
Have you some ideas?
That's a bug. I was able to re-produce it and it's caused by a race condition. The code doesn't allow a call to be delayed if there are no other call legs in progress. However because all the call legs start within a very short space of time the non-delayed call legs might not have started before the delayed call leg is reached.

I've fixed the code and will deploy it to the production servers during the next deployment window which will be this coming Sunday.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest