Can I ring an extension after a voice mail is received

Is it possible to do the below:

Call extension 8552 for 5 seconds
Leave a voice mail
Close the call
Asterisk now that the call is terminated rings extensions 6666 forever until it is answered
when 6666 answer it will hear automatically the voicemail

Is this possible to do?

My attempt so far

exten => 8552,1,Dial(SIP/8552@demo,5)
same => n,VoiceMail(8552@default)
same => n,Dial(SIP/6666@demo)
same => n,Hangup

You’ll need to use the h extension and either use Originate, or queue a call file. The former only has one chance.

My attempt

exten => 8552,1,Dial(SIP/8552@demo,5)
same => n,VoiceMail(8552@default)
same => n,Hangup

exten => h,1,NoOp()
same => n,Originate(SIP/6666@demo,exten,)

This works but after the voicemail message is recorded the extension does not hangup
If I hungup the extension 8552 then the extension 6666 rings for 10 seconds and I get this error

[Jul 1 17:33:50] WARNING[29458]: chan_sip.c:4409 __sip_autodestruct: Autodestruct on dialog ‘70eb9022-b68be803-3e5b32d4@IP’ with owner SIP/2576-0000047c in place (Method: BYE). Rescheduling destruction for 10000 ms

Also if I pick up extension 6666 the phone call drops. I want to establish a call with the voicemail

I would run some dialplan on the originate.

can you specify what you mean?

You are supposed to either run an extension in the dialplan or an application, when you use originate. Not doing either may explain the invalid hangup message.

This is my dialplan.
The problem I have is that after the voicemail message is recorded the phone does not hungup automatically. If I do not do anything the other extension rings forever. However if I click end call on the phone I get the error message and the call on the second extension drop after 10 seconds

exten => 8552,1,Dial(SIP/8552@amp,1)
same => n,VoiceMail(8552@default)
same => n,Goto(call-voicemail,1)
same => n,Hangup

exten => call-voicemail,1,NoOp()
same => n,Answer()
same => n,Originate(SIP/vm-tanio@amp,app,VoiceMailMain,8552,)

exten => *8552,1,VoiceMailMain(8552)
same => n,Hangup

First hangup is uncreachable. Answer is redundant. Presumably the voicemail can be completed by hanging up, so to catch every case you need an h extension. You might as well explicitly hangup if it drops through.

If you want to limit the ring time to less than, I think, 30 seconds, you will need to use a local channel on the A side of the originate.

How can I create a local channel which is not related to any physical extension?? The originate app blocks until the B party answer the call and this is an issue. Can I create a fake channel and put it as the A party in the Originate function??
Regarding the h extension it is called every time I hangup a call in any part of the dialplan. In theory the h extension is called within the same context so I created a new context where I put only the voicemail button but it is still called. At the end of each call I have the voicemail ringing all the time which is not what I need. I managed to find a dirty solution using auto dial out and the system app. I created a file where I put the VoiceMailMain app and at the end of the voicemail I use the System app to copy and paste the file in the /var/spool/asterisk/outgoing folder. It works fine but I would have preferred to have just a clean dialplan

You can use a local channel as the A chanel for Originate.

h only runs for call executing in its context, so make sure you are in appropriate context.


include => h-extension-context




exten=> h,1,NoOp()

I tried this and the h extension is called when I use extension 100 Why does it happen?

You need to use GoTo or GoSub, not include.

Perfect, thanks a lot