How to replace caller name by curl website tel.search.ch

Description

tel.search.ch is a website that holds public telephone numbers and their corresponding names. If a call comes into your phone system from a public organization, you may want to know what the exact name of the caller is, this article will guide you how to use curl command to achieve this requirement.

 

Applicable Device

Model: P-Series IPPBX

Firmware: Not Required

 

Dialplan Code

[DLPN_trunk_XXXX]
exten = h,1,HangUp()
exten = _.,1,Set(CHANNEL(language)=${PLAYLANGUAGE})
exten = _.,2,NoOp(WHATEVER)
exten = _.,3,Set(CDR(srcname)=${CALLERID(name)})
exten = _.,4,Set(CDR(userfield)=Inbound)
exten = _.,5,Set(REALCALLERNUM=${CALLERID(num)})
exten = _.,6,Set(DSCIDORIGNAME=${CALLERID(name)})
exten = _.,7,YsWalkContext(whitelist-inbound,${EXTEN},1,${CALLERID(num)},inbound)
exten = _.,8,Set(GROUP(trunk-XXXX-endpoint)=trunk-XXXX-endpoint)
exten = _.,9,ExecIf($[${LEN(${CUSTOM_VAR(trunk-XXXX-endpoint_LIMIT)})}>0]?Gotoif($[${GROUP_COUNT(trunk-XXXX-endpoint)} > ${CUSTOM_VAR(trunk-XXXX-endpoint_LIMIT)}]?h,1))
exten = _.,10,Set(FAXOPT(gateway)=no)
exten = _.,11,Set(TMPNAME=${SHELL(curl -k https://tel.search.ch/api/?was=${CALLERID(num)}&key=******)})
exten = _.,12,System(touch /ysdisk/support/tmp/tmpname.txt)
exten = _.,13,System(echo '${TMPNAME}' > /ysdisk/support/tmp/tmpname.txt)
exten = _.,14,Wait(1)
exten = _.,15,Set(CALLERID(name)=${SHELL(awk '/<title type=\"text\">/,/<\/title>/ {print $0}' /ysdisk/support/tmp/tmpname.txt | awk -v FS="<title type=\"text\">" -v OFS=" " '{print $2}' | awk -v FS="<\/title>" -v OFS=" " '{print $1}' | sed -n '2p')})
exten = _.,16,GotoIf(${CALLERID(name)}?+1:+3)
exten = _.,17,Set(CDR(srcname)=${CALLERID(name)})
exten = _.,18,Set(DSCIDORIGNAME=${CALLERID(name)})
exten = _.,19,System(rm -r /ysdisk/support/tmp/tmpname.txt)
exten = _.,20,Noop(do nothing)
exten = _.,21,UserEvent(UpdateCaller,CallerNumber: ${CALLERID(num)})
exten = _.,22,ContsInit(${CALLERID(num)})
exten = _.,23,ContsMatchExtMobile()
exten = _.,n,Goto(inbound_trunk_XXXX,${EXTEN},1)

 

Attention and Steps

1, In above dialplan code, you have to replace XXXX with exact trunk name, replace ****** with your API key from tel.search.ch.

2, Access ssh of pbx, search '[DLPN_trunk_XXXX]' in /etc/asterisk/extensions.conf, copy the context under [DLPN_trunk_XXXX] and paste to file in path /ysdisk/support/tmp/extensions_support.conf.

3, Do not copy above dialplan to extensions_support.conf file directly, it's high possible different from your pbx.

4, Add above bold and italic dialplan to correct location in extensions_support.conf file.

5, Create any extension in web interface and delete it again, click on 'Apply'.

6, Test call.

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.