28 posts / 0 new
Last post
jesperkjeldsen
jesperkjeldsen's picture
Joined: 2009/01/12
Points: 0

In FreePBX there is an option to make Caller ID lookup from an URL. That would be really nice feature :-)

If someone has a script and can point me in the right direction I will try make it possible - I already have an URL I can look up Danish numbers so im just waiting ;-)

The URL is something like http://callerid.kjeldsen.it/phonenumer=12345678 and it then returns a name and no more - simple :-)

Regards
Jesper

cbbs70a
cbbs70a's picture
Joined: 2008/04/10
Points: 0

You mean the Thirdlane feature under CRM Links/CRM Settings?
FSD

eeman
eeman's picture
Joined: 2007/11/06
Points: 260

I think he's looking for a means to do a CNAM lookup and populate CALLERID(name) without paying for the service from his carrier

Erik Smith
dCAP
Thirdlane/Asterisk Support available
esmith.bgnv@gmail.com

cbbs70a
cbbs70a's picture
Joined: 2008/04/10
Points: 0

Gotcha. On a similiar note, I'm trying to get screen pop ups to work with VTiger. It seems that VTiger wants the URL to have a record number to search for, not a phone number. I do not have a solution for that yet. EEman, how exactly do the screen pop ups work? It's certainly nothing in the dial plan that I can see. Any insight at all would be greatly appreciated.
Frank

eeman
eeman's picture
Joined: 2007/11/06
Points: 260

wait, is it STE or MTE? and is this the new vtiger?

the new vtiger makes an AMI connection that will do its own popup in vtiger, it will also let you call from the contact. IT only works with STE, those dash-tenant entries mess it up entirely.

Erik Smith
dCAP
Thirdlane/Asterisk Support available
esmith.bgnv@gmail.com

cbbs70a
cbbs70a's picture
Joined: 2008/04/10
Points: 0

I'm working with STE and the new VTiger, but in general, I have no idea how the pop ups work.
Thanks
FSD

jesperkjeldsen
jesperkjeldsen's picture
Joined: 2009/01/12
Points: 0

Yes, I wanne do a CNAM lookup and populate CALLERID(name).
My carrier doesn't have that services so I am actually bying it somwhere else (XML lookup and output the name). So I pay for - just not at my carrier ;-)

Regards
Jesper

eeman
eeman's picture
Joined: 2007/11/06
Points: 260

i have some AGI code that uses curl to do the lookup and then returns the value. It would require modification to parse data returned by your site as opposed to other sites i've written it for. It even cache's into mysql to curb expenses.

Erik Smith
dCAP
Thirdlane/Asterisk Support available
esmith.bgnv@gmail.com

jesperkjeldsen
jesperkjeldsen's picture
Joined: 2009/01/12
Points: 0

Hi Erik
You are welcome to send it to me if you want ;-)
You can reach me at jesper (the funny a) kjeldsen.it :-)

If I suceed to get it to work (at some time I will) - I will of course share it.

Regards
Jesper

jesperkjeldsen
jesperkjeldsen's picture
Joined: 2009/01/12
Points: 0

I've been working on this for some days, but I just can't get over the last problem.
From extensions.conf I run the AGI script with one argument. If I put in a phone-numer directly it works, but now then I use variables.
What have I done wrong?

From extensions.conf:
[from-outside]
exten => _X.,1,Wait(1)
exten => _X.,2,AGI(kit-lookup1.agi|${CALLERID(num)})
exten => _X.,3,Set(CALLERID(name)=${lookupname})
exten => _X.,n,Set(__INCOMINGCLI=${CALLERID(num)})
exten => _X.,n,Goto(from-outside-redir,${EXTEN},1)

And the kit-lookup1.agi looks like this:
#!/bin/sh
name=`curl http://url-to-the-server/?phone=${1}`
echo "SET VARIABLE lookupname \"$name\""

I know I need a lot of security to ensure there isn't any "bad" chars and so on, but for testing I like to keep it as simple as possible ;-)

eeman
eeman's picture
Joined: 2007/11/06
Points: 260

well that pipe is going to be a problem if its 1.6 based.

Erik Smith
dCAP
Thirdlane/Asterisk Support available
esmith.bgnv@gmail.com

eeman
eeman's picture
Joined: 2007/11/06
Points: 260

add a NoOp to see if the $lookupname even makes it back to asterisk.

Erik Smith
dCAP
Thirdlane/Asterisk Support available
esmith.bgnv@gmail.com

jesperkjeldsen
jesperkjeldsen's picture
Joined: 2009/01/12
Points: 0

If I use exten => _X.,2,AGI(kit-lookup1.agi|96950000) I get the right "answer" (its our own phone number).
So $lookupname comes back to Asterisk, but its like ${CALLERID(num)} dosen't contain the number.

Sorry I forgot to say its Asterisk 1.4..

Regards
jesper

eeman
eeman's picture
Joined: 2007/11/06
Points: 260

well that is likely a problem with your carrier if they arent providing you callerid.

Erik Smith
dCAP
Thirdlane/Asterisk Support available
esmith.bgnv@gmail.com

jesperkjeldsen
jesperkjeldsen's picture
Joined: 2009/01/12
Points: 0

If I call from outside I get the callers number, so unless there more kinds of caller ids I must get it.

Regards
Jesper

