same TSP SIP lines call handling

Discussion in 'General' started by zaritronic, Aug 13, 2009.

  1. zaritronic

    Joined:
    Apr 29, 2009
    Messages:
    54
    Likes Received:
    0
    I have two SIP lines registered with the same TSP going to the same ELASTIX box.
    Each line has its own TRUNK definition, and one INBOUND ROUTE for all trunks.
    I want to perform specific CALL HANDLING for each line. For instance when line A is called I want it to go to a specific extension, whereas when line B is called I want it to go to an IVR.

    I know how to do that with a pure asterisk box (I specify different context in their SIP definition) but I'm not sure how it can be done under ELASTIX.

    Thanks for your help,

    Aron
     
  2. Megabyte

    Joined:
    Mar 28, 2009
    Messages:
    327
    Likes Received:
    0
    Ok you just have to go to incoming routes and add incoming route based in your differents DID of your accounts. In the field that say DID Number define here the number that your provider give to you. later in the Set Destination select where you wnat that you call goes.
     
  3. zaritronic

    Joined:
    Apr 29, 2009
    Messages:
    54
    Likes Received:
    0
    Indeed, I had done that but it doesn't work.
    It looks like it doesn't get the DID from the TSP, am I right?

    Look at the snippet I copied from asterisk's CLI at the beginning of the incoming call.
    It shown the DID as being 's'.

    Furtermore asterisk always show the call as coming from the same trunk (MY_TSP_LINE_A) whether I call Line A or Line B.

    Any clue?

    ------------------------------------------------
    Connected to Asterisk 1.4.25.1 currently running on tavolino (pid = 2342)
    Verbosity is at least 3
    -- Executing [s@from-sip-external:1] GotoIf("SIP/MY_TSP_LINE_A-08885448", "1?from-trunk||1") in new stack
    -- Goto (from-trunk,s,1)
    -- Executing [s@from-trunk:1] Set("SIP/MY_TSP_LINE_A-08885448", "__FROM_DID=s") in new stack
    -- Executing [s@from-trunk:2] Gosub("SIP/MY_TSP_LINE_A-08885448", "app-blacklist-check|s|1") in new stack
    -- Executing [s@app-blacklist-check:1] LookupBlacklist("SIP/MY_TSP_LINE_A-08885448", "") in new stack
    -- Executing [s@app-blacklist-check:2] GotoIf("SIP/MY_TSP_LINE_A-08885448", "0?blacklisted") in new stack
    -- Executing [s@app-blacklist-check:3] Return("SIP/MY_TSP_LINE_A-08885448", "") in new stack
    -- Executing [s@from-trunk:3] ExecIf("SIP/MY_TSP_LINE_A-08885448", "0 |Set|CALLERID(name)=+<MY_CALLERID>") in new stack
    -- Executing [s@from-trunk:4] Set("SIP/MY_TSP_LINE_A-08885448", "__CALLINGPRES_SV=allowed_not_screened") in new stack
    -- Executing [s@from-trunk:5] SetCallerPres("SIP/MY_TSP_LINE_A-08885448", "allowed_not_screened") in new stack
    -- Executing [s@from-trunk:6] Goto("SIP/MY_TSP_LINE_A-08885448", "from-did-direct|5121|1") in new stack
     
  4. Megabyte

    Joined:
    Mar 28, 2009
    Messages:
    327
    Likes Received:
    0
    If it is "s" you will have to create an any did/any cid incoming route without any DID, but it will be so difficult if your other provider dont send a DID number, you can contact and ask him if he can send you a number or something, even a Alpha digit work in this case.
     
  5. zaritronic

    Joined:
    Apr 29, 2009
    Messages:
    54
    Likes Received:
    0
    OK, I had a look at the FreePBX code and learned that context [from-sip-external] usen
    EXTEN as the variable that supposedly contains the DID information.

    But as I had already found out with classic asterisk installations, that is not always true,
    thus I got to fetch the DID information from the TO: field of the the SIP header.
    Now I have done the same with Elastix and here follows the code that implemts it.

    It works for me even with various TSP, thus allowing me to achieve the objective of
    my posting. To implement it in ELASTIX one need to perform the following:

    1) edit /etc/asterisk/extensions_override_freepbx.conf and insert the lines following
    the ;----------- line
    2) reload asterisk

    Enjoy your DID!!!

    Aron

    P.S. I think it could be good to implemt it directly in FreePBX, but I leave for the developers
    to assess the value of this solution.

    ;---------------------------
    ;
    ; * /etc/asterisk/extensions_override_freepbx.conf *
    ;
    ; According to http://www.freepbx.org/configuration_files
    ; all contexts defined in this file override the equivalent context
    ; in /etc/asterisk/extensions.conf
    ;

    [from-sip-external]
    ;give external sip users congestion and hangup
    ; Yes. This is _really_ meant to be _. - I know asterisk whinges about it, but
    ; I do know what I'm doing. This is correct.
    exten => _.,1,NoOp(Received incoming SIP connection from unknown peer to ${EXTEN})
    exten => _.,n,Set(DID=${IF($["${EXTEN:1:2}"=""]?s:${EXTEN})})
    exten => _.,n,Goto(s,1)
    ;
    ; 13-Aug-2009
    ;
    ; Vis-a-vis of the original [from-sip-external] context there are
    ; two extra lines (those following this comment) as well as the change
    ; to 's' priority from '1' for the 'GoToIf($["${ALLOW_SIP_ANON}"="yes"...'
    ; line immediately after.
    ; The telephone number extracted from the SIP header might not contain
    ; the country code.
    ;
    exten => s,1,NoOp("Current context = ${CONTEXT} - Override version")
    exten => s,n,Set(DID=${CUT(CUT(SIP_HEADER(TO),@,1),:,2)})
    ;
    exten => s,n,GotoIf($["${ALLOW_SIP_ANON}"="yes"]?from-trunk,${DID},1)
    exten => s,n,Set(TIMEOUT(absolute)=15)
    exten => s,n,Answer
    exten => s,n,Wait(2)
    exten => s,n,Playback(ss-noservice)
    exten => s,n,Playtones(congestion)
    exten => s,n,Congestion(5)
    exten => h,1,NoOp(Hangup)
    exten => i,1,NoOp(Invalid)
    exten => t,1,NoOp(Timeout)
     

Share This Page