Главная / 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 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.


You can leave your feedback on Facebook:

© Битри 2012