Главная / Asterisk Click2Call extension for Google Chrome

Asterisk Click2Call extension for Google Chrome

Click2Call extension for Google Chrome allows you to dial any phone number directly from the browser with your Asterisk PBX.

Step-by-step installation manual below.


Step 0. Starting with Asterisk 12 you can choose between AMI or ARI to originate calls with this Google Chrome Extension. With ARI you won't need server script so you can skip the steps 1-3 and start with setting up ARI user.

Step 1. Add a new manager to /etc/asterisk/manager.conf on your Asterisk box.



Step 2. Create AMI script with your favorite language.

Perl example:

use Asterisk::AMI;
use CGI;
my $q = new CGI;
#the phone number you want to dial
my $phone = $q->param("phone");
#your Asterisk extension
my $exten = $q->param("exten");
#replacing +7 with 8 - adjust this in according to your dial rules.
$phone =~ s/^\+7/8/;
#cut off non-digit characters;
$phone =~ s/\D//g;
#connecting to asterisk
my $astman = Asterisk::AMI->new(PeerAddr => '',
                                PeerPort => '5038',
                                Username => 'bitree',
                                Secret => 'bitree_secret'
die "Unable to connect to asterisk" unless ($astman);
#and finally making the call
my $response = $astman->action({Action => 'Originate',
                                Channel => "Local/$exten\@from-internal",
                                Context => 'from-internal',
                                Exten => "$phone", 
                                Priority => 1,
                                WaitTime => 15,
                                Callerid => $phone});


PHP example:

<? if (!empty( $_REQUEST['phone'])   && !empty( $_REQUEST['exten']  ) )
        $num = $_REQUEST['phone'];
        $ext = $_REQUEST['exten'];
        $num = preg_replace( "/^\+7/", "8", $num );
        $num = preg_replace( "/\D/", "", $num );

        if ( ! empty( $num ) )
                echo "Dialing $num\r\n";

                $timeout = 10;
                $asterisk_ip = "";

                $socket = fsockopen($asterisk_ip,"5038", $errno, $errstr, $timeout);
                fputs($socket, "Action: Login\r\n");
                fputs($socket, "UserName: bitree\r\n");
                fputs($socket, "Secret: bitree_secret\r\n\r\n");


                echo $wrets;

                fputs($socket, "Action: Originate\r\n" );
                fputs($socket, "Channel: Local/$ext@from-internal\r\n" );
                fputs($socket, "Exten: $num\r\n" );
                fputs($socket, "Context: from-internal\r\n" );
                fputs($socket, "Priority: 1\r\n" );
                fputs($socket, "Async: yes\r\n" );
                fputs($socket, "WaitTime: 15\r\n" );
                fputs($socket, "Callerid: $num\r\n\r\n" );

                echo $wrets;
                echo "Unable to determine number from (" . $_REQUEST['phone'] . ")\r\n";
{?>Please enter a number to dial.


Step 3. Copy the script to the web accessible directory on your Asterisk box (you have to run a web server, of course), set correct permissions on the script and verify the installation with the following request:


You should have the extension 101 ringing and after picking up - the phone number 3434343 should be called.

If everything is OK, proceed with the next step.


Step 4. Install Chrome extension.


Step 5. Update the extension settings. You have to set up your Asterisk extension and AMI script's URL. Then click Save button.


Step 6. You're done! To make a call from the web brower just highlight the phone number you want to dial, make a right click and choose Call context menu. Asterisk will do the rest.

Step 7. You can set up basic authentication on the web server to protect your script. In this case use Username and Password fields to provide the credentials.

Step 8. To make a replacement like +7 -> 8 in phone numbers use Replace characters field. The syntax is a|b (replace all occurrences of a with b in dialed numbers). Special characters must be escaped with backslash. Several rules must be separated by commas. Keep in mind that all non-digit characters will be removed before the call processed regardless of this setting, so you don't need to replace brackets and dashes here.


NEW!  Converting phone numbers found on a page to clickable links.

Try our new Asterisk Screenpop Chrome extension that shows Caller ID for incoming calls. (Asterisk v12+ required).

You can leave your feedback on Facebook:

© Битри 2012