How to get SIP_CAUSE value in outgoing calls

Hi All,

I want to get the SIP Cause text from the SIP packet for a failed outgoing calls. Asterisk do provide us the SIP_CAUSE variable, but I am unable to use it in the FAILED extension in my dialplan. I am placing calls through the Asterisk spool directory as call files.

Rite now, I am trying to get the cause in my dialplan as

exten => failed,n,Set(sip_cause=${HASH(SIP_CAUSE,${CHANNEL})});

in failed extension.

Also I have enabled it in the sip.conf as

storesipcause=yes

I am using Asterisk ver 1.8.11, and not getting the SIP CAUSE.

Any help will be appreciated. If there is any other way to get the SIP cause string/code, plz let me know.

You need to fill the proper channel name for example using the ${CDR(dstchannel)} variable instead of the ${CHANNEL} one.