6.1. AsteriskC2D¶
Click to dial
Using AsteriskC2D for iPhone, you can dial using your VoIP PBX. currently We support, Vonage, Asterisk, trixbox, Broadsoft Anywhere, thirdlane.
Full list of Supported PBXs and their installation codes, also with youTube Video showing how to install it.
Depending on your PBX and it’s configuration you can route your calls either to your deskphone or your mobile, or indeed anywhere you like. When the phone rings answer it and you’ll be connected via your PBX to the number you dialed.
More PBXs can and are being added remotely. If your an Enterprise and would like to roll out to your users or would like us to include your PBX, you can request a PBX configuration which includes your necessary defaults, eg server IP, SSL, parameters, etc. Your users can then install this configuration by dialing an install code. For further details on this please contact me.
For asterisk, trixbox or any derivative of those you will need to install my server scripts.
6.1.1. How do I use AsteriskC2D to help my world¶
With asteriskC2D I’m able to make calls from my iPhone and have them appear from my office line. I don’t suffer from issues with Poor VoIP quality due to issues with someone elses network. A GSM call to my phone is often cheeper than if I’d dialed it direct specially if I’m roaming.
This is a fantastic feature, I can hold phone calls with my customers without them knowing where I am or indeed sharing my mobile number.
Our PBX also supports conference bridges. With AsteriskC2D I’m able to call people into the conference rooms via my iPhone. Once everyone is in. I can have it add me in too. This way I can manage conferene calls even when I’m not in the office.
Finally as a corporation we can manage call costings via the PBX. No more hudge mobile phone bills. Upper management can also see via logging, calls that have been placed and thus report on staff activity.
6.1.2. Why is the server side written in Perl?¶
This was done for a few reasons..
Transparent, you can see what it’s doing. Would you trust a random program that allows people to dial via your PBX? No thought not, this way you can see how it works and thus see that there isn’t any hidden code doing something nasty.
Example, you can take this can modify it however you like, so if you really do want to write it in C then please do. It’s not likely to get you anything, the performance of Perl is just fine for this sort of thing, unless you’re handling thousands of call requests a second.
Customisable, you can change parts of it to suit your needs, eg the authentication methods, LDAP, file, or SQL. How it handles number does it need to put a 9 in front for outside lines, etc. Do you want to handle another parameter? Well AsteriskC2D on the iPhone can! so it’s handy the script can to!
6.1.3. Setting up the Server Side¶
In order to use AsteriskC2D you need to install a simple Perl script onto a webserver. Normally people pick the server Asterisk is also running on but it’s not required.
So to get started you’ll need to download the tar ball which contains two scripts, one you might already have “cgi-lib.pl” and the other you won’t “AsteriskC2D.pl”.
AsteriskC2D.tgz Version released 10th August 2009
This new version now does not require you to install perl modules you do not intend to use. Ie if you’re installing on trixbox, then you don’t need to install the LDAP module. The script will also provide human error messages when necessary modules are missing
Support for setting CallerID from the iPhone has now been included. You’ll need to install the PBXCode ##1212# to get the extra parameter on your iPhone. If you do not then original function will remain.
You need to copy them to your “cgi-bin” directory of your webserver, “/var/www/cgi-bin/” maybe. change the permissions on “AsteriskC2D.pl” so it’s world executable.
$ chmod 755 AsteriskC2D.pl
The Perl script also requires at least one perl module which might not be installed on your system, “NET::Telnet”.
$ sudo perl -MCPAN -e "install('Net::Telnet');"
If you want to authenticate with LDAP then you’ll likely need this modules too.
sudo perl -MCPAN -e "install('Net::LDAP');"
Use your favorite editor, vi, pico, emacs, to edit AsteriskC2D.pl to match your Environment. By default this script will use mySQL server to authenticate the users and is generally set for TrixBox.
###########################################################################
# 1 for LDAP, 2 for MySQL, 0 to use a file
my $authMethod = 2;
# Asterisk server IP or hostname
my $server_ip = '127.0.0.1';
# Username in the manager.conf file which is allowed to connect.. you have enabled it right
my $clickUser = 'AsteriskC2D';
# the password associated with the above username
my $ClickPassword = 'nottelling!';
# LDAP server configuration bits
###########################################################################
# LDAP server used to authenticate the users expecting to click and dial
my $LDAPServer = 'ldap.example.com';
# prefix for the usernames eg uid=rho,cn=users,dc=00
my $UID ='uid';
# where in the LDAP to look for the users to authenticate
my $LDAPSearch = 'ou=people,dc=example,dc=com';
###########################################################################
# MySQL authentication support
# Trixbox support
###########################################################################
# Use MySQL for authentication, mainly for TrixBox Support
# mysql Server usually localhost
my $MySQLserver = 'localhost';
# username
my $dbusername = 'asteriskuser';
# Password
my $dbpasswd = 'amp109';
# database name
my $database = 'asterisk';
# tablename
my $table = 'sip';
# query for
my $dbquery = 'select data from sip where keyword=\'secret\' and id=';
###########################################################################
# file based authentication configuration
###########################################################################
my $authFile = '/etc/AsteriskC2D.users';
###########################################################################
# contexts in extensions.conf to start matching to dialing strings etc.
my $context = 'from-internal';
#The callerID to put on the phone you are Dialing FROM!!!..
#This puts the name ClickDial and the number your dialing!
my $CIDName = 'ClickDial';
# Enable logging?
my $LOGGING = 1;
# where to log?
my $LOGFILE = '/var/log/asterisk/click.log';
If you would like AsteriskC2D to adjust some phone numbers in flight, ie to change + to your international dialing code etc the look around line 152, uncomment and edit the if statements to your required tastes.
# Uncomment or edit these lines to have AsteriskC2D adjust numbers on the fly.
# if (substr($exten,0,4) eq '+440') { $exten = '90'.substr($exten,4,length($exten)); }
# if (substr($exten,0,3) eq '+44') { $exten = '90'.substr($exten,3,length($exten)); }
# if (substr($exten,0,2) eq '44') { $exten = '90'.substr($exten,2,length($exten)); }
# if (substr($exten,0,1) eq '+') { $exten = '900'.substr($exten,1,length($exten)); }
# if ((substr($exten,0,1) ne '9') && (length($exten) > 4) ) { $exten = '9'.$exten; }
now edit “/etc/asterisk/manager.conf” and make sure it’s enabled and you’ve specified a username and password which matches the “clickUser” and “clickPassword” in the AsteriskC2D.pl script
[general]
displaysystemname = yes
enabled = yes
webenabled = yes
port = 5038
httptimeout = 60
bindaddr = 0.0.0.0
[asteriskC2D]
secret=nottelling
read=call,user
write=call,user
If you’re using Asterisk 1.6 you might need to change “call,user” to be “call,user,originate” in the above lines.
That should be it. Restart Asterisk and you’re ready to try test dialing. If you’re on a unix system then you can use “curl” to test the script and it’s ability to talk with asterisk.
curl 'http://localhost/cgi-bin/AsteriskC2D.pl' -d 'username=fred&password=1234&deskphone=SIP/1234&toCall=600'
If that works then try with the AsteriskC2D Mac Client. Don’t forget to look in your webserver access and error logs.
You might also want to review my blog on iPhone and SSL Certificates to help with securing your Asterisk server with SSL.
6.1.4. Inbound CallerID¶
CallerID between callers on the same PBX is simple, it just works. Even callerID between Asterisk PBXs usually just works fine. However if you want to have nice caller ID from PSTN or ISDN lines then you’re going to have to do some work.
In this document we’ll discuss a simple method of taking phone numbers and names from your Apple Address book (You’re using a Mac right) and creating a file which Asterisk will check against when a phone call comes in. It’ll then set the callerID to the name and number, much nicer.
First of all download the scripts.. tarBall
InboundCallerID.zip Version released 7th Feb 2010
Inside you should find an Applescript script which will create your phonebook file. This file is very simple format:
name:123213
Create the file and transfer it to your PBX, I store it in /etc/asterisk/ and called it “addrbook.dat”, but you can edit the AGI script if you need to.
Copy the AGI script over to your Asterisk PBX into your AGI directory eg, /etc/asterisk/AGI. Make sure the AGI script has execute permissions
chmod 755 InboundCallerID.agi
The AGI script will search the file trying to match the calling phone number, if it finds a match then it sets the callerID to something like “name “.
In your extensions.conf file you need to call the AGI script. Something like this should do the trick.
exten => s,1,noop(Inbound Call)
exten => s,n,wait(1)
exten => s,n,AGI(InboundCallerID.agi)
exten => s,n,noop(Call From: ${CALLERID(all)})
6.1.5. Setting up Asterisk and AsteriskC2D to dial your mobile¶
Simple instructions for configuring Asterisk and AsteriskC2D to allow calls to come from your mobile phone while away from the office. First you need to make sure the AsteriskC2D.pl perl script has the “context” parameter set to a context configured in your extension.conf configuration. This context is where all calls from AsteriskC2D will start and look for dialling patterns.
# contexts in extensions.conf to start matching to dialing strings etc.
my $context = 'inside';
You could create your own context just for AsteriskC2D or you can pick one already configured. To start with you can pick the same one that your SIP phones are using. This will mean, any number you can dial from the SIP phone will work via AsteriskC2D.
In AsteriskC2D you need to specify your number or device where the calls will appear to have come from. If you want the call to come from your SIP deskphone then simply specify your SIP number eg, “SIP/1234” in the “Extensions” parameter. You can also specify the callerID, this will work inside your Asterisk PBX, but might not when routing out via PSTN.
If however you wish to have the call routed to your mobile then you need to provide your mobile number, “LOCAL/14085551234”. You are using the “LOCAL” prefix to have Asterisk route this part of the call via the dialling rules in extensions.conf and place the call. Your mobile phone will now ring before the other side of the call is placed.
6.1.6. Holding A Conference Call via AsteriskC2D¶
Details of how to setup Asterisk and AsteriskC2D to bring people into a conference call. If you’re out of the office but still need to hold a conference call, maybe with some people who are in the office but others who are external maybe on mobiles or from a different company.
First you need to configure Asterisk to allow conference calls, this is very simple with just an edit of extensions.conf and meetme.conf.
In your “meetme.conf” file you need to define the conference number and any specific settings for that conference:
;
; Configuration file for MeetMe simple conference rooms
; for Asterisk of course.
;
[rooms]
;
; Usage is conf => confno[,pin]
;
conf => 2590
conf => 2591,1234
conf => 2592
Here we have 3 conference bridges set up one requires a pin to access it.
In "extensions.conf", we then allow the dialling of these conference bridges:
[confbridge]
exten => _259[0-2],1,Answer()
exten => _259[0-2],n,Wait(1)
exten => _259[0-2],n,MeetMe(${EXTEN},p)
exten => _259[0-2],n,Playback(VW-goodbye)
exten => _259[0-2],n,Hangup()
Now you just need to reload Asterisk and your conference bridges should be functional. Just try dialling one from your deskphone. It that’s all working or already configured for you, then you can configure AsteriskC2D to allow you to call people and place them directly into the conference.
Create a new PBX configuration, and enter the PBX server details as normal, you’ll also need to specify your username and password. However for the “Extension” parameter, rather than specifying you deskphone or mobile phone number, you can specify one of the conference bridge numbers, eg “LOCAL/2590”. Save the configuration. Now when you select a contact to dial, rather than them connecting to your phone they will be connected to the conference bridge.
It’s recommended to connect yourself to the bridge first and then bring the others in, that way they don’t feel like they are just hanging around. Either use AsteriskC2D to dial your self into the bridge or dial direct (If you can). You can then swap to the AsteriskC2D Application on iPhone while you call is still in progress using the iPhones “Home” button.
In our office each people has their own conference bridge, that way we don’t end up with conflicts. Their bridge number is just their extension number with a number 1 in front, which also makes it simple for them to remember.
6.1.7. AsteriskC2D support for Thirdlane¶
AsteriskC2D and AsteriskC2DPro now has support for Thirdlane PBX built in. No need to install anything on your PBX, it works natively!
If you already have AsteriskC2D or AsteriskC2DPro installed then the upgrade will be free and you’ll be notified automatically when you start up the AppStore on your iphone or in iTunes.
Version 3.3 with thirdlane support has now been released via AppStore.
6.1.8. AsteriskC2D and AsteriskC2DPro Comparison¶
AsteriskC2D and AsteriskC2DPro are identical, with just AsteriskC2D being limited in the number of configurations which can be stored. With AsteriskC2D you are no longer constrained by where your deskphones are. You can make and receive calls via your iPhone over the GSM network. The voice part of the call is carried by the GSM network so you always get the best voice quality.
Note your PBX will be billed for both the outbound call and the GSM call to your mobile, however in most calling plans this GSM call cost is very small.
Feature |
AsteriskC2D |
AsteriskC2DPro |
---|---|---|
PBXCodes Support |
YES |
YES |
Native iPhone Application |
YES |
YES |
Secure Connections (SSL) |
YES |
YES |
Number of Configurations |
2 |
Unlimited |
Support for other PBX systems |
YES |
YES |
6.1.9. Does AsteriskC2D work when not connected to a WIFI network?¶
Yes indeed it does.
AsteriskC2D routes the call over the GSM network, so you’re free to use AsteriskC2D on your iphone anywhere you get any form of a data signal, WFI, GSM, 3G, or Edge. This is fully supported by Apple and in no way breaches there terms of use.
In fact you configure your AsteriskC2D to route the voice call anywhere, so if you’re in a hotel you can have AsteriskC2D route the calls to your hotel phone for you. The person on the other end will have no idea that you’re calling from the hotel phone and not your iPhone, or indeed you deskphone at your office.
6.1.10. AsteriskC2D and Asterisk 1.6¶
AsteriskC2D does indeed work just fine with Asterisk 1.6. The only thing might be that you will need to add an originate entry to in manager.conf
[asteriskC2D]
secret=nottelling
read=call,user,originate
write=call,user,originate
Everything else should be just fine.
6.1.11. Asterisk and International Dialing +¶
So I receive and make many calls which are international, most currently via our E1 (EuroISDN) line on the ZAP channel. I use the callerID number where ever I can for many things, and keeping it standard makes lots of sense to me. I also have PBXs paired up around the world so localizing the number is a really bad idea until the last minute. So I really want to have the + on a phone number for as long as possible.
well the good news is Asterisk fully supports this. In your “zapatel.conf” file add these lines to the “[channels]” part:
nationalprefix=+44
internationalprefix=+
Well ok I’m in the UK so +44 is right for me, if you’re elsewhere then adjust to taste. Now all inbound calls will have the international dialing codes added.
So that’s the inbound part done.. now for the outbound. This is really simple..in your outbound context add these two lines..
[PSTNOutBound]
exten => _+X.,1,noop(internation Dailing!! )
exten => _+X.,n,goto(PSTNOutBound,00${EXTEN:1},1) ; + = 00 for UK PBX
What this does is replace the + with the international dialing prefix.. again I’m in the UK so 00 is right for me. Oh but wait you say, what happens if the number I’m dialing is a UK number?!? Well in the context you need to check for that and again strip those out and replace…
exten => _0044X.,1,Dial(${ISDNTRUNK}/0${EXTEN:4}) ; we're in the UK, remove the 0044 and put a 0 in front
exten => _0X.,1,Dial(${ISDNTRUNK}/${EXTEN}) ; matches 0 and 00
exten => _9X.,1,Dial(${ISDNTRUNK}/${EXTEN:1}) ; remove the leading 9
exten => _90044X.,1,Dial(${ISDNTRUNK}/0${EXTEN:5}) ; remove lots of leading digits
So the final context looks like this:
[PSTNOutBound]
exten => _+X.,1,noop(internation Dailing!! )
exten => _+X.,n,goto(PSTNOutBound,00${EXTEN:1},1) ; + = 00 for UK PBX
exten => _0044X.,1,Dial(${ISDNTRUNK}/0${EXTEN:4}) ; we're in the UK, remove the 0044 and put a 0 infront
exten => _0X.,1,Dial(${ISDNTRUNK}/${EXTEN}) ; matches 0 and 00
exten => _9X.,1,Dial(${ISDNTRUNK}/${EXTEN:1}) ; remove the leading 9
exten => _90044X.,1,Dial(${ISDNTRUNK}/0${EXTEN:5}) ; remove lots of leading digits
The context handles users dialing a + (ie call back, click to Dial) or dialing the international dialing of a number. It also supports dialing out without a 9. ie just the number, with or without international dialing digits.
6.1.12. PBXCodes¶
Both AsteriskC2D and AsteriskC2DPro support installation of additional PBX configurations. If you are a VoIP service provider your configurations can be included here. You can either build your own server side support or install server scripts. You’ll then need to provide the necessary configuration information and an 80×80 pixel icon. Feel free to Contact Me to discuss further.
If you are an enterprise (small, medium or large) and would like to help your users configure their iphones for click to dial, you too can request your PBX configuration be installable via PBXCode. Your enterprise codes will not be listed here and will remain private between you and us.
Provider Install Code Notes logo – AsteriskC2D ##1212# Additional CallerID Parameter added broadsoft – Broadsoft ##1218# Broadsoft anywhere required fonality – Fonality PBXtra ##1213# Call Center enabled vonage – Vonage ##1215#
To install a PBX code, start AsteriskC2D or AsteriskC2DPro, select dialPad and key in the corresponding code. Your phone will need to have access to the internet either via GSM, Edge, 3G, or WIFI.
If you need to remove an additional PBX configuration, you can do so by adding a “9” to the end of the PBXCode, eg, “##1215#9”