2

When placing outgoing external call using SIP client Bria. The phone displays our caller ID as the name of our calling party. Looking over the log, it shows that it came from this line

-- Executing [s@macro-dialout-trunk:21] ExecIf("SIP/100-0000004a", "1?Set(CONNECTEDLINE(name,i)=CID:2120000000)”) in new stack

How can we set up our system so that it queries CNAM or internal databases to display the actual name of the business or person we are calling?

Any help would be appreciated.

Joe2265
  • 21
  • 1
  • 4

1 Answers1

0

You can do it, but the way I see it will require some asterisk scripting skills, and the CNAM database of course.

You could override the original macro-dialout-trunk and modify it so that it queries the CNAM or internal databases. To override an existing dialplan context, you need to put your code into /etc/asterisk/extensions_override_freepbx.conf. You'll need to copy the entire modified [macro-dialout-trunk] context into this file.

Example:

...
exten => s,n(gocall),Macro(dialout-trunk-predial-hook,)
exten => s,n,GotoIf($["${PREDIAL_HOOK_RET}" = "BYPASS"]?bypass,1)
exten => s,n,ExecIf($["${DB(AMPUSER/${AMPUSER}/cidname)}" != ""]?Set(CONNECTEDLINE(num,i)=${DIAL_NUMBER}))
;;; This is the line that puts caller ID as the name of the calling party
exten => s,n,ExecIf($[$["${DB(AMPUSER/${AMPUSER}/cidname)}" != ""] & $["${CALLERID(name)}"!="hidden"]]?Set(CONNECTEDLINE(name,i)=CID:${CALLERID(number)}))
exten => s,n,ExecIf($[$["${DB(AMPUSER/${AMPUSER}/cidname)}" != ""] & $["${CALLERID(name)}"="hidden"]]?Set(CONNECTEDLINE(name,i)=CID:(Hidden)${CALLERID(number)}))
exten => s,n,GotoIf($["${custom}" = "AMP"]?customtrunk)
exten => s,n,Dial(${OUT_${DIAL_TRUNK}}/${OUTNUM}${OUT_${DIAL_TRUNK}_SUFFIX},${TRUNK_RING_TIMER},${DIAL_TRUNK_OPTIONS})
...

You could add or modify the lines to the [macro-dialout-trunk] to query your desired database, something like this:

...
exten => s,n,AGI(iWantTheNameOfThisCompany.agi,${OUTNUM})
exten => s,n,Set(CONNECTEDLINE(name,i)=${awesomeCompanyName})
...

Asterisk will run the iWantTheNameOfThisCompany.agi AGI script, passing the dialed number as argument. The script then could set the ${awesomeCompanyName} variable user in the function CONNECTEDLINE. You can use Perl, PHP, C, Pascal, Bourne Shell - for your query AGI script. it's your choice, really.