Send custom SIP header / SIP messge on hangup

Below dialplan does AMD before connecting the calls.

If machine is found, the call is to be aborted, with SIP - 403.

I need to send SIP- 410 Gone, instead. If it is possible to add any custom header in the SIP Bye, then also works for me.

I need to do this so that the call originator can mark this call as AMD rejected.

[code][macro-trunkdial-failover-0.3]
exten = s,1,GotoIf($[${LEN(${FMCIDNUM})} > 6]?1-fmsetcid,1)
exten = s,n,GotoIf($[${LEN(${GLOBAL_OUTBOUNDCIDNAME})} > 1]?1-setgbobname,1)
exten = s,n,GotoIf($[${LEN(${CALLERID(num)})} > 6]?1-dial,1)
exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${CID_${ARG3}})} > 6]?${CID_${ARG3}}:${GLOBAL_OUTBOUNDCID})})
exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${ARG5})} > 2]?${ARG5}:)})
exten = s,n,Goto(1-dial,1)
exten = 1-setgbobname,1,Set(CALLERID(name)=${GLOBAL_OUTBOUNDCIDNAME})
exten = 1-setgbobname,n,Goto(s,3)
exten = 1-fmsetcid,1,Set(CALLERID(num)=${FMCIDNUM})
exten = 1-fmsetcid,n,Set(CALLERID(name)=${FMCIDNAME})
exten = 1-fmsetcid,n,Goto(s,4)
exten = 1-dial,1,Dial(${ARG1},20,M(new,${EXTEN}))
exten = 1-dial,n,Gotoif(${LEN(${ARG2})} > 0 ?1-${DIALSTATUS},1:1-out,1)
exten = 1-CHANUNAVAIL,1,Dial(${ARG2})
exten = 1-CHANUNAVAIL,n,Hangup()
exten = 1-CONGESTION,1,Dial(${ARG2})
exten = 1-CONGESTION,n,Hangup()
exten => s,n,AbsoluteTimeout(3)
exten = 1-out,1,Hangup()

[macro-new]
exten => s,1,Background(sip-silence)
exten => s,n,AMD(2000,2000,1000,5000,120,50,4,256)
exten => s,n,GotoIf($[${AMDSTATUS}=HUMAN]?humn:mach)
exten => s,n(mach),WaitForSilence(2000|2|30)
exten => s,n,Playback(vm-reenterpassword)
exten => s,n,Set(MACRO_RESULT=ABORT)
exten => s,n,Hangup()[/code]

Kindly guide me.

Don’t answer the call and hang it up with the Hangup application. Google ISDN cause codes for details of the values.

Once you Answer the call, Asterisk can only send BYE and there are no facilities for customising BYE.

[quote=“david55”]Don’t answer the call and hang it up with the Hangup application. Google ISDN cause codes for details of the values.

Once you Answer the call, Asterisk can only send BYE and there are no facilities for customising BYE.[/quote]

As you can see, I am hanging up the call after AMD machine detection, but asterisk ends up bridging both the calls. The only way to terminate the call after AMD is to call

But in ABORT I am not able to set custom cause code.

The earlier versions of Asterisk I use don’t support RFC 3326. If a later version does, I imagine it will be based on the parameter to Hangup().