Home » Technology » Putting the Pedal to the Metal with Asterisk@Home

The Most Versatile VoIP Provider: FREE PORTING

Putting the Pedal to the Metal with Asterisk@Home

Peaceful Coexistence. This is the fifth in our Asterisk@Home series. Read the first four parts (I, II, III and IV), and then this one will be a breeze. Now that we have our Asterisk® server up and running and our Sipura SPA-3000 configured, you've probably noticed a few quirks. Specifically, both Asterisk and the Sipura device are designed to control some of the same functions such as call forwarding, call forwarding on busy, call waiting, and do not disturb. Where possible, we want the Asterisk box to control these functions because you may have more trunks than your Ma Bell PSTN line, and the Sipura box is only designed to manage your incoming PSTN trunk. That would mean your SIP and IAX2 trunks would be left without support for call forwarding, call waiting, and do not disturb which isn't what we want. There's a simple way to fix this. Point a web browser at your Sipura device's IP address, click on Admin Login and then Advanced. Now click the Regional tab and scroll down to the Vertical Service Activation Codes section. Then delete the following entries: Blind Transfer Code, Cfwd All Act Code, Cfwd All Deact Code, Cfwd Busy Act Code, Cfwd Busy Deact Code, CW Per Call Act Code, CW Per Call Deact Code, Block ANC Act Code, DND Act Code, DND Deact Code, and Conference Act Code. Now save your changes by clicking the Submit All Changes Button at the bottom of the form. Your SPA-3000 will reboot, and you're all set. Now the following functions will work through Asterisk from any extension on your system:

  • *61 Local weather forecast
  • *62 Schedule wakeup call
  • *70 Activate Call Waiting
  • *71 Deactivate Call Waiting
  • *72 Enable Call Forwarding (include forwarding number to avoid prompt)
  • *73 Disable Call Forwarding
  • *90 Enable Call Forwarding on Busy (include forwarding number to avoid prompt)
  • *91 Disable Call Forwarding on Busy
  • *78 Enable Do Not Disturb
  • *79 Disable Do Not Disturb
  • *97 Access Voicemail for Calling Extension
  • *98 Access Voicemail with Prompt for Mailbox Number
  • Wading into the Weeds. As best we could, we've tried to keep the really technical parts of Asterisk shrouded in secrecy because there's really no reason to fiddle with most of this stuff, particularly if you don't really understand what you're doing. There are times, however, when things don't work or lines ring busy when they shouldn't, and you at least need to know where to look to find the information that others (not me!) will need to help you with your problem. The Asterisk forums at SourceForge and Voxilla are tremendous resources when something comes unglued, and you'll also learn a lot just by reading some of the issues others have faced. If you're new to forums, there's one cardinal rule you need to observe. Search for an existing answer to your problem first. If you don't find it, then post a question. This will save you the embarrassment of being flamed for repeating a question that already has been answered.

    So where do you look to see what's going on with your system. If you're getting a fast busy when you try to place calls or, if people calling you are getting a fast busy when they dial your number, the first thing to check is whether your connections to your VoIP providers have been successfully established. Fire up your web browser and point it at your Asterisk server's IP address. Then choose AMP->Maintenance and click on Asterisk Info. The sections we're primarily interested in are Sip Peers and IAX2 Sip Registry. All of your connections to BroadVoice, Voxee, and other VoIP providers will have an entry here assuming you've created a Trunk for each of them. In the far right column of each entry should be an entry which says "Registered." If it says something else, you've got a registration problem which typically is caused by your providing an incorrect account name and/or password, or your VoIP provider's service may be down. If you're using a Sipura SPA-3000 to manage your PSTN (home phone) line, then you'll need to point your web browser at the IP address of your SPA-3000, click Admin login, then Advanced, and choose the Info tab on the far left. Check the Registration State in both the Line 1 Status section and the PSTN Line Status section. Both of these should also show Registered. If not, review the setup steps for the SPA-3000 in our previous articles. You've missed a step or a password somewhere. The next place to turn for information is Asterisk's debug log. You can print out the last 2,000 lines of the file by going to AMP->Maintenance->Log Files and clicking on Asterisk Full debug log. Or, if you're a glutton for punishment, go to a command prompt, change to /var/log/asterisk, and print out the full file. Yep, that's the name of the file: full.

    Asterisk also has an interactive mode called the Command Line Interface (CLI) so that you can actually watch what's happening when calls are placed and received. This works best if you connect to your Asterisk server through SSH from a Mac or PC. SSH comes with every Mac and the syntax is simple: ssh root@AsteriskIPaddress. If you're still chained to Microsoft, download Putty from the Mother Country, and you can do the same thing using a Windows machine. Once you're logged in as root, issue the following command: asterisk -r. Quit ends your Asterisk CLI session, and exit logs you out of your SSH session. Now issue the command: set verbose 5 to get maximum information. Place a call and watch what happens. HELP will list all of the various commands which are available. Be careful! Some of them will really screw up your system if you don't know what you're doing. Save dialplan, for example, sounds fairly innocuous but it permanently deletes your existing dialplan with no backup! If you have problems with SIP connections, review the SIP commands and turn debug on for a particular IP address or channel. If you have Zap, IAX2, or PRI connection issues, you can do something similar for the addresses and channels of these interfaces. Before you use any of the commands in CLI, give a careful read to the detailed explanations of the commands which can be found at this link on VOIP-Info.org.

    System Backups. If you do nothing else with your Asterisk server, at least configure the system to make regular backups and download at least one backup to another computer. To download a backup to another computer, go to the remote computer and use a web browser to access AMP on your Asterisk server. Choose, Maintenance, then Backup. Now Ctrl-Click (Mac) or Right-Click (PC) on Download Backup and save it to a safe place on your local machine. To configure regular backups on the Asterisk server itself (remember that these don't help you if you have a disk crash!), go to AMP->Setup->Backup and Restore and choose Add Backup Schedule. Stop here for a moment and go to your Asterisk machine, log in as root, and change to the following directory: cd /var/lib/asterisk. Make a new directory: mkdir backups. Change the owner of the directory: chown asterisk backups. Change the group ownership of the directory: chgrp asterisk backups. Now return to AMP's Add Backup Schedule screen. Name your backup schedule Daily. Click Yes for all the buttons. Leave Follow Schedule Below selected. Click 2 in both the hour and minute columns, and make sure the other three entries each have All selected. This means you'll get a backup every day at 2:02 am in your /var/lib/asterisk/backups/daily folder. Click Submit Changes to activate the backup schedule. Don't forget to check the directory from time to time and remove some of the older backups. Periodically, make an external backup to a remote machine just be on the safe side. Now you'll sleep better.

    Choosing VoIP Providers. One of the beauties of having your own PBX is being able to easily add and change VoIP providers. Because Voice Over IP technology is still experiencing some growing pains, putting all your eggs in one basket for IP telephony is a very bad idea. A number of readers have written asking for specific provider recommendations beyond those outlined in some of these articles. We're always shopping for the most reliable and least costly solutions just as you are and THINGS CHANGE. BroadVoice, for example, which has been one of our favorites and is especially flexible for those with Asterisk servers is having some internal problems apparently. Three of the company's founders including the CEO, his wife, and their top guru all abruptly left BroadVoice last month ... about the same time BroadVoice reportedly implemented some shady retroactive billing practices. Read this thread on Voxilla for more information. You really can't beat Voxee for pricing on most outgoing calls, but they don't provide incoming phone numbers (yet anyway). For a really good selection of incoming numbers and reliable service, we like Teliax but, unlike most in the VoIP industry, they charge for incoming and toll-free calls (2¢ a minute) with minimum one minute billing plus $5/month per phone number/DID. Don't expect them to be around too long. They're just too pricey. Secret clue for Teliax: folks aren't drawn to the VoIP solution just to find a way to pay more for their phone service than they're currently paying Ma Bell. Sorry boys but the cellphone pricing model just isn't going to fly in the VoIP arena. A footnote on Teliax: One of the extremely cool things you can do with a Teliax IAX2 connection to your server is spoof your CallerID number. If you want to have a little fun, put on a Barry White album and then call your buddy late one night after setting your CallerIDNumber to his girlfriend's home phone number ... and then lock all your doors and windows.


    Another top-rated provider is VoicePulse. They offer all-you-can-eat plans starting at $14.95 (these plans use a locked terminal adapter!) and pay-as-you-go service called VoicePulse Connect with local numbers/DIDs priced at $11 per month with unlimited free incoming calls. That's just about double the price of a comparable BYOD-Lite account with BroadVoice. Others have recommended getting a FWD account and using it with a free DID from Washington state using IPkall. This gives you free incoming calls albeit to a Washington state telephone number. Our experience with FWD has been just short of terrible. And our one inviolate rule for incoming calls is your phone needs to ring when someone calls. This is simply not negotiable in our book. Our particular FWD account failed to register about 90% of the time during our testing these past few weeks so we've pretty much written off FWD. The good news is that just because FWD was disappointing doesn't mean you can't use an IPkall number with Asterisk to get free incoming calls from a real Washington state PSTN number. In fact, your number will be just outside Bill Gates' hometown. For this to work, you'll need a fully qualified domain for your Asterisk server as we previously discussed. Then you'll need to make certain that your firewall redirects incoming UDP traffic on ports 5060 through 5082 and 10000 through 20000 to the internal IP address of your Asterisk server. Finally create an entry in the [from-internal-custom] context of your extensions_custom.conf file that looks like this substituting one of your phone extensions for 204 in lines 1 and 2. Why not just use an actual extension number with ipkall.com? Because this way you can control incoming calls from that specific VoIP provider without divulging any information about the actual extensions in your Asterisk system.

    exten => ipkall,1,dial(SIP/204,20,m)
    exten => ipkall,2,VoiceMail(204@default)
    exten => ipkall,3,Hangup

    You'll also need to make sure you have two lines in the [General] context of your sip.conf file. The first line should contain the actual public IP address of your Asterisk server. If you don't know it, click here. The second line should be the private subnet of your internal network, typically 192.168.0.0 or 192.168.1.0. The subnet mask (255.255.255.0) should be correct for most of you. With these settings, you shouldn't have to turn on NAT for your individual phone instruments. Just remember to update your externip address whenever your ISP changes your dynamic IP address if that's what you have. The third line is a little fix (from the Voxilla forums) that solves a nagging problem with incoming BroadVoice calls not actually ringing at the caller's end. Just thought we'd fix it while we were here.

    externip = 24.99.153.83
    localnet=192.168.0.0/255.255.255.0
    progressinband=yes

    Restart Asterisk and then go to ipkall.com and sign up for your free telephone number. For your SIP phone number, use ipkall. For your SIP Proxy, use the fully qualified domain name for your Asterisk server. Use your legitimate email address to assure that you receive your signup information. Think up a four digit PIN to access your IPkall account in the future. And change the seconds to voicemail to a number such as 90 so that it never gets used. Now sit back and wait for your signup email which will have your new phone number in area code 360. Within an hour, anyone will be able to dial your 360 phone number and connect through your Asterisk server to the extension you specified above. It doesn't get much easier (or cheaper!) than that. Ours was operational in just under 60 minutes. If you ever want to disable the number temporarily or permanently, all you have to do is comment out the three ipkall lines in your extensions_custom.conf file with a leading semicolon and restart Asterisk.

    Here's a good list of all the VoIP providers out there if you want to explore your options further.


    So which providers do we use? Well, it's a combination of a $49 a month BellSouth PSTN line and BroadVoice's $9.95 in-state SIP calling plan with free incoming calls to handle all incoming calls as well as outgoing local and in-state calls (which make up about 90% of our usage) and Voxee's pay-as-you-go, penny-a-minute service for U.S. long distance calls. Guess which one we're about to disconnect? Then we have ipKall and Teliax's pay-as-you-go service for additional redundancy. If all of these services fail, telephones will be the least of our worries. We don't do much international calling (other than to some of you) so that wasn't a big issue for us. Your mileage may vary depending upon your calling patterns. Based upon the current allegations floating around, BroadVoice would be our very last choice if heavy international calling (even to girlfriends or family) were a priority. Here's why. Too bad.

    Building Autoattendants and Interactive Voice Response (IVR) Systems. Entire books have been written and literally hundreds of multi-thousand dollar telephony courses can be purchased to learn about good design and implementation techniques for autoattendants and IVR systems. Our discussion is going to focus on the technical aspects of implementing such a system with Asterisk@Home. But, if you want to keep your friends and your customers, you really should learn something about IVR design before implementing your own version of IVR Hell. Here's a free site with loads of good tips about IVR design. A little additional time with Google will work wonders, too.

    The folks that brought us the Asterisk Management Portal (AMP) got it almost right with their Digital Receptionist. You access it by going to AMP->Setup->Digital Receptionist. The drill for today goes something like this. First, sketch out on a piece of paper what options you want to offer your callers. Whether you like it or not, callers will have the option of keying in an actual extension number to dial or pressing the pound key to access your directory lookup service. We configured this in Part II. In any case, you'll probably want to tell callers about these two options plus any others you want to add. Second, we'll record the actual Main Menu for your new autoattendant. Third, we'll move it to its permanent home on your Asterisk server. And then we'll use AMP to tweak our extensions_custom config file. And finally, we'll use AMP's Digital Receptionist to do the heavy lifting of building the actual IVR code for us. Just for fun, play along and build the sample below. Then you can change it to your heart's content.

    As we mentioned, the AMP folks got it just about right, but not quite. Just about everything works except actually naming and placing your voice prompt files (such as For Bob, press 1; for Betty, press 2, etc.) in the proper locations. The AMP solution also uses .wav files which are roughly 50 times the size of equivalent .gsm files. So we're going to do things a little differently, but the result will be the same. It does mean you have to endure a couple of error messages from AMP, but who cares if it works when we're done. Right? So we begin by thinking through what we want our home menu choices to be when someone calls. We decide that callers should be able to press 1 to ring Bob's phone, 2 to ring Bob's cellphone, or 3 to leave a voicemail message. Pressing 4 will give password-protected access to an outside line, and pressing 5 will play back today's weather forecast. We built these last two applications previously but we'll modify them a bit to support AMP's IVR design plan.

    In our last article, we covered Recording Voice Prompts with Asterisk. If you've forgotten how, go back and read that section again. Now that you're up to speed, pick up a phone and dial 456. Then say "Welcome to Bob's Place. Press 1 for Bob, 2 for Bob's cellphone, 3 to leave a message, 4 to access an outside line, or 5 for today's local weather forecast. You can also access Bob's directory by pressing the pound key." When you finish speaking, press the pound key (#) to play back and then save your recording into the /tmp folder with a filename of asterisk-recording.gsm. If you make a mistake, you just repeat the drill which will overwrite the previous file. Now go to your Asterisk terminal and login as root. Now move your recording to it's final home and delete the corresponding .wav file if it exists:

    mv /tmp/asterisk-recording.gsm /var/lib/asterisk/sounds/custom/aa_1.gsm
    rm /var/lib/asterisk/sounds/custom/aa_1.wav

    Now go back to your Mac or PC and bring up AMP using your web browser. Before we get to the Digital Receptionist, we need to make a couple additions to our extensions_custom.conf file. So click on the Maintenance tab, click Config Edit, and then click extensions_custom.conf. Insert the following code at the bottom of the file substituting your cell phone number in the last context. Then save the file by clicking the Update button.

    [custom-weather]
    exten => s,1,Answer
    exten => s,2,AGI(weather.agi)
    exten => s,3,Hangup

    [custom-callout]
    exten => s,1,Authenticate(1234588)
    exten => s,2,Background(pls-wait-connect-call)
    exten => s,3,DISA(no-password|from-internal)

    [custom-cellphone]
    exten => s,1,Dial(SIP/6781234567@bv,60,r)
    exten => s,2,Hangup

    Now go to AMP->Setup->Digital Receptionist and click Create a New Voice Menu. Provide your extension number when prompted. Ignore Step 1 and Step 2 and the error message in the Record Menu. Name your menu "Main Menu" and give a brief summary of what it is -- "Main Asterisk Autoattendant." In the Options for Menu screen, leave the context as Default, and enter 5 for the number of options. When you click Continue, you'll be prompted to actually enter your choices for the five options. Enter the following:

  • Option #1 ... click Extension button ... choose Bob's extension from pull-down
  • Option #2 ... click Custom App button ... enter the following: custom-cellphone,s,1
  • Option #3 ... click Voicemail button ... choose Bob's extension from pull-down
  • Option #4 ... click Custom App button ... enter the following: custom-callout,s,1
  • Option #5 ... click Custom App button ... enter the following: custom-weather,s,1
  • If you want a default AutoAttendant option for those that don't press any buttons, then just add a final menu selection and change it's number from 6 to the letter t (for timeout) with whatever option you want to implement for that choice.

    Now click the Continue button to save your changes and then the red bar to reload Asterisk. Then go to AMP->Setup->Incoming Calls and choose Digital Receptionist->Main Menu for both your day time and evening call answering choice. Save your changes and click the red button to restart Asterisk. You now can test your autoattendant by calling your home or BroadVoice number.

    For those that also want to control your incoming PSTN line from your Sipura SPA-3000, replace your existing exten=>99 code in extensions_custom.conf with the following. WARNING: If you cut and paste code from these articles and the code contains quotation marks (such as below), be sure to replace the WordPress-inserted, front and back quotes with normal quotation marks, or you’ll send Asterisk into the ozone.

    exten => 99,1,GotoIf($["${CALLERIDNUM:0:2}" = "00"]?2:3)
    exten => 99,2,SetCIDNum(${CALLERIDNUM:2})
    exten => 99,3,SetMusicOnHold(default)
    exten => 99,4,Goto(aa_1,s,1)

    The last line is the important one. There's a context for each autoattendant, and they're numbered starting with 1. AMP->Digital Receptionist provides the actual names (after the word "Menu").


    The Stealth AutoAttendant. For home use especially, you may prefer something a bit less intimidating for callers. Last week, we built a welcome message which said something like "Welcome to the Rockefellers. Someone will be right with you." We stored the welcome message in the custom sounds folder. This can be used as kind of a silent autoattendant. In short, for regular callers, they just hear music on hold while calls are transferred to the extensions you designate. For family that know it's really an autoattendant, you can dial certain codes to make Asterisk jump through certain hoops so long as you start dialing immediately after the welcome message begins playing. Here's how we've done it for our home. In the [from-internal-custom] context of the extensions_custom.conf file, add an extension which will trigger the AutoAttendant welcome message:

    exten => 111,1,Zapateller(answer|nocallerid)
    exten => 111,2,Wait(1)
    exten => 111,3,SetMusicOnHold(default)
    exten => 111,4,GotoIf($["${CALLERIDNUM}" = ""]?who-r-u,s,1)
    exten => 111,5,GotoIf($["foo${CALLERIDNUM}" = "foo"]?who-r-u,s,1)
    exten => 111,6,GotoIf($["${CALLERIDNAME:0:9}" = "Anonymous"]?who-r-u,s,1)
    exten => 111,7,GotoIf($["${CALLERIDNAME:0:7}" = "Unknown"]?who-r-u,s,1)
    exten => 111,8,GotoIf($["${CALLERIDNUM:0:7}" = "Private"]?who-r-u,s,1)
    exten => 111,9,GotoIf($["${CALLERIDNAME:0:7}" = "Private"]?who-r-u,s,1)
    exten => 111,10,GotoIf($["${CALLERIDNUM:0:10}" = "Restricted"]?who-r-u,s,1)
    exten => 111,11,GotoIf($["${CALLERIDNAME:0:11}" = "OUT OF AREA"]?who-r-u,s,1)
    exten => 111,12,GotoIf($["${CALLERIDNUM:0:4}" = "PSTN"]?who-r-u,s,1)
    exten => 111,13,GotoIf($["${CALLERIDNAME:0:4}" = "PSTN"]?who-r-u,s,1)
    exten => 111,14,DigitTimeout,3
    exten => 111,15,ResponseTimeout,3
    exten => 111,16,Background(custom/welcome)

    exten => 0,1,Background(pls-hold-while-try)
    exten => 0,2,Dial(local/200@from-internal,20,m)
    exten => 0,3,VoiceMail(200@default)
    exten => 0,4,Hangup
    exten => 1,1,Background(pls-hold-while-try)
    exten => 1,2,Dial(local/222@from-internal,20,m)
    exten => 1,3,VoiceMail(204@default)
    exten => 1,4,Hangup
    exten => 4,1,Authenticate(1234588)
    exten => 4,2,Background(pls-wait-connect-call)
    exten => 4,3,DISA(no-password|from-internal)

    exten => 2XX,1,Background(pls-hold-while-try)
    exten => 2XX,2,Dial(local/${EXTEN}@from-internal,20,m)
    exten => 2XX,3,VoiceMail(${EXTEN}@default)
    exten => 2XX,4,Hangup
    exten => 2XX,103,Voicemail(${EXTEN}@default)
    exten => 2XX,104,Hangup

    exten => t,1,Background(pls-hold-while-try)
    exten => t,2,Dial(local/204@from-internal,20,m)
    exten => t,3,VoiceMail(204@default)
    exten => t,4,Hangup

    exten => i,1,Playback(wrong-try-again-smarty)
    exten => i,2,Goto(111,16)

    At the bottom of the extensions_custom.conf file, add the two following contexts:

    [who-r-u]
    exten => s,1,Background(privacy-unident)
    exten => s,2,Background(vm-rec-name)
    exten => s,3,Wait(2)
    exten => s,4,Record(/tmp/asterisk-stranger:gsm|5|15)
    exten => s,5,Background(pls-hold-while-try)
    exten => s,6,Goto(ext-park,70,1)
    exten => s,7,VoiceMail(200@default)
    exten => s,8,Playback(Goodbye)
    exten => s,9,Hangup

    [ext-park]
    exten => 70,1,Answer
    exten => 70,2,SetMusicOnHold(default)
    exten => 70,3,ParkAndAnnounce(asterisk-friend:/tmp/asterisk-stranger:vm-isonphone:at-following-number:PARKED|40|local/222@from-internal|who-r-u,s,7)
    exten => 70,4,Hangup

    Now create an additional extension on your Asterisk server to process incoming calls, e.g. 205. Using a softphone, connect to that extension and then place a call to *72111 which tells Asterisk to forward incoming calls on this extension 205 to extension 111. You never have to touch extension 205 again. Now using AMP->Setup->Incoming Calls, send incoming calls to extension 205. We have to jump through the double extension hoop (205 and then 111) because AMP only recognizes extensions created in AMP and not custom extensions which you've built in extensions_custom.conf. If you want to extend this to also manage your SPA-3000 incoming PSTN calls, then you'll need to modify your exten=>99 block of code from last week to call extension 205 (only!).


    Let's cover a little of what the code above actually does so that you can make changes and enhancements if you want to. The exten=>111 section of the code actually processes the incoming call to this extension. Zapateller is a special information tone which will be played to callers who have CallerID disabled. It also causes most automated telemarketing systems to hang up and place your phone number in their Do-Not-Call database. Others won't hear the tone sequence at all. Lines 4 through 11 attempt to identify all the various messages which are sent when someone has CallerID disabled. Lines 12 and 13 handle incoming PSTN calls with no CallerID from your SPA-3000. If there's any match, these callers will be prompted to say their name after which their call will be parked automatically on an extension (beginning with 71). Asterisk figures out the next empty parking space so you don't have to worry about it. You do need to modify the [ext-park] context code (line 3) to specify the extension, extensions, or ring group where you want this incoming call announced. We use 222 as a ring group for our entire house. So our phones will ring, we answer, and Asterisk says "Asterisk is your friend. John Doe is on the phone at the following number: 71." John Doe is whatever name the caller recorded above in the caller's own voice. We then hang up the phone, pick it up again, and dial 71 to connect to John Doe, who is listening to music while waiting. If you don't want to talk to John Doe, then don't dial 71 and sooner or later John Doe will get tired of the elevator music and hang up. Actually exten=>s,7 specifies which voicemail account will be used in the event of no parked call answer within 40 seconds. Be sure to change it to one of your working voicemail extensions.

    For incoming callers with CallerID, the system will play "Welcome to the Rockefellers. Please hold while we connect your call." Music on hold plays and the extension, extensions, or ring group specified in exten=>t,2 (we use 204 for our cordless phones) will ring assuming the caller presses no buttons. If there's no answer in 20 seconds, exten=>t,3 sends them to voicemail for extension 204. You can change these extensions to suit your needs. The exten=>2XX code block allows callers (who know our little secret) to actually dial a 200-299 extension within our home. If your extensions are numbered differently, just modify 2XX to match them. The exten=>0 code rings our office if someone presses 0. The exten=>1 code rings our ring group (all phones) if someone presses 1. And the exten=>4 code prompts for a password (1234588) and then gives outside dial tone to place a call through BroadVoice or the PSTN line or our other VoIP providers. If the caller enters any other number, the exten=>i code block plays a "try again, dummy" message.

    Special Filters for Special People. Finally, if you're like most mere mortals, there are some "special" callers with CallerID enabled that you'd just prefer to never speak to again. Remember, if someone turns off CallerID, we'll catch them in our [who-r-u] tangled web. But for old girlfriends, ex-wives, and former stock brokers, we need some special processing. Asterisk handles this with ease in a couple of different ways. We'll cover the blacklist database in a future article but, for now, just add lines like the following at the top of the exten=>111 code above substituting the actual area code and numbers of the people you want to block:

    exten => 111/2565551212,1,Congestion
    exten => 111/6785551212,1,Congestion
    exten => 111/3215551212,1,Congestion

    Why Use Asterisk@Home and Not Roll Your Own? One of our favorite pundits on Voxilla summed it up this way:

    After using Asterisk@Home for three months, we haven't found a single thing we couldn't do that someone with a roll-your-own version of Asterisk could. Asterisk@Home is not crippled in any way. In fact, it's just the opposite. It's not only full-blown Asterisk but it's also AMP (Asterisk Management Panel, think of it as PHPmyAdmin for Asterisk) plus functioning music on hold (just try to get it working on a vanilla Linux box!) plus voice support for any speech application you can dream up plus a Flash Operator Panel plus ring groups plus calling queues plus conferencing plus DID routing plus SQL-compliant Call Detail Reporting plus SugarCRM contact management with integrated dialing plus SpanDSP fax support plus Microsoft Outlook TAPI integration with a Microsoft TAPI gateway (that works!) plus Apache, PHP, SSH, SFTP, SendMail, Web Mail, and MySQL integration plus Cisco XML support (to load your contact management info into your Cisco IP phones) plus xPL for Home Automation plus H.323 NetMeeting support plus turnkey support for SIP, IAX2, auto-configuring ZAP channels, and ENUM.

    What we have found is that we can implement solutions for clients in a couple of minutes or hours that would have taken weeks or months to learn to do had we gone the roll-your-own route. That includes building IVR and AutoAttendant solutions literally in minutes, supporting five or more VoIP providers and numerous departments each with numerous phones of all flavors, implementing complex dialing rules, remote phone access, voicemail with email and SMS alerts, and out-of-the-box support for virtually every 3-digit calling feature provided by local Baby Bells.

    Are there folks that want to master calling plans, extension syntax, contexts, Linux, Apache, SendMail, MySQL, PHPmyAdmin, WebMin, Web Mail, Asterisk and all its add-on's plus Linux dependency hell? Absolutely. But Asterisk@Home doesn't preclude your using anything you learn. It just gives you an incredible, leveraged head start. Asterisk@Home is a deceptive moniker. It's not stripped-down, crippled, or condensed in any way. Quite the contrary, it's Asterisk on Steroids, plain and simple. Worked great for Major League Baseball, didn't it?

    Amen, Brother! Well, we've covered a lot of territory today. It ought to be sufficient to keep you busy while we think of something else to write about. Enjoy!


    Some Recent Nerd Vittles Articles of Interest...


    35 Comments

    1. Greetings. Congratulations on another excellent tutorial! I’ve read and re-read this and the previous tutorial and am having an issue that I can’t seem to figure out. I’m able to successfully connect to the Digital Receptionist when I dial my Broadvoice number (as a result of the DID being directed to the Digital Receptionist), but am unable to connect when dialing the PSTN number. I believe this is because the Sipura dial plan directs the incoming PSTN number to extension 99 (which in turn rings extension 204 as per your previous tutorial). I tried to setup a dial plan that directed to another DID I setup but alas it did not work. Are you aware of anyway to direct either extension 99 or 204 to the Digital Receptionist? Any assistance would be most appreciated. Again, thanks for the great how-to’s for us Asterisk newbies!

      [WM: This oughta do the trick. Replace your existing exten=>99 code in extensions_custom.conf with the following:

      exten => 99,1,GotoIf($["${CALLERIDNUM:0:2}" = "00"]?2:3)
      exten => 99,2,SetCIDNum(${CALLERIDNUM:2})
      exten => 99,3,SetMusicOnHold(default)
      exten => 99,4,Goto(aa_1,s,1)

      The last line is the important one. There’s a context for each autoattendant, and they’re numbered starting with _1. AMP->Digital Receptionist provides the names after the word "Menu." Let me know if you have any further problems.]

    2. I created an IVR and everything works great. How can I redirect the call for example into a queue or into voicemail if no number is pushed.
      Right now the IVR just hangs the call up.

      [WM: Great question, and I’ll add the answer to the body of the article as well. If you want a default AutoAttendant option for those that don’t press any buttons, just add a final menu selection and change it’s number to the letter t (for timeout) with whatever option you want to implement for that choice.]

    3. Great tutorials. I have been going through them and following them for a few weeks, however I ran into some problems with this one and cannot seem to figure it out. If I follow the steps on the tutorial for creating the 5 extensions, I can connect to my broadvoice line for about 7 seconds but do not hear the digital receptionist, then I am disconnected from the line. If I choose to add a time out option I am forwarded directly to whichever value I choose. Any ideas on what might be missing?

      [WM: Carefully check for typo’s and missing punctuation. Also be sure all quotation marks are real ones, not WordPress typesetting quotation marks.]

    4. I know this has gotta be an easy one, but I’m pulling my hair out over it and haven’t been able to find the answer anywhere. I (prematurely?) cancelled my BroadVoice account, and now want to forward calls to my cellphone via GoIAX.com. What dial string do I use since I am connecting to them via IAX2? I tried replacing SIP with IAX2 and bv with goiax rather expecting it wouldn’t work (and it didn’t). Looking forward to any suggestions.

      [WM: Here’s the syntax: exten => 2355,1,Dial(IAX2/goiax/16781234567). But, if you’re merely forwarding incoming PSTN calls, you should be able to do that by activating call forwarding with *70 from an extension and then plug in your cellphone number. ]

    5. hello awesome user guides 🙂 I how ever am wanting to do the following I didn’t see this senario listed in any of your guides. what I am wanting to do is I have 2 people on my phone system, my friend, and myself. I have myself as ivr minue 1 and my friend as ivr 2. eg 1 goes to my extention 202 and 2 goes to my friends extention 203. when I press 1 or 2, when I call from another phone or when ever some one calls my pbx for that matter they hear the ringing sound, how can I tell the pbx to play music on hold while the phone is ringing the extention?
      also one thing I also didn’t see mentioned is having it say please hold while I transfer you to that extention before the music on hold when some one presses the ivr minue is this possible as well? if so can you please tell me how to impliment these 2 features? thanks hank ps. keep up the awesome work!!! 🙂

      [WM: Just add some code like the following to the [from-internal-custom] context in extensions_custom.conf. The m in the Dial string gets you music. Line 1 gets you the "please hold" message. For a complete list of the available sounds that come with Asterisk@Home, go here and here.

      exten => _20X,1,Background(pls-hold-while-try)
      exten => _20X,2,Dial(SIP/${EXTEN},20,m)
      exten => _20X,3,VoiceMail(${EXTEN}@default)
      exten => _20X,4,Hangup
      exten => _20X,103,Voicemail(${EXTEN}@default)
      exten => _20X,104,Hangup

      That should do it.]

    6. Again, awesome tutorial
      Perhaps I missed this somewhere put did you cover the "record on demand" feature in the extension setup?
      -Does it work yet or do you know anything about it ?
      I know you have to check it during setup of extensions but doesn’t work right off the bat; I would imagine it needs some sort of alterations any help would be appreciated!!
      Todd

    7. Thank you for the user guides. They are excellent real world example of how to setup Asterisk.

      I am running into a small problem with trying to get a filename variable set to the current time. Is there a way to do this in Asterisk?

      I am currently using something like this:
      exten => s,1,SetVar(FileName=${SystemTime})

      I have also tried {DateTime}, {TimeDate}, {Now} and several others, all of which do not work. is there a way to get the current system time?

    8. Great work! This page has helped me.
      As most others.. I have a remaining problem.
      I’ve setup the digital receptionist, and it performs fine if I simulate an external call (7777). If I call from my SIP trunk however, I get the receptionist, but pressing any dtmf tone hangs up the phone.
      If I use a Queue, and then have the receptionist answer, dtmf tones work fine.
      Any help would be appreciated!

    9. Just wanted to make one comment on these great tutorials. Setting up the digital receptionist with a broadvoice account can sometimes cause an issue where the options selected by an outside caller will be ignored, however when using 7777 everything works perfectly. This is due to the fact that by default the DTMF mode for broadvoice on the outgoing trunk is set to inband. If you change it to RFC2833 for the outgoing trunk everything will work perfectly. Not sure why this is the case since the DTMF tones for outgoing connections should have no impact on the incoming caller, but it resolves the issue with no trouble. Also this problem will not happen with every caller. From what I noticed it was primarily an issue when I had people calling from other VOIP providers or Cellular phones. All calls coming from a standard PSTN seemed to work fine.

    10. You have some great articles and howtos… A lot of the time I am travelling, and some times I am in locations where I don’t have access to broadband… Is there way way to do an auto conversion to save your articles as pdf or at the very least be able to make the html into a single file for print out?

      Just a thought…

    11. You are keeping me very busy with all these great articles. I’ve run into a small problem when trying to implement stealth attendant with AAH2. Zapateller works as it should be when my cid number is present I’m presented with the privacy prompt and when I block my incoming number I’m then put through as if I had a valid CID. For whatever reason it’s reveresed. Any ideas.

      Thanks
      That_Kid

      [WM: Check carefully for typos.]

    12. I’m trying to implement the CallerID detection script as shown in this article, but it’s not working for me. When I call in to the PBX with caller id withheld, my call goes right through to my autoattendant. I don’t get the prompts asking for the callers name, etc.

      Here is a portion of my call output
      ——————————————–
      dialparties.agi: Dial string is Local/111@from-internal|30|tr
      — AGI Script dialparties.agi completed, returning 0
      — Executing Dial("Zap/1-1″, "Local/111@from-internal|30|tr") in new stack
      — Executing Wait("Local/111@from-internal-a0e8,2″, "1″) in new stack
      — Called 111@from-internal
      — Executing SetMusicOnHold("Local/111@from-internal-a0e8,2″, "default") in new stack
      — Executing GotoIf("Local/111@from-internal-a0e8,2″, ""?¢ÀÜ?°?É‚Ä??Ǭ¨?Ǭ¢"?who-r-u|s|1″) in new stack
      — Executing GotoIf("Local/111@from-internal-a0e8,2″, ""foo?¢ÀÜ?°?É‚Ä??Ǭ¨?Ǭ¢foo"?who-r-u|s|1″) in new stack
      — Executing GotoIf("Local/111@from-internal-a0e8,2″, ""?¢ÀÜ?°?É‚Ä??Ǭ¨?Ǭ¢Anonymous"?who-r-u|s|1″) in new stack
      — Executing GotoIf("Local/111@from-internal-a0e8,2″, "0?who-r-u|s|1″) in new stack
      — Executing GotoIf("Local/111@from-internal-a0e8,2″, "0?who-r-u|s|1″) in new stack
      — Executing GotoIf("Local/111@from-internal-a0e8,2″, ""?¢ÀÜ?°?É‚Ä??Ǭ¨?Ǭ¢Private"?who-r-u|s|1″) in new stack
      — Executing GotoIf("Local/111@from-internal-a0e8,2″, "0?who-r-u|s|1″) in new stack
      — Executing GotoIf("Local/111@from-internal-a0e8,2″, ""?¢ÀÜ?°?É‚Ä??Ǭ¨?Ǭ¢OUT OF AREA"?who-r-u|s|1″) in new stack
      — Executing GotoIf("Local/111@from-internal-a0e8,2″, "0?who-r-u|s|1″) in new stack
      — Executing GotoIf("Local/111@from-internal-a0e8,2″, "0?who-r-u|s|1″) in new stack
      — Executing DigitTimeout("Local/111@from-internal-a0e8,2″, "3″) in new stack
      — Set Digit Timeout to 3
      — Executing ResponseTimeout("Local/111@from-internal-a0e8,2″, "3″) in new stack
      — Set Response Timeout to 3
      — Executing BackGround("Local/111@from-internal-a0e8,2″, "custom/aa_1″) in new stack
      — Local/111@from-internal-a0e8,1 answered Zap/1-1
      — Playing ‘custom/aa_1’ (language ‘en’)
      ———————————————————–
      How can I fix this?

      [WM: Replace the typographic quotation marks in the script with regular quotation marks.]

    13. I currently have an X-Lite SIP phone, Analog phone and Polycom 300 SIP phone associated with a PBX running @Home. Just today, I was successful at finally configuring the Polycom to ring. However, I can’t seem to get it to dial out. Always get a quick 3 busy signals and then silence. Would be more than happy to supply whatever info’s needed to better explain the problem, with hopes of help at reaching a solution.

      [WM: Your best bet is one of the forums we’ve recommended in our columns: SourceForge or Voxilla.]

    14. Ward, your tutorials rock. I could have not learned Asterisk without your help. I am trying to implament Find Me Follow Me. I have it working internally, but since the new version of asterisk uses the dialparties.agi I cannot seem to get it to work. This is what I have in my [from-internal]
      exten => 202,1,dial(sip/202,20)
      exten => 202,2,playback(pls-wait-connect-call)
      exten => 202,3,Setvar(NewCaller=${CALLERIDNUM})
      exten => 202,4,SetCIDNum(0${CALLERIDNUM})
      exten => 202,5,dial(IAX2/voipjet/19999999999,20,m)
      exten => 202,6,SetCIDNum(${NewCaller})
      exten => 202,7,voicemail(u202@default)
      exten => 202,101,voicemail(b202@default)
      exten => 202,102,hangup

      If you can help that would be great.

      Chris

    15. How about making the autoattendant to call back any caller, as soon as an agent picks up the phone, instead of placing the caller in an ordinary que wor wait? =)..

    16. HI there,

      i have setup my asterisk@home+spa300 using your great guide. Anyway i have a stange propblem with digital recepcionist.

      I’m using:

      exten => 298,1,GotoIf($["${CALLERIDNUM:0:2}" = "00?]?2:3)
      exten => 298,2,SetCIDNum(${CALLERIDNUM:2})
      exten => 298,3,SetMusicOnHold(default)
      exten => 298,4,Goto(aa_1,s,1)

      Thats fine..i set digital recep. with several options and so..the problem is:

      – when caller push 1 it gos to extension sip softphone 201 , thats working fine

      – When caller push 2 it goes to extension sip line1 sipura , so cordless phone should ring, but it doesnt work fine, it repeats 1st recepcionist message aa_1 .

      When i use simply pstn->sip extension incoming calls, i can set cordless ext. fine, it rings fine and i can talk fine.

      So whats wrong?

      [WM: Look through your [from-internal-custom] context in extensions_custom.conf for all the entries that start with exten=>2,… All of those get processed every time there is an incoming call. Be sure you don’t have one in there that you didn’t remember.]

    17. Ok, I have become spoiled… I really like the idea of utilizing non-CID people having to come throught the who-r-u to park calls. I would like to go one step further, and utilize for people with CID. I am thinking that I could add the user along with their CID in the ast_db. Then, using festival, the name could be sent, and the option would still exist to pick up the call or force to vm.

      I wonder if that is do-able?

      [WM: Absolutely. We prefer MySQL for the task since storing data in ast_db is sorta like putting your address book in the Windows Registry, but each to his or her own. Here’s a link that will give you some ideas and get you started.]

    18. Again, great articles. Would you consider writing a more technical piece on what is really going on behind AMP with the .conf files? All AMP is doing is managing a MySQL database with the same info and writing out to the .conf files, right? I’d like to learn more about digging into the guts to customize things even more than we have already but I still don’t really understand the architecture of what is going on with the various .conf files and [contexts], etc., or even the syntax of how some of the code you’ve written works.

      [WM: Bill, If I had to dig into AMP that deeply, I’d be tempted to rewrite it. But, at least today, I’m not that tempted. Like a lot of developers, the AMP folks appear to have intentionally made a lot of the code obscure to preserve their turf. But who knows maybe these guys are so smart that they actually like drawing pictures based upon reflections in the mirror.]

    19. Ok, so you rock – what a great resource. I would like to agree with the using Asterisk@Home vs. rolling your own. However – I need the 64-bit flavor of CentOS 4.2 AND the ability to do RAID. So I’d like to simply make my own base system configured in those two basic ways… and then run the AAH installer on-top of it. However, for the life of me – I can’t find any detailed source that says what basic packages I need to tell CentOS to install during its stand-alone install so that AAH has everything it needs. Any guidance here? Keep up the great work!!

    20. Regarding the IPKall setup, can you please explain why the ports 5060 thru 5082 need to be opened? I have only ever seen (on other tutorials) the need to open 5060, as opposed to said range of ports. I have only 5060 open, and seem to get good performance. I guess I have always found SIP ports kinda mysterious, anyways…

      [WM: It depends upon the provider. This range covers most of them that we’ve encountered.]

    21. Great tutorial. I have most of it working except for the piece about getting all phones in the house to ring.

      You indicate:
      "You do need to modify the [ext-park] context code (line 3) to specify the extension, extensions, or ring group where you want this incoming call announced. We use 222 as a ring group for our entire house."

      I use AMP to create a Ring Group, which created Ring Group 1. It has 5 extensions in it. So I tried the following:
      exten => 70,3,ParkAndAnnounce(/tmp/asterisk-stranger:vm-isonphone:at-following-number:PARKED|40|local/1@from-internal|who-r-u,s,7)

      But that doesn’t work. I am not sure what to change "local/200@from-internal" to to reference a ring group instead of an extension.

      Any suggestions?

      Thanks and I will keep reading these great tutorials.

      Dave

      [WM: I wouldn’t use 1 for a ring group. Think of that number as the extension you dial to ring all the phones in the ring group. That’s why we use 222. Normally, the syntax for ringing a ring group is Dial(local/222@from-internal,18,m) where 222 is the ring group, 18 is the time to ring the extensions, and m means play music on hold while ringing. This may not work with Call Parking but it works fine in your normal dial plan.]

    22. Awesome tutorial!!!

      I am trying to setup an autoattendant that dials my cellphone when someone calls my home and I’m not there. The problem is in waiting 10/20/30 seconds for me to pick up my cellphone before returning to my asterisk voicemail. If for example, my cellphone is off, my cellphone voicemail will pickup immediately, and the caller will not get a chance to leave a voicemail message on the asterisk machine, but rather on my cellphone.

      Is there a way to have me autheticate and/or accept the incoming call on my cellphone, or else the call is transfered back to asterisk voicemail? Essentially, this way it will never seem to an outside caller that the call was transfered to my cellphone (i.e. they will never get my cellphone voicemail).

      Thanks a ton, keep up the awesome discoveries.

      Chris

    23. What if I want to use my FXO card "ZAP/1″ instead of a SIP account for giving the option to call my workphone:

      exten => s,1,Dial(SIP/6781234567@bv,60,r) should it be this instead:
      exten => s,1,Dial(ZAP/6781234567@1,60,r)

      Also, after my main message is played it takes a while to ring to my default extension which is 201. i have the t option set.

      My main message is like: "You have called Kim’s asterisk PBX system (Want to show off others ;)) please wait a moment while you’re call is being connected. If it is an urgent matter you can dial 5 to connect to my work phone"

      Then I have 2 other hidden options: one for DISA and other is the ‘t’ option which is basically going to my default ext 201. And for 201 I have voicemail. So what I want is to minimize the wait time before I can hear ring back tones calling my 201 extension. Also there is a long silect between. Can you help….

    24. I have one problem with auto attendent – it all works, and the volume is great from any extensions, but incoming callers ona pstn (X100P) card hear the recording at very low volume. Any suggestions?

    25. What about those of us who arent quite ready to jump in with both feet just yet. Can I do something simple like not actually have asterisk take control of an incoming POTS call but just ring extensions on asterisk? That way I can let my ‘old fashioned’ voice mail still take over, or if I want to answer the call on a pots phone I still can, but if I do pick up an asterisk extension thats ringing, it would then grab the POTS call. (I am playing with Asterisk@Home with just soft phones at this point.. no real outside world connections just yet)

      [WM: You’ll need to buy a Sipura SPA-3000. Then just follow our tutorial to get it going, and you can do exactly what you suggest.]

    26. "If you want to extend this to also manage your SPA-3000 incoming PSTN calls, then you’ll need to modify your exten=>99 block of code from last week to call extension 205 (only!)."

      For the benefit of newbies like me, can you please provide the exten=>99 code to support the SPA-3000?

      [WM: Someone did it for me. Here’s the link.]

    27. Why are these lines duplicated in the exten => 111 block?

      exten => 111,8,GotoIf($["${CALLERIDNUM:0:7}" = "Private"]?who-r-u,s,1)
      exten => 111,9,GotoIf($["${CALLERIDNAME:0:7}" = "Private"]?who-r-u,s,1)

      exten => 111,12,GotoIf($["${CALLERIDNUM:0:4}" = "PSTN"]?who-r-u,s,1)
      exten => 111,13,GotoIf($["${CALLERIDNAME:0:4}" = "PSTN"]?who-r-u,s,1)

      [WM: Some providers sent Private as the number and others send it as the name. Same with PSTN.]

    28. I have developed some rather sophisticated IVR systems using Dialogic boards connected to all types of PBXs. I want to convert them to use Asterisk and assume I need to use the IAX library and look like a softphone – however, I don’t find any documentation on using that interface – any suggestions or recommendations?

    29. My comment is exactly the same as "Steve" above. Number 25…

      "I have one problem with auto attendent – it all works, and the volume is great from any extensions, but incoming callers ona pstn (X100P) card hear the recording at very low volume. Any suggestions?"

      How would I go about raising the volume on the auto attendent? Any suggestions would be greatly appreciated.

      Thanks!

      -Adrian

      [WM: Solved in TrixBox.]

    30. Hi,

      I’m dialling out using PRI. After about 10Sec I’m getting busy tone when the remote side didn’t answer.
      Is this value can be reconfigured??.

      TIA,

    31. Wow, this is great stuff! The who-r-u context for unidentified callers is a fantastic idea; however, there is one thing that bugs me a bit. If an unidentified caller does not record their name and press pound, the script still parks the call and announces a blank name prompt. It would be awesome if the script could recognize that the caller never pressed pound and send the call directly to voicemail (or something else).

      [WM: This article was written a long time ago when I, too, was a "newbie." I’ll have another look at it in the "modern" context of TrixBox. Thanks for the suggestion.]

    32. I just wanted to comment that I think you have missed one of the best deals around

      1 cent per minute to all of USA and Canada!

      Take a look at GenericVoIP.net they are now making some changes and will soon be offering more destinations on the 1 cent per minute calling. They do now also support caller ID contrary to what the web site still says. It is truly a good deal.

      [WM: Heh, heh. OK, I’ll post your comment but not without a few of my own. First, if you thought TelaSIP has a lousy web site, you’ll love this one. Second, if you want CallerID, that ups the price to 1.7¢ per minute. Then there’s the little matter of rounding calls to the whole minute. Gee, what a deal! Finally, there’s the fine print (and more) below. So… I think I’ll pass.]

      *Price quoted is cash price. PayPal price is 4% more. Credit Card is 5.5% more. USA 48 at 1 Cent Per minute requires a minimum of 5000 minutes per month, funded with a single payment of $50.00 per month. A minimum usage of $50.00 per calendar month applies to all $0.01 per minute accounts. All calls billed in 60/60 Intervals. USA 1 Cent accounts do not allow international calls. Use of PayPal requires a VERIFIED PayPal account. USA 48 / Canada $0.017 accounts with no outbound traffic for 60 days are subject to deletion.

    33. I love the tutorials here. Is there a way to tie the Stealth autoattendant to just one of the trunks instead of all of them? Thanks.

      [WM: Sure. That functionality is now built into the new inbound trunks setup in freePBX. Just use one of our preconfigured TrixBox systems at the top of the page to get started.]

    Comments are closed.