eeman
eeman's picture
Joined: 2007/11/06
Points: 260

not possible.. if you get caller's number.. then CALLERID(num) is set. That IS what you are seeing... your callerid on your phone comes from the same internal value that CALLERID(num) reads. what sort of line is this?

Erik Smith
dCAP
Thirdlane/Asterisk Support available
esmith.bgnv@gmail.com

jesperkjeldsen
jesperkjeldsen's picture
Joined: 2009/01/12
Points: 0

I didn't went to bed, started working on this as the time right now is great for the restart of Asterisk every time I changes in extensions.conf :-)

I haven't changed a lot, but it works with this in extensions.conf:
[from-outside]
exten => _X.,1,Wait(1)
exten => _X.,n,Set(__INCOMINGCLI=${CALLERID(num)})
exten => _X.,n,AGI(kit-lookup1.agi|${CALLERID(num)})
exten => _X.,n,Set(CALLERID(name)=${lookupname})
exten => _X.,n,Goto(from-outside-redir,${EXTEN},1)

And the kit-lookup1.agi is still like this and placed in /var/lib/asterisk/agi-bin/:
#!/bin/sh
name=`curl http://url-to-the-server/?phone=${1}`
echo "SET VARIABLE lookupname \"$name\""

One question to that, in this way I will have to enabled it to all users (in this case it is an MTE) at one time. If I want to do it for a single tennant, isn't I right in that I will have to "enable" it in inbound.include og inbound_actions.include for every trunk?

Regards
Jesper

INTACS
INTACS's picture
Joined: 2010/07/17
Points: 0

Hello Erik

Can you email me also the lookup scripts

marvin AT intacs dot com

phoetger
phoetger's picture
Joined: 2010/11/09
Points: 0

I would like to get the lookup script as well...

phoetger AT nationsline dot com

Thank you

jesperkjeldsen
jesperkjeldsen's picture
Joined: 2009/01/12
Points: 0

Hi phoetger
You can see the scripts in my post from 03/09/10 :-)

Regards
Jesper

phoetger
phoetger's picture
Joined: 2010/11/09
Points: 0

jesperkjeldsen,

did you figure out how to do the caching of the CNAM?

We got CNAM to work with our provider ($0.006 per query), but we would like to implement caching to reduce the costs.

If you have an example, that would be great.

Thanks

jesperkjeldsen
jesperkjeldsen's picture
Joined: 2009/01/12
Points: 0

Hi again
To make a long story short, we had a programmer who did it in .NET but our phone-to-name provider change the structure so no I am working on a small PHP script that does the caching.
So in fact I make the lookup from Asterisk to an webserver that look up another webbased service :-)

When I have finshed I will try to remember to post the script here, but do not expext rocket-sciene :-)

Regards
Jesper

mattdarnell
mattdarnell's picture
Joined: 2007/10/25
Points: 20

phoetger,

Shouldn't be hard to put it in a mysql database. Asterisk could look to the database to see if there is an entry for that number before you do a lookup. The next level would keep track of when you did the lookup so you could expire old records - maybe every 12 months.

It would be interesting to see the database grow. I imagine it would level off fairly quickly.

-Matt

eeman
eeman's picture
Joined: 2007/11/06
Points: 260

you need to expire them a lot more frequently than 12months. believe me, you'll regret it if you dont. legally you're not suppose to cache them at all. There are 3 CNAM databases, depending on your service your provider will have access to 1 or all 3. ATT is one of the database maintainers. ATT has a clause that you cannot cache their lookups. Setting the cache too long will get you caught. ATT will randomly run checks. If one of their customers places a call to you, and their database records a lookup, and then later that same number is called from their network and there is no lookup they flag it for investigation. Ive heard rumor of them doing tricks like changing the CNAM entry to see if the data changes after buying service at a place like vonage.

then there is the issue that these actually _do_ change from time to time and having a bad entry will cause your customers to complain. I would make your record expire every 30 days. Right now I am only caching for 6 days, but thats still cutting my costs down on frequent calls by 85%. If they arent calling any more frequently than once a month then why go as far as 12mos thats only a 0.015 savings right?

Erik Smith
dCAP
Thirdlane/Asterisk Support available
esmith.bgnv@gmail.com

poliver
poliver's picture
Joined: 2011/07/07
Points: 0

Erik,
Migrating off our homegrown asterisk service to thirdlane. Our lookup uses a pipe to pass the callerid num to an agi script. I understand this will not work in 1.6. I would love to take a look at your code to solve this problem, as well as review your implementation of record aging. (We are caching with astdb with no aging.) Moving to mysql for caching with the aging capability would be great.

I can be contacted at poliver@fortistelecom.net

Best regards...

eeman
eeman's picture
Joined: 2007/11/06
Points: 260

show me your AGI statement

Erik Smith
dCAP
Thirdlane/Asterisk Support available
esmith.bgnv@gmail.com

poliver
poliver's picture
Joined: 2011/07/07
Points: 0

exten => s,31,AGI(lookupcidname.agi|${lcallerid})

eeman
eeman's picture
Joined: 2007/11/06
Points: 260

so you should be able to change it to

exten => s,31,AGI(lookupcidname.agi, ${lcallerid})

Erik Smith
dCAP
Thirdlane/Asterisk Support available
esmith.bgnv@gmail.com