Showing results for 
Search instead for 
Did you mean: 

Community Helping Community

A guide to SIP Normalization on CUCM and Lua Scripting

Cisco Employee


(view in My Videos)


I have recorded this guide for SIP Normalization on call manager and also have elaborated a little bit on how we use the Lua scripting.


A SIP Normalization script could really help the customer as a workaround or a permanent solution for issues related to calling and CLID.



Cisco TAC does NOT support SIP Normalization scripts. If the customer has already applied a script, TAC does NOT troubleshoot it. It is the customer's responsiblity to make it work.


i test this script but no Change


M = {}
function M.outbound_INVITE(msg)
 msg:modifyHeader("Contact", "2099006t0")

return M


for my understanding i cann only Change the From  

Question it is possible to Change the From


From: <sip:"SIPID"@>;tag=3535~14bb5db7-95a9-4db0-864a-a21a1f2e14ad-


Cisco Employee

If the script doesn't change the message, then you'll need to take the traces on the CUCM to see if the script got executed and hit some error.

You will need detailed CUCM traces for it.

Yes you can change the From.


function M.outbound_INVITE(msg)

    local from = msg:getHeader("From")

    local b = string.gsub(a, "(<sip:.+@)", "<sip:200xxt50@")

    msg:modifyHeader("From", b)


return M


Hi Thanks for your replay ! but i still have error


00226559.005 |20:28:49.629 |AlarmErr |AlarmClass: CallManager, AlarmName: SIPNormalizationScriptError, AlarmSeverity: Error, AlarmMessage: , AlarmDescription: A script error occurred, AlarmParameters: DeviceName:NS_SIP_TRUNK, ScriptName:sipgate, ScriptFunction:M.outbound_INVITE, ScriptType:Custom, ErrorCode:3, ErrorCodeText:Execution Error, ErrorMessage:sipgate at line 7: bad argument #1 to 'gsub' (string expected, got nil), ConfiguredAction:Rollback Only, ResultingAction:Rollback Only, InUseMemory:1306, MemoryThreshold:51200, InUseLuaInstructions:0, LuaInstructionThreshold:1000, AppID:Cisco CallManager, ClusterID:StandAloneCluster, NodeID:NS-CUCM,


Also both the INVITE line and the FROM field appear to be unchanged:


Cisco Employee

Thats because the string.gsub function is getting 'a' as the first argument. Change it to from, because that is the variable.

local b = string.gsub(from, "(<sip:.+@)", "<sip:200xxt50@")

hi just get the ISP

there are expecting this informations:





My CUCS is sending :

INVITE SIP/2.0   is ok

From: <sip:4921163558628806@>;tag=2044~14bb5db7-95a9-4db0-864a-a21a1f2e14ad-18282657  not ok

To: <>  is ok

we only have to Change the from Line


Hi Screekanth !

THANKS A LOT for your Help ! ! the Trunk is UP now ! i just have tu Setup the CUCM correctly to get the Phone working


Thanks Thanks

Cisco Employee

Great! Enjoy scripting further!

Hello, how can I Download the Video?



Cisco Employee

Hi Armin,

I don't think you can download this video unfortunately. Only the streaming option is allowed.




Hi Sreekanth,

Firstly.. the video was informative and provided a good insight on the subject. So thanks for the tutorial.

My query is: Is it possible to do a Ldap lookup in the script for replacing/ adding values to the "From" field based on the name associated with the number in the Ldap?

eg. If a number 4444 (a third party device not capable of forwarding caller id info - clid/cnid) is making a call to a cisco call manager cluster and the number 4444 is associated with the name "XXX" in LDAP, would it be possible to show XXX in the caller id instead of 4444?

Thanks in advance.

Cisco Employee

Hi Alan,


Thanks for your kind words. Glad it helped.

No, unfortunately, such API has not been provided by the developers. We cannot run functions that call the LDAP search and perform actions on the output.

You will need to figure out a pattern and then make changes based on "if" conditions in the script.



Hi Sreekanth,


I find this thread very useful, but i have a question, do you know if there is any recommendations for the Memory and LUA instructions thresholds? I assume it may be dependant on the load of the server or even on the size of the script.


Thanks in advance.


Carlos M. 

Cisco Employee

Hi Carlos,

No, there isn't any recommendation for memory and lua instruction thresholds.





Hi Mr Sreekanth,


Very good and informative video!!

I have the same requirement as posted below by Alan Baker. 

I know there are no functions that call the LDAP search and perform actions on the output.

Is there any workaround to that? I mean maybe i can save all my contacts in an external file and maybe perform a search there to map the usernames?

Please suggest something. There are around 14000 users!


Thanks in advance.



Cisco Employee

Hi Akshay,


Thanks for your kind words!

Unfortunately, no, we can't parse a file located on the CUCM and link that to the sip normalization script. The workaround would need to performed out of the scope of the normalization script.




CreatePlease to create content
Content for Community-Ad
FusionCharts will render here