Storing "SIP" Responses without Dialplan

Hello everyone,
I’ve posted the following topic sometime ago Storing SIP Responses?
About storing the hangupcauses that asterisks gives, but, i found the usage of it a bit… odd

So, i was wondering if there is a way to assign a “Application” as “Set(CDR(newcdrfield))” without doing it on the dialplan, like a normal call detail record.

Call ends and some variables are being stored, right?
So, there must be a way to add a new field with its “Formula”

Best regards!

Custom CDR values need to be written on the dial plan using CHANNEL function

Thanks for your help @ambiorixg12
But i cant find something about “CDR” over here Asterisk Wiki

I use the normal SIP channel

If you could give another tip i would be grateful

Something like this should work, for example

same=>n,Set(CHANNEL(accountcode)= ${HANGUPCAUSE })

Actually, im doing that with


I’m trying to automatically save “Hangupcause” variable like every normal CDR field, but without inserting it every time.

Because if you cancel a call (487 SIP Code) and the call flow doesn’t get to the Set(CDR(customfield)) you will have a empty value, not even zero

Thanks for your help

You could evaluate the value of ${HANGUPCAUSE} of the h extension and if match 487 SIP code you can write the custom cdr field from there

Let me explain again with an example:

exten => _X.,1,Noop(Something)
exten => _X.,2,Dial(SIP/trunk/{EXTEN}) exten => _X.,3,Set(CDR(customfield)={HANGUPCAUSE})
exten => _X.,4,Hangup()

When you get to (2) Dial and cancel the call while the channel its ringing, you won’t save any variable, because you hangup the call at priority 2 (Dial).

Result: No Hangup Mapping

So, my question is if there is any way to save the hangup mappings without using the dialplan (At least, after Dial), if the call doesn’t go through the correct call flow (1 ,2 ,3. . . in this case) there won’t be any value on the customfield of the CDR’s

Listening to AMI’s event and writing to the CDR using PHP ,

you can change dial-plan like this,
exten => _X.,1,Noop(Something)
exten => _X.,2,Dial(SIP/trunk/{EXTEN})
exten => _X.,3,Set(CDR(customfield)={HANGUPCAUSE})
exten => _X.,4,Hangup()

exten => h,1,Noop(–hangup–)
exten => h,n,Set(CDR(customfield)={HANGUPCAUSE})

but, there is a difference between SIP Response and HANUPCAUSE.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.