cidlookup module and CID Name

Discussion in 'General' started by harryhirsch, Aug 28, 2009.

  1. harryhirsch

    Joined:
    Apr 10, 2009
    Messages:
    24
    Likes Received:
    0
    Hi,

    I am trying to get cidlookup with Superfecta to work perfectly.
    I have a problem in cidlookup :

    When there is an incoming SIP call with CID name and number, cidlookup try to get in any case the Internet phonebook to get the CID name :
    Here the script :

    [ext-did-0002]
    exten => 33811951884,1,Set(__FROM_DID=${EXTEN})
    exten => 33811951884,n,Gosub(app-blacklist-check,s,1)
    exten => 33811951884,n,Gosub(cidlookup,cidlookup_5,1)
    exten => 33811951884,n,ExecIf($[ "${CALLERID(name)}" = "" ] ,Set,CALLERID(name)=${CALLERID(num)})
    exten => 33811951884,n,Set(__CALLINGPRES_SV=${CALLINGPRES_${CALLINGPRES}})
    exten => 33811951884,n,SetCallerPres(allowed_not_screened)
    exten => 33811951884,n,Goto(from-did-direct,200,1)


    [cidlookup]
    include => cidlookup-custom
    exten => Noop(Using CallerID ${CALLERID(all)})
    exten => cidlookup_5,1,Set(CALLERID(name)=${CURL(http://127.0.0.1:80/admin/modules/super ... henumber=${CALLERID(num)})})
    exten => cidlookup_5,n,Return()
    exten => cidlookup_return,1,LookupCIDName
    exten => cidlookup_return,n,Return()

    In my case, as the number does not exists in the Internet phonebook, it continues with the CID number as CID name, means "CID name" is the CID number.

    IMO, as the CID name was delivered with the SIP info, the cidlookup script should use this info
    and ignore the script to find the CID name in the Internet.

    So the cidlookup script should do like this :
    Identify if the incoming call delivers a CID name (letters, no numbers).
    If yes, it should use this info.
    If no, it should do an Internet phonebook lookup with the CID number to get the CID name.
    Else, continue with/without the information.


    If I can fix this problem, cidlookup with SUPERFECTA will work perfectly !!!

    As I do not know much about programming/modifying the extensions script, maybe somebody can kindly help ;-)


    Thanks in advance

    Harry

    PS: without cidlookup, it shows correctly the name
     
  2. Patrick_elx

    Joined:
    Dec 14, 2008
    Messages:
    1,120
    Likes Received:
    0
    did you put the lookup source 'trunk provided' before the other ones? If your trunk provided a CID that is not one of the keyword defined in the 'trunk provided' lookup source options, it will stop the search and keep it for your extensions.
     
  3. harryhirsch

    Joined:
    Apr 10, 2009
    Messages:
    24
    Likes Received:
    0
    Hi Patrick,

    Yes, I have even disabled all others. So only "Trunk-Provided" was enabled.

    I am searched in the source files, while I found maybe the source of the problem:
    With the source-Trunk_Provided.php, Superfecta should get the "Caller ID Name" from asteriskCLI Interface.
    IMO here is the "problem".

    I traced Asterisk Manager and Asterisk CLI at the same time as I called in.
    In AsteriskCLI, after I saw the incoming all, I entered "core show channels concise" to find the current channel name and then I entered "core show channel <channel name>".

    After the call, I compared the AsteriskManager log with the AsteriskCLI Log.
    In the AsteriskCLI log I found the Info "Caller ID Name" but it showed me the CID instead of the name :

    Elastix*CLI> core show channel SIP/5059-08cfd2d0
    -- General --
    Name: SIP/5059-08cfd2d0
    Type: SIP
    UniqueID: 1251284416.8
    Caller ID: 33486688802
    Caller ID Name: 33486688802
    DNID Digits: 33811915784
    State: Ring (4)
    Rings: 0
    NativeFormats: 0x4 (ulaw)
    WriteFormat: 0x4 (ulaw)
    ReadFormat: 0x4 (ulaw)
    WriteTranscode: No
    ReadTranscode: No
    1st File Descriptor: 26
    Frames in: 0
    Frames out: 0
    Time to Hangup: 0
    Elapsed Time: 0h0m12s
    Direct Bridge: <none>
    Indirect Bridge: <none>
    -- PBX --
    Context: macro-dial
    Extension: s
    Priority: 7
    Call Group: 0
    Pickup Group: 0
    Application: Dial
    Data: SIP/200||tr
    Blocking in: ast_waitfor_nandfds
    Variables:
    ...

    But in the AsteriskManager, I found with same channel name the correct/wished Info :

    Event: Newchannel
    Privilege: call,all
    Channel: SIP/5059-08d00900
    State: Down
    CallerIDNum: 33486688802
    CallerIDName: HARRY
    Uniqueid: 1251290340.16

    Event: Newstate
    Privilege: call,all
    Channel: SIP/5059-08d00900
    State: Ring
    CallerID: 33486688802
    CallerIDName: HARRY
    Uniqueid: 1251290340.16
    ...

    It will be better that the source-Trunk_Provided.php should look in the Asterisk Manager and pickup the "Event: Newchannel" info, as these infos are not modified by the macros.
    But as it starts quit late after a call came in, maybe these infos are already "gone".


    IMO, the cidlookup script overwrites the Asterisk Manager info and then it shows in AsteriskCLI
    "core show channel <channel name>" the CID number instead of the name.
    Thats why the source-Trunk_Provided.php do not show the name.

    So thats why I am searching for a workaround.
    If the CID name is already present, it should NOT jump into the cidlookup script.
    Or the cidlookup script do this verification before it checks the Internet Ponebook.
    So the delivered CID name will be not overwritten, source-Trunk_Provided.php can find and forward the name to Superfecta. All will be be OK.


    What is your opinion ?
    How can I fix it ?


    Thanks in advance

    Harry
     
  4. harryhirsch

    Joined:
    Apr 10, 2009
    Messages:
    24
    Likes Received:
    0
    I tried another thing to see where the CID name was replaced.
    So I added in the extensions_additional.conf some lines to check :

    [ext-did-0002]
    exten => 33811915784,1,Set(__FROM_DID=${EXTEN})
    exten => 33811915784,n,Gosub(app-blacklist-check,s,1)
    exten => 33811915784,n,Noop(Show CallerID Name ${CALLERID(name)})
    exten => 33811915784,n,Gosub(cidlookup,cidlookup_5,1)
    exten => 33811915784,n,Noop(Show CallerID Name ${CALLERID(name)})
    exten => 33811915784,n,ExecIf($[ "${CALLERID(name)}" = "" ] ,Set,CALLERID(name)=${CALLERID(num)})
    exten => 33811915784,n,Set(__CALLINGPRES_SV=${CALLINGPRES_${CALLINGPRES}})
    exten => 33811915784,n,SetCallerPres(allowed_not_screened)
    exten => 33811915784,n,Goto(from-did-direct,200,1)


    In the log you can see that the cidlookup replaced the CID name which was found before,
    by "nothing", as it did not found an entry in the Internet phonebook :


    -- Executing [33811915784@from-trunk:1] Set("SIP/5059-084169b8", "__FROM_DID=33811915784" ) in new stack
    -- Executing [33811915784@from-trunk:2] Gosub("SIP/5059-084169b8", "app-blacklist-check|s|1" ) in new stack
    -- Executing [s@app-blacklist-check:1] LookupBlacklist("SIP/5059-084169b8", "" ) in new stack
    -- Executing [s@app-blacklist-check:2] GotoIf("SIP/5059-084169b8", "0?blacklisted" ) in new stack
    -- Executing [s@app-blacklist-check:3] Return("SIP/5059-084169b8", "" ) in new stack
    -- Executing [33811915784@from-trunk:3] NoOp("SIP/5059-084169b8", "Show CallerID Name HARRY" ) in new stack
    -- Executing [33811915784@from-trunk:4] Gosub("SIP/5059-084169b8", "cidlookup|cidlookup_5|1" ) in new stack
    -- Executing [cidlookup_5@cidlookup:1] Set("SIP/5059-084169b8", "CALLERID(name)=" ) in new stack
    -- Executing [cidlookup_5@cidlookup:2] Return("SIP/5059-084169b8", "" ) in new stack
    -- Executing [33811915784@from-trunk:5] NoOp("SIP/5059-084169b8", "Show CallerID Name " ) in new stack
    -- Executing [33811915784@from-trunk:6] ExecIf("SIP/5059-084169b8", "1 |Set|CALLERID(name)=33486688802" ) in new stack
    -- Executing [33811915784@from-trunk:7] Set("SIP/5059-084169b8", "__CALLINGPRES_SV=allowed_not_screened" ) in new stack
    -- Executing [33811915784@from-trunk:8] SetCallerPres("SIP/5059-084169b8", "allowed_not_screened" ) in new stack
    -- Executing [33811915784@from-trunk:9] Goto("SIP/5059-084169b8", "from-did-direct|200|1" ) in new stack
    -- Goto (from-did-direct,200,1)


    I think I need a script line which verifies if a CID name was found,
    - if yes it should jump over the cidlookup line
    - if no it should do the cidlookup


    Thanks


    Harry
     
  5. harryhirsch

    Joined:
    Apr 10, 2009
    Messages:
    24
    Likes Received:
    0
    Hi

    I tried to enter this line :

    [ext-did-0002]
    ...
    exten => 33811915784,n,Gosub(app-blacklist-check,s,1)
    exten => 33811915784,n,Noop(Show CallerID Name ${CALLERID(name)})
    exten => 33811915784,n,GotoIf($["${CALLERID(name)}" = " " ]?namefound)
    exten => 33811915784,n,Gosub(cidlookup,cidlookup_5,1)
    exten => 33811915784,n(namefound),Noop(Show CallerID Name ${CALLERID(name)})
    exten => 33811915784,n,ExecIf($[ "${CALLERID(name)}" = "" ] ,Set,CALLERID(name)=${CALLERID(num)})
    ...

    But it seem that the result was not found :

    -- Executing [33811915784@from-trunk:1] Set("SIP/5059-b7606858", "__FROM_DID=33811915784" ) in new stack
    -- Executing [33811915784@from-trunk:2] Gosub("SIP/5059-b7606858", "app-blacklist-check|s|1" ) in new stack
    -- Executing [s@app-blacklist-check:1] LookupBlacklist("SIP/5059-b7606858", "" ) in new stack
    -- Executing [s@app-blacklist-check:2] GotoIf("SIP/5059-b7606858", "0?blacklisted" ) in new stack
    -- Executing [s@app-blacklist-check:3] Return("SIP/5059-b7606858", "" ) in new stack
    -- Executing [33811915784@from-trunk:3] NoOp("SIP/5059-b7606858", "Show CallerID Name HARRY" ) in new stack
    -- Executing [33811915784@from-trunk:4] GotoIf("SIP/5059-b7606858", "0?namefound" ) in new stack
    -- Executing [33811915784@from-trunk:5] Gosub("SIP/5059-b7606858", "cidlookup|cidlookup_5|1" ) in new stack
    -- Executing [cidlookup_5@cidlookup:1] Set("SIP/5059-b7606858", "CALLERID(name)=" ) in new stack
    -- Executing [cidlookup_5@cidlookup:2] Return("SIP/5059-b7606858", "" ) in new stack
    -- Executing [33811915784@from-trunk:6] NoOp("SIP/5059-b7606858", "Show CallerID Name " ) in new stack
    -- Executing [33811915784@from-trunk:7] ExecIf("SIP/5059-b7606858", "1 |Set|CALLERID(name)=33486688802" ) in new stack
    -- Executing [33811915784@from-trunk:8] Set("SIP/5059-b7606858", "__CALLINGPRES_SV=allowed_not_screened" ) in new stack
    -- Executing [33811915784@from-trunk:9] SetCallerPres("SIP/5059-b7606858", "allowed_not_screened" ) in new stack
    -- Executing [33811915784@from-trunk:10] Goto("SIP/5059-b7606858", "from-did-direct|200|1" ) in new stack
    -- Goto (from-did-direct,200,1)


    Something do not work like it should :-(
    The result "?namefound" value should be "1" when a CID name(=text) was found !?

    exten => 33811915784,n,GotoIf($["${CALLERID(name)}" = " " ]?namefound)

    What is wrong with my line ?


    Or maybe there is another way to tell, when a text will be found in the CALLERID(name), it should jump over the cidlookup line.

    Thanks for your help


    Harry
     
  6. Patrick_elx

    Joined:
    Dec 14, 2008
    Messages:
    1,120
    Likes Received:
    0
    GotoIf(condition?label1[:label2])

    Go to label1 if condition is true or to next step (or label2 if defined) if condition is false

    then if your caller id is " " it will go to namefound...

    In your case callerid is "Harry", the condition is then false (0) then goes to the next line...

    You should change your gotoif with:
    exten => 33811915784,n,GotoIf($["${CALLERID(name)}" = "" ]?:namefound)
     
  7. harryhirsch

    Joined:
    Apr 10, 2009
    Messages:
    24
    Likes Received:
    0
    Hi Patrick,

    That was one step forward - thank you !
    There is only one little problem open.

    Here my results...

    ...with CID name in SIP Info :

    -- Executing [s@from-sip-external:1] GotoIf("SIP/5059-08576c18", "1?from-trunk|33811915784|1" ) in new stack
    -- Goto (from-trunk,33811915784,1)
    -- Executing [33811915784@from-trunk:1] Set("SIP/5059-08576c18", "__FROM_DID=33811915784" ) in new stack
    -- Executing [33811915784@from-trunk:2] Gosub("SIP/5059-08576c18", "app-blacklist-check|s|1" ) in new stack
    -- Executing [s@app-blacklist-check:1] LookupBlacklist("SIP/5059-08576c18", "" ) in new stack
    -- Executing [s@app-blacklist-check:2] GotoIf("SIP/5059-08576c18", "0?blacklisted" ) in new stack
    -- Executing [s@app-blacklist-check:3] Return("SIP/5059-08576c18", "" ) in new stack
    -- Executing [33811915784@from-trunk:3] NoOp("SIP/5059-08576c18", "Show CallerID Name HARRY" ) in new stack
    -- Executing [33811915784@from-trunk:4] GotoIf("SIP/5059-08576c18", "0?:namefound" ) in new stack
    -- Goto (from-trunk,33811915784,6)
    -- Executing [33811915784@from-trunk:6] NoOp("SIP/5059-08576c18", "Show CallerID Name HARRY" ) in new stack
    -- Executing [33811915784@from-trunk:7] ExecIf("SIP/5059-08576c18", "0 |Set|CALLERID(name)=33486688802" ) in new stack
    -- Executing [33811915784@from-trunk:8] Set("SIP/5059-08576c18", "__CALLINGPRES_SV=allowed_not_screened" ) in new stack
    -- Executing [33811915784@from-trunk:9] SetCallerPres("SIP/5059-08576c18", "allowed_not_screened" ) in new stack
    -- Executing [33811915784@from-trunk:10] Goto("SIP/5059-08576c18", "from-did-direct|200|1" ) in new stack
    -- Goto (from-did-direct,200,1)


    ...without CID name, only the number :

    -- Executing [s@from-sip-external:1] GotoIf("SIP/5059-085c12c0", "1?from-trunk|33811915784|1" ) in new stack
    -- Goto (from-trunk,33811915784,1)
    -- Executing [33811915784@from-trunk:1] Set("SIP/5059-085c12c0", "__FROM_DID=33811915784" ) in new stack
    -- Executing [33811915784@from-trunk:2] Gosub("SIP/5059-085c12c0", "app-blacklist-check|s|1" ) in new stack
    -- Executing [s@app-blacklist-check:1] LookupBlacklist("SIP/5059-085c12c0", "" ) in new stack
    -- Executing [s@app-blacklist-check:2] GotoIf("SIP/5059-085c12c0", "0?blacklisted" ) in new stack
    -- Executing [s@app-blacklist-check:3] Return("SIP/5059-085c12c0", "" ) in new stack
    -- Executing [33811915784@from-trunk:3] NoOp("SIP/5059-085c12c0", "Show CallerID Name +33915912547" ) in new stack
    -- Executing [33811915784@from-trunk:4] GotoIf("SIP/5059-085c12c0", "0?:namefound" ) in new stack
    -- Goto (from-trunk,33811915784,6)
    -- Executing [33811915784@from-trunk:6] NoOp("SIP/5059-085c12c0", "Show CallerID Name +33915912547" ) in new stack
    -- Executing [33811915784@from-trunk:7] ExecIf("SIP/5059-085c12c0", "0 |Set|CALLERID(name)=33915912547" ) in new stack
    -- Executing [33811915784@from-trunk:8] Set("SIP/5059-085c12c0", "__CALLINGPRES_SV=allowed_not_screened" ) in new stack
    -- Executing [33811915784@from-trunk:9] SetCallerPres("SIP/5059-085c12c0", "allowed_not_screened" ) in new stack
    -- Executing [33811915784@from-trunk:10] Goto("SIP/5059-085c12c0", "from-did-direct|200|1" ) in new stack
    -- Goto (from-did-direct,200,1)


    In both cases it jumped directly to "namefound" because the result value was "0".

    How can I tell the script, that the value should be "1" when their are digits or "+" in the CallerID(name) field ?

    I think thats the reason why it did not work.
    Please help me.



    Bye

    Harry
     
  8. harryhirsch

    Joined:
    Apr 10, 2009
    Messages:
    24
    Likes Received:
    0
    Hi,

    After studding some docs about "Asterisk Expressions", maybe I found a way to get my wished result :

    Here my strings :
    ...
    exten => 33811915784,n,Set(compare=$["${CALLERID(name)}" : "([0-9+]+)"])
    exten => 33811915784,n,GotoIf($["${CALLERID(name)}" = "${compare}" ]?namenotfound:namefound)
    exten => 33811915784,n(namenotfound),Gosub(cidlookup,cidlookup_5,1)
    exten => 33811915784,n(namefound),Noop(Show CallerID Name ${CALLERID(name)})
    ...


    With the "Set" I created an output value (=compare) which is the result of comparison between the {CALLERID(name)} and the digits 0-9,"+" .
    In the case a caller did not send his CID name but his CID number, the result is his CID number.
    If the CID name is shown with letters, then it nothing.

    The second line, I compared the results of the CALLERID(name) with the "compare" value.
    If its false, it jumps to namefound
    If its true, it jumps to namenotfound.


    Here the traces :
    without CID name in call :

    -- Executing [33811951784@from-sip-external:1] NoOp("SIP/5059-b7506dc0", "Received incoming SIP connection from unknown peer to 33811951784" ) in new stack
    -- Executing [33811951784@from-sip-external:2] Set("SIP/5059-b7506dc0", "DID=33811951784" ) in new stack
    -- Executing [33811951784@from-sip-external:3] Goto("SIP/5059-b7506dc0", "s|1" ) in new stack
    -- Goto (from-sip-external,s,1)
    -- Executing [s@from-sip-external:1] GotoIf("SIP/5059-b7506dc0", "1?from-trunk|33811951784|1" ) in new stack
    -- Goto (from-trunk,33811951784,1)
    -- Executing [33811951784@from-trunk:1] Set("SIP/5059-b7506dc0", "__FROM_DID=33811951784" ) in new stack
    -- Executing [33811951784@from-trunk:2] Gosub("SIP/5059-b7506dc0", "app-blacklist-check|s|1" ) in new stack
    -- Executing [s@app-blacklist-check:1] LookupBlacklist("SIP/5059-b7506dc0", "" ) in new stack
    -- Executing [s@app-blacklist-check:2] GotoIf("SIP/5059-b7506dc0", "0?blacklisted" ) in new stack
    -- Executing [s@app-blacklist-check:3] Return("SIP/5059-b7506dc0", "" ) in new stack
    -- Executing [33811951784@from-trunk:3] NoOp("SIP/5059-b7506dc0", "Show CallerID Name +33951915247" ) in new stack
    -- Executing [33811951784@from-trunk:4] Set("SIP/5059-b7506dc0", "compare=+33951915247" ) in new stack
    -- Executing [33811951784@from-trunk:5] NoOp("SIP/5059-b7506dc0", "Show compare+33951915247" ) in new stack
    -- Executing [33811951784@from-trunk:6] GotoIf("SIP/5059-b7506dc0", "1?namenotfound:namefound" ) in new stack
    -- Goto (from-trunk,33811951784,8)
    -- Executing [33811951784@from-trunk:8] Gosub("SIP/5059-b7506dc0", "cidlookup|cidlookup_5|1" ) in new stack
    -- Executing [cidlookup_5@cidlookup:1] Set("SIP/5059-b7506dc0", "CALLERID(name)= MY NAME" ) in new stack

    With CID name in call :

    -- Executing [33811951784@from-sip-external:1] NoOp("SIP/5059-b7505798", "Received incoming SIP connection from unknown peer to 33811951784" ) in new stack
    -- Executing [33811951784@from-sip-external:2] Set("SIP/5059-b7505798", "DID=33811951784" ) in new stack
    -- Executing [33811951784@from-sip-external:3] Goto("SIP/5059-b7505798", "s|1" ) in new stack
    -- Goto (from-sip-external,s,1)
    -- Executing [s@from-sip-external:1] GotoIf("SIP/5059-b7505798", "1?from-trunk|33811951784|1" ) in new stack
    -- Goto (from-trunk,33811951784,1)
    -- Executing [33811951784@from-trunk:1] Set("SIP/5059-b7505798", "__FROM_DID=33811951784" ) in new stack
    -- Executing [33811951784@from-trunk:2] Gosub("SIP/5059-b7505798", "app-blacklist-check|s|1" ) in new stack
    -- Executing [s@app-blacklist-check:1] LookupBlacklist("SIP/5059-b7505798", "" ) in new stack
    -- Executing [s@app-blacklist-check:2] GotoIf("SIP/5059-b7505798", "0?blacklisted" ) in new stack
    -- Executing [s@app-blacklist-check:3] Return("SIP/5059-b7505798", "" ) in new stack
    -- Executing [33811951784@from-trunk:3] NoOp("SIP/5059-b7505798", "Show CallerID Name HARRY" ) in new stack
    -- Executing [33811951784@from-trunk:4] Set("SIP/5059-b7505798", "compare=" ) in new stack
    -- Executing [33811951784@from-trunk:5] NoOp("SIP/5059-b7505798", "Show compare" ) in new stack
    -- Executing [33811951784@from-trunk:6] GotoIf("SIP/5059-b7505798", "0?namenotfound:namefound" ) in new stack
    -- Goto (from-trunk,33811951784,9)
    -- Executing [33811951784@from-trunk:9] NoOp("SIP/5059-b7505798", "Show CallerID Name HARRY" ) in new stack
    -- Executing [33811951784@from-trunk:10] ExecIf("SIP/5059-b7505798", "0 |Set|CALLERID(name)=33486688802" ) in new stack
    -- Executing [33811951784@from-trunk:11] Set("SIP/5059-b7505798", "__CALLINGPRES_SV=allowed_not_screened" ) in new stack
    -- Executing [33811951784@from-trunk:12] SetCallerPres("SIP/5059-b7505798", "allowed_not_screened" ) in new stack
    -- Executing [33811951784@from-trunk:13] Goto("SIP/5059-b7505798", "from-did-direct|200|1" ) in new stack
    -- Goto (from-did-direct,200,1)



    Is my script ok and/or can I simplify it ?


    Thanks in advance


    Harry
     

Share This Page