Showing results for 
Search instead for 
Did you mean: 

Cisco Community Designated VIP Class of 2020

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.

Rising star

Very good video Sreekanth, Thanks for sharing it. It'd be nice if we could get those sample scripts you explained ;)

Cisco Employee

Thanks for your comment Suresh! It is easy to cook the scripts up. Which one were you looking for?

Rising star

I'm trying to modify the History-info to Diversion, tried the below script.


M = {}
M.allowHeaders = {"History-Info"}
function M.inbound_INVITE(msg)
local hisInfo = msg:getHeader("History-Info")
local start = string.find(hisinfo, "<")
local end_str = string.find(hisinfo, ">", start+1)
local target = string.sub(hisinfo, start, end_str)
local diversion = string.format("%s;reason=\"unconditional\"", target)
msg:addHeader("Diversion", diversion)
return M


Tried the Lua interpreter to execute the script and it showed the correct result.


HISTORY-INFO: <;user=phone>;index=1;ms-retarget-reason=forwarding,<;user=phone>;index=1.1

hisinfo = '<;user=phone>;index=1;ms-retarget-reason=forwarding,<;user=phone>;index=1.1'

local start = string.find(hisinfo, "<")
local end_str = string.find(hisinfo, ">", start+1)
local target = string.sub(hisinfo, start, end_str)
local diversion = string.format("%s;reason=\"unconditional\"", target)

print (diversion)



but the CUCM throws error at line number 5.


13:00:15.100 |SIPNormalizationScriptError - A script error occurred Device Name:SIP_CA_Lync_2013_Toll_QA Script Name:Simultaneous_Ring_Script Script Function:M.inbound_INVITE Script Type:Custom Error Code:3 Error Code Text:Execution Error Error Message:Simultaneous_Ring_Script at line 5: bad argument #1 to 'find' (string expected, got nil) Configured Action:Rollback Only Resulting Action:Rollback Only In Use Memory:1946 Memory Threshold:51200 In Use Lua Instructions:0 Lua Instruction Threshold:1000

>> could you please have a check on this? will open a thread in support form if needed :)

Rising star

ok, found & fixed the issue of the case sensitive variable :)

local hisInfo = msg:getHeader("History-Info")

defined the valiable as "hisInfo" but called it without block letter I, hisinfo other places.

Cisco Employee

Nicely done! The find function wasn't getting any value.


Excellent Post. Thank you for this. Helped me out a lot!


Cisco Employee

Thanks for your feedback John!


GREAT! This is how to transmit experience. So important the SIP interop stuff. Thanks so much.This is Cisco SOLUTIONS.. :-) Thanks!!

Cisco Employee

Thanks ahenne! Glad you like the post :)

Hi Team !

i have the same Issue ! the SIP Provider ask me to change the Invite and the From

now my CUCM is sending the Invite and From like this

INVITE sip:06923848585@ SIP/2.0
> Via: SIP/2.0/UDP;branch=z9hG4bKc013179554
> From: <sip:021163558628806@>;tag=3535~14bb5db7-95a9-4db0-864a-a21a1f2e14ad-


i have to modified it like this:

> Via: SIP/2.0/UDP;branch=z9hG4bKc013179554
> From: <sip:20xx005t0@>;tag=3535~14bb5db7-95a9-4db0-864a-a21a1f2e14ad-


Please can you help send me the Script template for my change !

Thanks in advance

Cisco Employee

Hi Alain,


We cannot change the Request URI unless it is going to the same number every time.

There is an API setRequestUri which is used to set the URI on the INVITE message.


I suggest using number translation on the route pattern or translation pattern on the CUCM itself before sending the call out over the SIP trunk.

As for the domain name that you need to send to, if you have DNS enabled, you can point the SIP trunk at This will populate it in the URI.


For changing the From header, again, you can invoke Calling Party transformation to make the changes, or if you really want to use normalization, then use the getHeader API to get the contents of the From message and then replace the number. You'll need to figure out a pattern first because the calling number can be different for each call.




Hi Screekanth,

thanks for your prompt replay. you are wright ! i am not trying to change the URI th am trying to change only the route Pattern


the Only change hier is

INVITE sip:06923848585------------  to INVITE sip:20xx005t0


From: <sip:021163558628806 ------ to From: <sip:20xx005t0


how to do it ?



Cisco Employee

Are these static changes that you want to make? Will it always be the same numbers?

And in 20xx005t0, does the XX mean a 2 digit number? What is the 't' here for?

yes it will alwas be the same nr and the xx are digits the t is there


this nr is my SIP ID and the provider need it to AUthenticate me



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