| macVoIP.com the web home of Ted Wallingford |
|
|
|
Link Asterisk to Skype
Excerpted from my book VoIP Hacks (O'Reilly Media) They said it couldn't be done without the Skype API. They were wrong. Wouldn't it be great if your Asterisk server could place calls to (and receive calls from) the Skype network? Imagine the possibilities-putting your Skype buddy list within reach of the Asterisk dialplan so all your calls can be routed to the appropriate Skype buddy depending on what you dial on your Asterisk-connected phone. Well, that dream is now a reality-with a few gotchas.
Connect a standard RJ11 phone cord from the telephone jack on the Internet Phone Wizard to an FXO port on your Asterisk box. This FXO port may be on a Digium TDM400P, X100P, or Sangoma Wanpipe PCI card (several examples for setting up the TDM400P are given in Chapter 4). Configure the Zaptel channel for this FXO port as you normally would if you wanted to connect the Asterisk server to a standard phone line. (The standard phone line is going to substituted by the connection from the Internet Phone Wizard.) Next, you'll need to add your Internet Phone Wizard speed-dial numbers to your Asterisk dial-plan so that they'll be dialed via the Zaptel FXO channel. (Remember, I'm assuming you've already set up your speed dial numbers on Skype using the Internet Phone Wizard, so if you haven't, flip back to [Hack #Hook Your Old Home Phone up to the Skype Network].) In your default Asterisk context for the phone you're going to be calling from, add something like this: exten => 71,1,Dial(Zap/1/71) exten => 72,2,Dial(Zap/1/72) exten => 73,3,Dial(Zap/1/73) If you had buddies with speed-dial numbers of 71, 72, and 73, the Asterisk server would attempt to call them on Skype via the connected Internet Phone Wizard. Of course, all the Asterisk box sees is the Zaptel interface. To be even slicker, you could assign an entire range of numbers to be used for Skype purposes. Here, I've set aside 80 through 89. The dialplan will always dial these extensions on the Zaptel interface, passing the extension number through to the Internert Phone Wizard as dialed digits: exten => 8X,1,Dial(Zap/1/${EXTEN})
Now, to get calls from Skype routed into your Asterisk dialplan, all you need to do is modify the default context of the Zaptel channel you've used to connect the Internet Phone Wizard. Refer to chapter 4 for an example that points out how to do this. Now, if you really want to get fancy with Asterisk and Skype, check out the next hack. Forward Your Home Phone Calls to Skype (For those times when you really, really need to stay in touch.) This is just plain cool. If you've come this far with Asterisk and the Internet Phone Wizard, then you've unlocked a world of wicked-cool hack potential. To get you primed for your journey to Aster-Skype hackatopia, let me show a very simple dialplan modification that will simultaneously ring your incoming coming phone calls on your locally-connected phones as well as on your Skype. In /etc/asterisk/extensions.conf, consider the following: exten => s,1,Dial(SIP/100&SIP/200) This extension will dial the two phones connected on SIP peers 100 and 200, and connect the call to whichever peer answers first. But let's say there's an Internet Phone Wizard connected to channel Zap/2, like in [Hack "#Connect Asterisk to the Skype Network"]. Now, you can actually dial those two phones and a Skype speed-dial alias from your buddy list: exten => s,1,Dial(SIP/100&SIP/200&Zap/2/99) Now, whoever is associated with speed dial number 99 in your Skype buddy list will also receive a call (through the Skype network), courtesy of the Internet Phone Wizard that you've hooked up to a Zaptel FXO port (Zap/2) on the Asterisk machine. So, if this was your default context for incoming calls from your home phone line (connected to Asterisk via another channel), then your incoming home phone calls would also ring on the Skype client logged in as the buddy in your list. Ideally, this buddy is a second Skype account you've set up-because Skype doesn't let you call yourself. So, I would set up Ted1 and Ted2 as Skype buddy names, and then have the Internet Phone Wizard's Skype client log in as Ted2, while I go about my normal business logging in as Ted1. In essence, my home phone calls will be forwarded from Skype user Ted2 to Skype user Ted1. |
|
|
|
(C) 2003 - 2006 Ted Wallingford
|