CUCM – Displaying Caller Name for External Inbound Calls

So one of the annoying things with Call Manager is you can’t really seem to easily manipulate the calling name for inbound calls, or at least recognise a known number and manipulate based on that.

So for example, an inbound call to a DDI comes from a company owned mobile number, which is referenced in the directory as part of a users profile. Call Manager seems to ignore the fact it is in the directory and just presents the number rather than the users name.

After lots of searching round it only seems to be possible on the CUBE via TCL script. I found a really useful post here which forms the basis of the script:

There is also someone on those forums selling a script which probably does a much better job than this but I rather have something freely available so thought I would publish the alterations I made. This has been working in production for a number of months now and has worked really well so far.

All you need to do is register this as an application on the cube and add in the numbers you want to recognise within the switch statement.

I have added about 15 of these so far. Future iterations of this will hopefully pull this info from a file system or LDAP query. The concern is, the more work this script does, the more delay is added to the inbound call.

Anyway script attached:

proc init {} {
global param
global dnis
global dn
global ani
global ani_pi
global requested_cnam
global found_name


proc act_Setup {} {
global dnis

leg setupack leg_incoming

set ani [infotag get leg_username]
set cid_original [infotag get leg_display_info]

puts "\n Calling Number is $ani"
set ani_pi [infotag get leg_ani_pi]
puts "\n Presentation Status: $ani_pi"

lookup_name "$ani"

proc lookup_name {number} {

switch $number {

puts "\n\n\n User 1's Phone has called in"
set found_name "User 1"
act_CID_DID "$found_name"

puts "\n\n\n User 2's Mobile has called in"
set found_name "User 2"
act_CID_DID "$found_name"

default {
puts "\n\n\nNo number found "
act_CID_DID ""

proc act_CID_DID {CNAM} {

set dnis [infotag get leg_dnis]
set dest [regexp {(\d+)} $dnis whole dest_num]
set ani [infotag get leg_username]
set cid_current [infotag get leg_display_info leg_incoming]

switch $CNAM {
"" {
puts "\n No CNAM specified so it will be set to the calling number, $cid_current"
set CNAM "$cid_current"
" " {
puts "\n No CNAM specified so it will be set to the calling number, $cid_current"
set CNAM "$cid_current"
default {
puts "\n The CNAM is $CNAM"

puts "\n CLID is $ani"
puts "\n DNIS is $dnis"
puts "\n Destination is $dest_num"

place_call "$dest_num" "$CNAM" "$ani"

proc place_call {called_num caller_name CLID } {
# Gather SIP header information
set From_Header [infotag get leg_proto_headers "From"]

set SIP_From [regexp {.*(<sip:.+@.+)} $From_Header whole_string 2nd_Section] puts "\n\n\n\n" puts "$SIP_From" puts "\n\n\n" puts "$From_Header" puts "\n The second half of the SIP From Header is $2nd_Section" puts "\n Updating the SIP From field to include the caller name, \"$caller_name\"" if {$caller_name != ""} { set SIP_String "\"$caller_name\" " } append SIP_String $2nd_Section puts "\n SIP From Header is modified to be $SIP_String" # Set CNAM Information set callInfo(displayInfo) "$caller_name" set callInfo(originationNum) "$CLID" set headers(From) $SIP_String set callInfo(protoHeaders) headers set param(name) "$caller_name" set param(number) "$called_num" leg callerid leg_incoming param # Insert a brief pause before continuing.... timer start leg_time 4 leg_incoming # Place the call puts "\n Ring, Ring... Incoming call from $caller_name" leg proceeding leg_incoming leg setup "$called_num" callInfo leg_incoming } proc act_CallSetupDone {} { set status [infotag get evt_status] puts "\n Call Status is $status" if {$status == "ls_000"} { puts "\n Call was successful" } else { puts "\n There was an error in connecting the call" call close } } proc act_Ignore {} { # Procedure to ignore events puts "Ignore this here --> IGNORE"

proc act_Cleanup {} {
puts "Entering act_Cleanup"
call close


# State Machine
set TopFSM(any_state,ev_disconnected) "act_Cleanup,same_state"
set TopFSM(CALL_INIT,ev_setup_indication) "act_Setup,PLACECALL"
set TopFSM(PLACECALL,ev_leg_timer) "act_Ignore,same_state"
set TopFSM(PLACECALL,ev_setup_done) "act_CallSetupDone,CALLACTIVE"
#set TopFSM(CALLACTIVE,ev_setup_done) "act_Ignore,same_state"
set TopFSM(CALLACTIVE,ev_disconnected) "act_Cleanup,CALLDISCONNECT"
set TopFSM(CALLDISCONNECT,ev_disconnect_done) "act_Cleanup,same_state"

fsm define TopFSM CALL_INIT


Register this as an application and apply it to the relevant dial-peers you want to manipulate:

conf t
application service service_name flash:/script_name.tcl

dial-peer voice 10 voip
service service_name

Leave a Reply

Your email address will not be published. Required fields are marked *