Dial And Start Music On Hold After Timeout

Home » Asterisk Users » Dial And Start Music On Hold After Timeout
Asterisk Users 14 Comments


I am searching a way to dial a SIP peer, and if it does not answer within 20 seconds, play an announcement to the caller. This means that the caller would hear a ring tone for 20 seconds, and only then hear the announcement if the callee did not answer.

I know it is possible to do this with ARI, but in this particular case I
do not want to use ARI. I would like to do this purely with dialplan and AGI scripts, but I cannot find a way. I have read about the “m” option of Dial application, but it starts the announcement immediately, whereas I would like to start it after 20 seconds of timeout.

Does anybody have an idea ?

Best regards,

Jean Aunis

14 thoughts on - Dial And Start Music On Hold After Timeout

  • This seems like the obvious answer but maybe I’m misunderstanding the question.

    exten => s,1,Dial(SIP/alice,20)
    same => n,Playback(myannouncement)
    same => n,NoOP(Whatever else you want to do goes here)

  • Sorry, I forgot to write that the SIP peer must keep ringing while the announcement is being played.

    Le 22/08/2016

  • Thank you for the idea. The problem with RetryDial, is that it will cancel the first call, play the announce and then dial the SIP peer once again, so the telephone will display a missed call. I would prefer to do everything in a single call.

    Le 22/08/2016

  • You could m and make a moh file that has ringing the first 30 sec and then the anouncment

    בתאריך 22 באוג׳ 2016 7:19 PM,‏ “Jean Aunis” כתב:

  • How about:

    exten => s,1,Dial(SIP/alice&LOCAL/555@delayed-announce,40)

    exten => 555,1,Wait(20)
    same => n,Playback(myannouncement,noanswer)
    same => n,NoOP(Whatever else you want to do goes here)

    The ‘noanswer’ option on the Playback means that SIP/alice should continue to ring for the remaining 20 of the 40 seconds, as the Playback will not answer (terminate) the call.

    Don’t forget AstriCon this year – http://www.astricon.net

  • Thank you, I just tried your suggestion. Strangely, the announcement is played only if I try to dial a SIP peer which is not available (not registered to be more precise). If the SIP peer is available, I only get the ring tone, and never hear the announcement. Here is the dialplan (I
    had to add an Answer() before the Dial, otherwise the announcement is never played, even in the first case) :

    exten = 007,1,Answer()
    same = n,Dial(SIP/foo&Local/s@playme,40)

    exten = s,1,Ringing()
    same = n,Wait(10)
    same = n,Playback(/var/lib/asterisk/sounddir/announce,noanswer)

    When it is working, I can see the following output in the CLI, which is not there otherwise :
    — SIP/xxxxxxxxx requested media update control 26, passing it to Local/s@playme-000005be;1

    Otherwise, no error message, Asterisk tells he is playing the announcement but I don’t hear it.

    Best regards

    Jean Aunis

    Le 23/08/2016 à 16:07, David Duffett a écrit :

  • Damn, I was going to suggest trying a Queue with a single member using the
    ‘r’ option to play ringing instead of MOH and using an announcement but the queue will stop ringing your agent while it plays the announcement.

    It’d go right back to ringing after the announcement however.

  • Maybe try progress() instead of answer ()

    בתאריך 23 באוג׳ 2016 7:19 PM,‏ “Jean Aunis” כתב:

  • Using Progress didn’t solve the problem. If I cannot find another way, I
    will use your solution of recording the ring tone.

    Le 23/08/2016 à 20:53, Israel Gottlieb a écrit :

  • Yes, sorry, my idea was too simplistic, as it did not take into account that the caller would already be hearing the ringing and therefore the announcement would need to be somehow mixed with that ringing…

  • ​I have the same exact issue. I cannot push any sounds or even Playtones to the caller, unless the channel is answered, which is not possible for billing reasons. I am also using the Local channel & Dial(PJSIP/…). I think this is a bug in Asterisk 13. The Dial function has not answered yet, so the Local channel should be able to play anything to the caller, without answering, in parallel with Dial. Should I open a JIRA ticket?

  • This behavior is exactly the same as it has always been. As Richard mentioned in your other thread, there is no bug here [1]. You have multiple options:

    (1) Indicating Ringing in the dialplan. Depending on your configuration, Asterisk will generate a 180 and pass it back to the caller, causing them to ring or it will generate a 183 and play a ringing tone back to the caller itself.

    (2) Indicate Progress in the dialplan. This will send back a 183 to the caller and, if possible, will send sound from Asterisk to the caller. You then have multiple options here:
    (2a) If Asterisk has the ability to perform early bridging with an outbound channel, it will. If not, it won’t – and it won’t mix the early media from multiple outbound channels.
    (2b) You can play media back yourself using MoH or one of the other sound generation applications.

    (3) Wait for one of your outbound channels to pass a 180 back, and allow that to cause the inbound channel to ring.

    [1] http://lists.digium.com/pipermail/asterisk-users/2016-August/289781.html

    Matthew Jordan Digium, Inc. | CTO
    445 Jan Davis Drive NW – Huntsville, AL 35806 – USA
    Check us out at: http://digium.com & http://asterisk.org