Need auto answer after dial execution

Hello Asterisk Community! I hope this post finds you well.

i am facing a problem in asterisk i want to implement auto answer via SIPAddHeader but i need first phone ring 5 seconds after that auto answer will apply.
i apply SIPAddHeader(Call-Info:answer-after=5) before Dial but it will not ring and if i apply that using U and G option in Dial then it will execute after manual answer.
so is there any way that just after Dial execution Dialplan goes to another place where we can implement SIPAddHeader(Call-Info:answer-after=2)

To achieve your desired behavior in Asterisk, where the phone rings for 5 seconds before auto-answering, you can use a combination of the Dial application and some dialplan logic. Here’s a basic outline of how you can implement this:

[auto_answer_context]
exten => s,1,NoOp(Starting auto-answer call)
 same => n,Dial(SIP/${EXTEN},20,U(answer_after))
 same => n,Hangup()

exten => answer_after,1,NoOp(Waiting 5 seconds before auto-answer)
 same => n,Wait(5)
 same => n,SIPAddHeader(Call-Info: answer-after=5)
 same => n,Return()

  1. auto_answer_context: This is the context where your auto-answer logic resides.
  2. s: This is the extension within the context.
  • The first priority dials the SIP endpoint (${EXTEN}) and specifies a timeout of 20 seconds. It also uses the “U” option to continue execution in the dialplan even after the call is answered.
  • After the Dial application, it jumps to the extension named “answer_after”.
  1. answer_after: This extension is responsible for waiting 5 seconds before sending the SIPAddHeader.
  • It waits for 5 seconds using the Wait application.
  • Then it adds the SIP header using SIPAddHeader.
  • Finally, it returns to the previous extension in the dialplan.

i hope it will some work for you

Best Regard
Danish Hafeez | QA Assistant
ICTInnovations

No you don’t as SIPAddHeader is no longer supported, as it only works with the, no longer included, since version 21, and unmaintained, chan_sip.

There is a pre-dial handler to allow the chan_pjsip equivalent to be run on the right channel.

Note that well designed phones should not accept it out of the box, as it turns them into infinity transmitters.

Also do not PM people from the forum asking them for help, unless they’ve advertised paid consultancy and you are prepared to pay the market rate.

hello danishhafeez,
thanks for reply but you use U option in Dial means the flow will continue to answer_after after manual pickup the call. after implement your provided dialplan below logs were received and phone continuous rings till 20 seconds.

Dpk2*CLI>
== Using SIP RTP CoS mark 5
> 0x7f8c4c03bb20 – Strict RTP learning after remote address set to: 10.5.60.179:48826
– Executing [10003@phones:1] NoOp(“SIP/10001-00000102”, “Starting auto-answer call”) in new stack
– Executing [10003@phones:2] Dial(“SIP/10001-00000102”, “SIP/10003,20,U(answer_after)”) in new stack
== Using SIP RTP CoS mark 5
– Called SIP/10003
– SIP/10003-00000103 is ringing

thanks david551 for reply and I apologize for sending a PM because I didn’t know about it.Meaning there is no way we can get a few rings before the auto answer.

The header can only be sent when the call is requested. It is the phone that applies any delay in auto-answering, based on the contents of the header, and/or local configuration. Note this header is not an official standard, even if widely implemented.

1 Like

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