Expanding My Answering-machine System

Home » Asterisk Users » Expanding My Answering-machine System
Asterisk Users 7 Comments

You all know the story–give the customer/client what they ask for, and if they like it, they’ll be back for more. Such is just so with my one-trick-pony answering-machine project. Now the other two musicians in my virtual band want the following capabilities:

1. The ability to dial the main number from outside our three-party network and hit a button, like 1, 2 or 3, while the outgoing message is playing which will ring one of the parties now in the system. Alternatively, press a button and have everybody’s phone ring and someone will eventually pick up in their studio.

2. Check voicemail remotely when not on the local network with a phone connected to the system. This is emminently doable and well described on how to do it in my book, but I have a question about how to invoke the VoicemailMain() function while the outgoing message is playing. Is it as easy as creating an extension whose number is “#” and send that to VoicemailMain()?

As always, thanks in advance for a kick in the right direction.

7 thoughts on - Expanding My Answering-machine System

  • For both capabilities, you can use Background() instead of Playback()
    for audio prompts.  Background() allows for interrupting the prompts and continue on with your dialplan.

    Doug

  • Doug,

    This is where the weeds start growing.

    The most common use of the Background() application is to create basic voice menus (often called auto attendants, IVRs ,  9 or phone trees ).

    But now, the confusion:

    Background() has the same syntax as Playback()  :

                      [TestMenu]
    exten => start,1,Answer()
                      same => n,Background(enter-ext-of-person)

    Stop right there. The syntax of Playback() is Playback(filename), there’s no extension number.

    More book:

    Both Background() and WaitExten()  allow the caller to enter DTMF
    digits. Asterisk then attempts to find an extension in the current context that matches the digits that the caller entered. If Asterisk finds a match, it will send the call to that extension.

    My question then is, is “*” a valid exension, as in:

    exten => *,VoicemailMain()

  • I’d have to assume yes.  I don’t use WaitExten() and I set autofallthrough=no in the /etc/asterisk.conf, since that is the way I’ve always expected Asterisk to work; my dialplan examples are based on that.

    The below example shows a call coming into a DID, playing background prompts and excepting input during play.

    ;****************
    ;* Auto attendant
    ;****************

    exten => 5175551212,1,Gosub(check-blacklist,s,1)
         same => n,Gosub(check-hours,s,1)
         same => n,Gosub(holiday-check,s,1)
         same => n,Gosub(get-callerid,s,1)
         same => n,Goto(auto-attend,s,1)

    [auto-attend]

    include => dial-by-extension

    ;*************
    ;* Set timeouts
    ;*************

    exten => s,1,Set(TIMEOUT(response)=8)
         same => n,Set(TIMEOUT(digit)=2)
         same => n,Set(LOOPCOUNT=0)

         same => n,GotoIf($[“${Holiday}” = “YES”]?HOLIDAY:BEGIN)
         same => n(BEGIN),Answer()
         same => n,Wait(1)

    ;****************************************************
    ;* Play the ‘Welcome message’ and office hours message
    ;****************************************************

         same => n,Background(${voice}/welcome)
         same => n,Background(${voice}/business_hours)
         same => n,Background(${voice}/8am_5pm)
         same => n(HOLIDAY),Background(${voice}/dial_anytime)
         same => n(DIRECTORY),Background(${voice}/directory_assist)
         same => n,Background(${voice}/press_1)
         same => n,Background(${voice}/to_ring_after_hours)
         same => n,Background(${voice}/press_2)
         same => n,Background(${voice}/absence_delay)
         same => n,Background(${voice}/press_3)

    ;************************************
    ;* If 1 is pressed, go to Dial by name
    ;************************************

    exten => 1,1,Goto(directory,s,1)

    ;***************************************
    ;* If 2 is pressed, dial the Foyer phone
    ;***************************************

    exten => 2,1,Goto(dial-by-extension,4255,1)

    ;***********************************************
    ;* If 3 is pressed, dial absence/delay extension
    ;***********************************************

    exten => 3,1,Gosub(cellphone-callerid,s,1)
    exten => 3,n,Voicemail(3888@sip,us)
    exten => 3,n,Hangup()

    ;********************************************
    ;* If 8# is pressed, go to Voicemail Main menu
    ;********************************************

    exten => 8#,1,VoiceMailMain(@sip)
    exten => 8#,2,Hangup()

    This is not the complete dialplan; I also have error checking and a loop counter.

    Doug

  • OK, this is how I thought it’s supposed to work. It just confounded me why the book would say the Playback() and Background() syntax were the same, then in the very next paragraph give an example that belied that claim.

    >

  • The syntax is the same. They both take a filename. The example gave a filename of “enter-ext-of-person”. You could pass that to Playback, though you would be unable to enter an extension.

  • No. One is not an extension number. One is a Background instructed to play a sound file with the filename “enter-ext-of-person”. It is not a placeholder where you replace it with an extension number. It’s meant to be used as-is, and play back a sound file named “enter-ext-of-person”.