Hangup outbound call after answer machine detected

hello,

I want to hang up the call if AMD STATUS equal MACHINE and send 603 code

[my_gosub_routine]
exten => s,1,NoOp(************ Drao Detection *************)
same => n,AMD()
same => n,NoOp("AMD: ${AMDSTATUS} - ${AMDCAUSE}")
same => n,GotoIf($["${AMDSTATUS}"="MACHINE"]?machine:human)
same => n(machine),Hangup(603)
same => n(human),Return()
[default]
exten => _+33.,1,Answer()
same => n,NoOp(********************* Appel Vers la France ****************************)
same => n,SipAddHeader(P-Asserted-Identity: ${SIP_HEADER(P-Asserted-Identity)})
same => n,SipAddHeader(P-Preferred-Identity: ${SIP_HEADER(P-Preferred-Identity)})
same => n,SipAddHeader(Privacy: ${SIP_HEADER(Privacy)})
same => n,Dial(${SIPTrunk}/${EXTEN},,U(my_gosub_routine^my_gosub_arg1^my_gosub_arg2))

currently the system hangs up the call but it does not return the 603 code

On Monday 10 June 2024 at 16:09:45, kimo via Asterisk Community wrote:

hello,

I want to hang up the call if AMD STATUS equal MACHINE and send 603 code

same => n(machine),Hangup(603)

Try using Hangup(21).

Antony.


Wanted: telepath. You know where to apply.

                                               Please reply to the list;
                                                     please *don't* CC me.

Whilst it is true that you cannot use a SIP cause code, in this context, the OP is hanging up a channel that is already up, so the hangup cause is only going to appear in a Reason header, always assuming that chan_sip even sets reason for BYE.

As Joshua is pointing out, this question contains many of the misunderstandings shown in another recent question.

Actually, both channels are up, as there is an apparently unnecessary Answer on the A side.

I’ve now checked and chan_sip, close to when it was removed from Asterisk, doesn’t provide the SIP cause for BYE, only the Q.850 one:

I’m assuming chan_sip, as they are performing operations that only work for chan_sip.