There have been any number of click to call applications released for Asterisk®, but none quite so simple to implement as the one we've uncovered. The original was introduced at VoIPjots.com about this time last year. Then Rafael Cortes at asteriskpbxs.com further embellished it. We took Rafael's version and added a few minor enhancements, and today you get Click2Dial for Asterisk to freely use with virtually any Asterisk PBX. It works exceptionally well with our customized versions of TrixBox 1.2.3 which you can download from the links above for Windows, Intel Macs, and Linux.

Overview. For those new to this technology, the basic idea behind Click-to-Dial or click to call applications is that folks can visit your web site, click on a link after plugging in their phone number, and a call is placed from your Asterisk PBX connecting you and them without the visitors incurring any long distance charges. The initial call to you is placed first, and it can be to any extension on your Asterisk system or even your cellphone if you have more than one outbound (termination) trunk. If you don't answer, no second call is placed. Once you answer, the outbound call to the web site visitor is placed. We've added support in the PHP application so that callers can also enter their name, and the name entry together with the phone number to be called will be displayed on your phone before you answer the call: Web-John Doe 843-678-1234. Be aware that cellphone providers throw CallerIDName information in the bit bucket so the name display only works on calls to Asterisk extensions, but the CallerIDNumber will work with any of the providers that support adjusting your outbound CallerID, such as TelaSIP. See our Roundup of VoIP Providers for more choices. Anyway, the web site visitors get 12 characters in which to enter their name and 10 for their area code and phone number. Without much tweaking, the 10-digit limitation can be adjusted for international calling. No dialplan changes are required to get this working assuming your dialplan supports 10-digit dialing from extensions on your system. Simply drop the code into the web directory on your Asterisk server, open port 80 on your firewall to point to the web server on your Asterisk or TrixBox system, and you're off to the races. Installation and setup time: about 2 minutes.

Click2Dial for Asterisk Installation and Setup. To download the Click2Dial for Asterisk application, click on this link. Save and unzip the archive on your Desktop. Open the Click2Dial folder and copy click2dial.php into the web folder on your Asterisk server (/var/www/html on TrixBox systems). Log into your Asterisk server as root and edit the file: nano -w /var/www/html/click2dial.php. For TrixBox systems, the only entry you need to change is the incoming call destination on line 38. For a SIP extension on your Asterisk system, the line should look like this: $strChannel = "SIP/502"; where 502 is the extension you wish to ring for incoming Click2Dial calls. If you have multiple outbound trunks and you want to route incoming web calls to your cellphone, here's the syntax:

$strChannel = "local/1NXXNXXXXXX@from-internal" ;

Replace 1NXXNXXXXXX with the actual phone number that you currently dial from an extension on your system to place a call to your cellphone. Save your change (Ctrl-X, Y, then Enter), and you're done! To try it out, point a web browser at the following page substituting your own fully-qualified domain name or IP address of your Asterisk server: http://192.168.0.211/click2dial.php. Feel free to cut-and-paste the code into an actual web page if you'd prefer to integrate Click2Dial for Asterisk into your existing web layout.

Other Goodies. We've also included all of Rafael Cortes' other handiwork in the archive which you are free to use (not sell!) if you so desire. In addition, we've included our YeeHah add-on for AsteriDex. This lets you do a couple of things. First, you can use it as a Click2Dial add-on which works exactly like the code described above. Just edit the top of the file and specify your CallerID number and extension number to be called. Then move the file to your existing AsteriDex folder on your Asterisk server. While editing the file, if you set Click2Call=false, then the application lets you actually dial outbound calls to two phones of your choosing from the web page. This is handy for personal use but obviously has serious security risks unless you also uncomment the top few lines in the application and specify the actual IP addresses of the computers on which this application can be used. If you don't understand what any of this means, then do yourself and your phone bill a favor, don't use it! Otherwise, anyone with access to your AsteriDex web application can make unlimited calls on your nickel to anywhere. Enjoy!

Nerd Reminder. Don't forget today is Valentine's Day. Give the keyboard a rest for a bit.

Nerd Vittles Valentine's Day Giveaway. As a special thanks to our loyal readers, we have a couple of free passes to give away to the Fonality trixbox Open Communications Certification course being held on March 5-6, 2007 at the Los Angeles LAX Westin. The retail value of each pass is $1495. If you'd like to attend, post a comment to this article which begins with I WANNA GO. Just tell us why you'd like or need to go to the course. And be sure to include your real name and email address in the required fields. Email addresses do NOT get shown on the web but do give us a way to get in touch with you. Except for the winning entries, none of the other comments will actually be posted on the blog so feel free to lie your ass off beg. To be eligible, we must receive your comment before 7 a.m., Eastern time, on Thursday, February 15, 2007. We will pick two lucky winners tomorrow morning. Decision of the judges (Nerd Uno) is final. If you don't hear from us by noon (Eastern time) tomorrow, then you didn't win. Sorry. Make up a better story next time. Winners are, of course, responsible for their own transportation, lodging, food and beverage expenses. This is a perfect opportunity to get certified on the TrixBox platform at minimal expense. Offer void where prohibited by law. Good luck!


Nerd Vittles Demo Hot Line (courtesy of les.net). You now can take a number of Nerd Vittles projects for a test drive... by phone! The current demos include (1) MailCall for Asterisk with password 1111 (retrieve your email by phone), (2) NewsClips for Asterisk (latest news headlines in dozens of categories), (3) Weather Forecasts by U.S. Airport Code, and (4) Weather Forecasts by U.S. ZIP Code. You're not prompted for #4 yet, but it does work! Just call our number (shown in the left margin) and take any or all of them for a spin. The sound quality may not be perfect due to performance limitations of our ancient Intel 386 demo machine. But the price is right.

