Showing posts with label voip. Show all posts
Showing posts with label voip. Show all posts

30 July 2005

Calling Features With Asterisk


In the past couple of days I’ve added a few useful calling features to the Asterisk installation we use for handling the calls to our household. These calling features would cost another $10-15 per month from the local RBOC if we wanted them normally. We’d just as soon not get nickeled and dimed for these though since they can be done for free.

There are snippets below to help the aspiring Asterisk user add these call features to their own system.

Caller-ID based Blacklisting

This feature takes incoming calls from specific folks that call a little too much and sends them somewhere that won’t make our phone ring. If the friendly, well-meaning vampires at the local blood bank are calling you twice every day, this is for you.

macro-stdexten

[incoming]
exten => s,1,Macro(stdexten,1234,SIP/MyInternalLine)


Now, in the macro-stdexten we tell it to check the blacklist. Key lines for this function are s,1 and s,102. The other lines are relevant to things I’ll cover later.


[macro-stdexten]
exten=s,1,LookupBlacklist ; If CID blacklisted, goto 102
exten=s,2,DBget(temp=CFIM/${ARG1}) ; Get CFIM (Call Forward IMmediate) key, if there isn't one, goto 103
exten=s,3,Dial(Local/${temp}@local/n) ; Unconditional forward
exten=s,4,DBput(lastcaller/${ARG1}=${CALLERIDNUM}) ; Note the last caller
exten=s,5,Dial(${ARG2},20) ; Call the extension with a 20 sec timeout
exten=s,6,DBget(temp=CFBS/${ARG1}) ; Get CFBS (Call Forward BuSy) key, if there isn't one, goto 107
exten=s,7,Dial(Local/${temp}@local/n) ; Forward on busy or unavailable
; Blacklisted CallerID
exten=s,102,Goto(blacklisted,s,1)
; No CFIM key
exten=s,103,Goto(s,4)
; No CFBS key = goto voicemail
exten=s,107,Answer
exten=s,108,Wait(1)
exten=s,109,Voicemail(u${ARG1})


So now people that have their phone numbers in the blacklist will get sent to blacklist s,1. We’d best define that…


[blacklisted]
exten=s,1,Answer
exten=s,2,Wait(1)
exten=s,3,Playback(nbdy-avail-to-take-call)
exten=s,4,Playback(carried-away-by-monkeys)
exten=s,5,Playback(lots-o-monkeys)
exten=s,6,Hangup


Now, I think the monkeys make the whole calling experience a lot more fun for the caller. If you want them to hear something more dignified you could always go for Playback(not-taking-your-call).

You can add and remove numbers from the blacklist by using the Asterisk console and database put blacklist 2025551212 1 and database del blacklist 2025551212. But it would probably be better if you could configure this from your phone so…


[blacklist-add]
exten=s,1,Playback(enter-num-blacklist)
exten=s,2,DigitTimeout(5)
exten=s,3,ResponseTimeout(30)
exten=_X.,1,DBput(blacklist/${EXTEN}=1)
exten=_X.,2,SayDigits(${EXTEN})
exten=_X.,3,Playback(num-was-successfully)
exten=_X.,4,Playback(added)
exten=_X.,5,Hangup

[blacklist-remove]
exten=s,1,Playback(enter-num-rmv-blklist)
exten=s,2,DigitTimeout(5)
exten=s,3,ResponseTimeout(30)
exten=_X.,1,DBput(blacklist/${EXTEN}=1)
exten=_X.,2,SayDigits(${EXTEN})
exten=_X.,3,Playback(num-was-successfully)
exten=_X.,4,Playback(removed)
exten=_X.,5,Hangup


If you are following the calling feature codes that are used in the United States, users should be able to do blacklist-add with *60 and blacklist-remove with *80.

Call Forwarding

Most of the logic for call forwarding is in the macro-stdexten above. If the call forwarding is configured, we send the call to that number. If you just have one PSTN line like we do, you’ll have to be able to route those forward calls over a VoIP provider, since the PSTN line may already be used up by the incoming call.

The main thing is simply to let people configure the call forwarding using a prompt system similar to the one we just used for the blacklist configuration. There are again standard calling feature codes for unconditional call forwarding in the United States. Activating call forwarding is *72 and deactivating is *73.


[callfwd-add]
exten=s,1,Playback(please-enter-the)
exten=s,2,Playback(call-forwarding)
exten=s,3,Playback(telephone-number)
exten=s,4,DigitTimeout(5)
exten=s,5,ResponseTimeout(30)
exten=_X.,1,DBput(CFIM/${CALLERID}=${EXTEN})
exten=_X.,2,Playback(call-forwarding)
exten=_X.,3,Playback(has-been-set-to)
exten=_X.,4,SayDigits(${EXTEN})
exten=_X.,5,Hangup

[callfwd-remove]
exten => s,1,Answer
exten => s,2,Wait(1)
exten => s,3,DBdel(CFIM/${CALLERIDNUM})
exten => s,4,Playback(call-fwd-cancelled)
exten => s,5,Hangup


Last Call Return

