Asterisk ring out even when the client is offline
I need to configure an Asterisk box to go to voicemail but only after X ringouts.
exten => 1234,1,Dial(SIP/ivan, 30)
exten => 1234,2,VoiceMail(777@mb_tutorial)
exten => 1234,3,PlayBack(vm-goodbye)
exten => 1234,4,HangUp()
The client in my case is a softphone client. If it does not running or not connected to the pbx then this would immediately redirect the caller to the voicemail. The 30 seconds wait time does not apply in this case when the phone (sip client) is unavailable.
How could I configure Asterisk to try to ring out at least 5 times (regardless the sip client is offline) then if there is still no answer drop the caller to the voicemail.
Thanks
Solution 1:
You can create a context in extensions.conf
that just rings forever if you call it, and then dial both the extension you want to reach and that contex. This guarantees that it will always run the Dial()
application for 30 seconds before jumping to the voicemail. (Change the 30 seconds value as needed to get five ringtones... the period of ringtones can be found in the appropriate section of indications.conf
for your country, so you can calculate how much time five rings are supposed to be.)
It can look something like this:
[noop]
exten => s,1,Wait(30)
same => n,Hangup
[your_context]
exten => 1234,1,Dial(SIP/ivan&Local/s@noop,30)
exten => 1234,2,VoiceMail(777@mb_tutorial)
exten => 1234,3,PlayBack(vm-goodbye)
exten => 1234,4,HangUp()
Calling the noop context will basically have no effect, and if SIP/ivan
is available, then it will ring. If you are not hearing ringtones when calling the 1234 extensions, you can try different options:
-
First possibility, using call progress (avoiding answering the channel and thus having the caller possibly pay to hear ringtones... but does not always work, depending on the SIP provider):
[your_context] exten => 1234,1,Progress exten => 1234,2,Ringing exten => 1234,3,Dial(SIP/ivan&Local/s@noop,30) exten => 1234,4,VoiceMail(777@mb_tutorial) exten => 1234,5,PlayBack(vm-goodbye) exten => 1234,6,HangUp()
-
Second possibility, generating ringtones as sound on the answered channel (meaning that the caller pays for the call while waiting for an answer too, because the call is actually answered):
[your_context] exten => 1234,1,Answer exten => 1234,2,Playtones(ring) exten => 1234,3,Dial(SIP/ivan&Local/s@noop,30) exten => 1234,4,VoiceMail(777@mb_tutorial) exten => 1234,5,PlayBack(vm-goodbye) exten => 1234,6,HangUp()
If you do not hear the ring tones while waiting, try adding a
,r
parameter to theDial
application:exten => 1234,3,Dial(SIP/ivan&Local/s@noop,30,r)