Nerd Vittles Fan Club Map. Thanks for visiting! We hope you'll take a second and add yourself to our Frappr World Map compliments of Google. In making your entry, you can choose an icon: guy, gal, nerd, or geek. For those that don't know the difference in the last two, here's the best definition we've found: "a nerd is very similar to a geek, but with more RAM and a faster modem." We're always looking for the best BBQ joints on the planet. So, if you know of one, add it to the map while you're visiting as well.


Some Recent Nerd Vittles Articles of Interest...

Be Sociable, Share!

This article has 11 comments

  1. I WANNA GO because someone needs to end my suffering. Before I go on – I am a rabid fan of Nervittles Applications. Anyway, back to my suffering, I work in the public sector and some years we have money and this year is not one of them. Money is one of the reasons we are looking at Asterisk to replace an aging Nortel over slow period. We run Trixbox as our helpdesk for 800 users and I am about to purchase and install a T1 card to interface with the Old PBX.

    All that makes me really need to attend the class. I may save tax payers many hundreds of thousands of dollars.

    btw, the following is what I sent earlier. It was a cut and paste from me begging Fonality for an ED discount. They gave me 25%, but as I amstill begging other departments to chip in funds it may be moot:

    We have essentially zero Professional Development budget so anything at all will help.

    I am a Chief Technologist for the district and I teach advanced students VoIP, VM and Linux server stuff they can’t get anywhere else. So what I am saying is that (in my opinion anyway) I am a good candidate for help.

    I make a pretty good student too.

    [WM: Here are our winners (only). Thanks to everyone who participated. Don’t purchase an airline ticket or pay for a hotel room until you receive confirmation from Fonality that you’re registered!! If, for some reason, you can’t attend, please let us know so that someone else can take your place. Enjoy and let us know how it goes!]

  2. I’ve been watching your site, reading and implementing many of your tweaks and tips here for at least two years now… I’ve enjoyed many of them. I started watching them back when I was 16. Now I’ve just turned 19, I’m into my second semester in at Walla Walla College in Washington State, but still don’t know what to do with my life. The thought has crossed my mind to start a business that helps large and small businesses convert to the open source Trixbox with minimal cost, allowing us to provide and charge for support. This could help drive the technology forward and provide more development. I’ve even registered a domain name – asterfone.com – to try and start such a venture. Only one major problem with starting a business like this is that you must have some sort of tangible proof of your experience, and while I have tinkered with the innards of asterisk and trixbox many times, I do not have any sort of proof to offer anybody that I am capable of helping them revolutionize their calling prices and practices. I have thought about attending the asterisk certification workshops put together by Digium, but being the high school and then college student that I was and am, I have not had the thousands required. And while I’ll take out loans for entire school year’s worth of tuition, it would be hard to justify taking out loans for one weekend. It would be an absolute Godsend to receive such a pass, and though I would need to take a few days off of school to go, and it would take transportation, accommodations, and food money to be there, I would love to receive one of the passes. Feel free to contact me by cell if you have any more questions. (913)755-1223 (I just moved from Kansas and am stuck with a cell contract from Alltel which by the way allows you to receive phone calls for free from 10 numbers – that’s where asterisk and Telasip come in… lol)
    Please seriously consider my request. I’d appreciate the help!
    Jacob Brassington

    [WM: Runner-up… in case one of the winners has to cancel.]

  3. I WANNA GO. Please let me go!!! I’ve talked the bosses into putting an asterisk system in. Now we’re having a few problems. The Mayor is involved…and you should see him when he’s mad. In his words: "This new phone system SUCKS." He’s about to make me tear it all out and go back to analog phones!!! HELP SOS … – – – …

    [WM: Bill, you’re winner #2. Hope you get the mayor straightened out. See the cautionary note above.]

  4. I got the click2dial to work calling an asterisk extension but when I commented out the extension line and added my cell I got the following error.

    Parse error: parse error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or ‘(‘ in /var/www/html/click2dial.php on line 34

    Also is there anyway to password protect the click2call page for security reasons.

    Great work!

    [WM: Be sure you’ve deleted everything after the semicolon on the line. As for security, look at the first few lines in the yeehah.php application and copy them over to the top of the click2call script. Then uncomment the lines and set the IP address for each PC which should have access. There are other ways, but this is the easiest and quickest solution. Good luck!]

  5. I deleted everything after the semicolon and it works, Thank you. I would like to assign a differernt trunk for the callout. What would the verbage be rather than local? I think I will need to find a another way as I will be travelng and might not know the IP every time.

    Jeff

  6. I took care of the password problem by hosting it on another server which has password protection. Now can I have it call the StealthAutoattendant(412) rather than $strChannel = "SIP/101″;

    Thanks,

    Jeff

  7. Sorry, " the 10-digit limitation can be adjusted for international calling." Where and How, please help me, I have from local ( 7 digital numbers ) and International ( 15 digital numbers )

    thanks in advanced
    Walter

  8. I want to experiment with this but with a different twist. May be someone can help. Can this be modified such that someone come to a webpage type in his desired number to call, and my trixbox can place the call thru by a click to any available outbound routes. Then he cal continue his discusstion until hangup

  9. I am a newbie.
    I got the code working and it rings the extension.Now i want to know how to define context dialplan to make the outgoing call to the customer number.

    Thanks for the help.

    [WM: Join the forum.]

  10. hi there
    this is truly a magnificent application but i wonder if i can use it to my call center project
    i need to make a fully client web interface in my web site that allow my clients to contact and communicate with my based asterisk call center agents using only there browsers
    can some one please help me i will be grateful
    and here my email achref.nasri@gmail.com
    and thank you