So again, part of what lets this work is in macro-stdexten s,4 above where the last call to each extension is recorded into the database for posterity. Then we can offer last call return when people dial *69 with the following snippet:


[app-lastcallreturn]
exten => s,1,Answer
exten => s,2,Wait(1)
exten => s,3,Playback(last-num-to-call)
exten => s,4,DBget(number=lastcaller/${CALLERIDNUM}) ; goto 105 if no lastcaller
exten => s,5,GotoIf($"${number}" = ""?105,1) ; also if it's blank (caller id blocked)
exten => s,6,SayDigits(${number})
exten => s,7,Wait,1
exten => s,8,Playback(to-call-num-press)
exten => s,9,Playback(digits/1)
exten => 1,1,Goto(longdistance,1${number},1)
exten => s,105,Playback(unidentified-no-callback)
exten => s,106,Hangup


Summary

Most of this was adapted from examples at www.voip-info.org where there is a nice wiki with Asterisk information. I made an effort to clean up some of the examples they had and try to use the more standard vertical service codes. Hopefully this is useful to folks.


30 March 2005

Can You Hear Me Now?


We’ve had one more hiccup in VoIP land. At first, we had only one provider for connecting long distance calls, SimpleTelecom. I’m not really sure what is wrong for them right now, but they aren’t completing calls. The IAX2 connector says “circuit-busy” and their call detail record says “Forbidden”. In any case, my call is not being connected and I want to talk to people. Good thing there are plenty choices and I’m not tied down.

In 15 minutes I setup an account with a competing long-distance provider, Teliax. Then with a small amount of change on the machine here, I was able to setup this new provider to be used in the event the first provider failed to complete my call. Voices didn’t transmit correctly when G729 compression was used, but forcing the call to G711-u seemed to fix things.

It was nice that adding new providers went relatively easily. On the other hand, people who get the “ready for your mother to use” services like Vonage, Packet8, and AT&T’s CallVantage are locked out of ever using another provider the same way people are traditionally used to with their normal plain old telephone service. When they have problems, there is no shopping for someone else that is working in the meantime. Vendor lock-in can be a bummer.


17 March 2005

Brave New VoIP World


We’ve made the plunge into the VoIP (Voice over IP: transmitting telephone calls over the Internet) world. After a few months of paying $20 a month on long distance I figured there must be better way. Our local phone company’s best plan without a monthly fee is 18¢ per minute. AT&T has a no monthly fee plan for 10¢ per minute, except that you pay a much higher rate for in-state long distance. MCI doesn’t even offer a no monthly fee plan any more.

Enter Internet long distance. A variety of VoIP companies offer long distance to the anywhere in the US, Canada, and most of western Europe for 2¢ per minute or less. No monthly fee. The only catch is that you have to get your call onto the internet. There are services that bundle a whole telephone line over the internet with long distance, a new phone number, and an interface box. These services also generally cost at least $20 per month. Worse yet, being a DSL customer out in the sticks, we can’t get DSL without a plain old telephone line. No use paying for two phone lines.

But you aren’t stuck with a package deal, you can always get your own interface box and buy your own long distance and still use the existing phone line you already have. In our case we got a Sipura SPA-3000 from AsteriskMall and setup Asterisk on a spare computer. With some amount of configuration work, we’ve got outgoing local calls still traversing the POTS line, outgoing long distance going over the Internet to our VoIP long distance provider (saving us 8-16¢ per minute), and incoming calls coming in over the POTS line. There are also some special numbers we can use to make free VoIP calls to other folks on the Internet like IAXtel’s 1-700 numbers and Free World Dialup. Free World Dialup in particular has free calling to anyone with the most popular bundle providers (Packet8, Vonage, etc.).

In the long run, our investment in the interface box will pay for itself in long distance savings in half a year. And since we still have our normal phone line which the interface box will fall back to automatically when there is a power outage we still get the E911 service, even when the power and/or Internet connection are not working.

This isn’t to say that this hasn’t been a bit of an adventure. The SPA-3000 has over one hundred configurable parameters and getting it configured correctly involved a lot of trial and error. (By the way, thanks to our parents who have been very kind about our phone calls as we try and get things working. “Can you hear me now?”) Voice quality has been fairly good though. The delay hasn’t been quite as bad as I had expected. It’s slightly better delay-wise than satellite calls across the Atlantic, but this depends on how Internet traffic is between our home and


  • Calls going out the POTS line are too quiet for both parties

    • Solved by increasing the PSTN Line “SPA to PSTN Gain” and “PSTN to SPA Gain” settings to 5 (dB presumably)



  • Calls going out the VoIP long distance have an echo for the people we call

    • Possibly solved by setting SIP “RTP Packet Size” to 0.010 (seconds)



  • Calls either way on the POTS line can’t make DTMF tones (touchtones) in call

    • No resolution yet



  • Calls either way on the POTS line rarely have an echo back to our phone when both sides are talking

    • No resolution yet


There is still a long ways we can go with this too. Now that we have Caller ID incoming calls can get special treatment depending on who they are and we can get some more powerful voice mail service as well.

Your call is important to us. Press 1 to learn about why paying for long distance service from the old communication monopolies is going to be obsolete in a dozen years…