How to make a click to call?

Hi @everyone,

I want to realise a click to call but I don’t really understand the concept… I think is the ability to make a call by clicking on a phone number on a website and my Asterisk do the call by using the extension who is enable to make the call. That it ?

Best regard,
Lordaker.

1 Like

The extension will have to communicate to via some sort of HTTP method that includes some sort of authorization information.

You build a listener that authenticates the request coming from your extension and then translates the HTTP request with with who to call to and who to call from into a call request for asterisk, One of the easiest ways to do this is by creating a call file.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+Call+Files

You could also use something like AMI to do an Originate action.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+15+ManagerAction_Originate

1 Like

AMI Originate Action and PHP, you will create a PHP script who will connect to the Asterisk manager and initiate the call, you pass the paratmers as POST or GET variables

Why don’t you use webrtc ?
You could make calls from website to asterisk…
You could look at www.toky.co to a ready to use (non completely free but very cheap) click to call button

Click to call using AMI it is a few line line of codes, Webrtc require deep understanding about this technologie and a huge configuration at least for some one new on this field , but if you have time and patience you can try with Webrtc

Actually, I try to make a call by clicking on link of phone numbers during visiting a website. I’m reading some documentations and watching tutorials about Asterisk. But I have a question, if I receive a call, is it possible to have a notification on my computer. I must use a softphone like X-Lite ?

Anything is possible if you write the code.

Send a Tweet
Turn on a lamp
Play a sound
Send an XMPP message

I know someone who once brewed a pot of coffee when he got a call from a specific number to win a bet.

1 Like

Totally agreed, I turn and off my room lamp, when I got a call using Raspberry PI

4 Likes

You can use FOP2 along with FOP2 Chrome extension. Works fine ! www.fop2.com Click2Call and Desktop notifications are included!

Just use Click2Call CRM Integration browser extension on Chrome Web Store https://chrome.google.com/webstore/detail/crm-click2call-click-to-c/cbjgpemimjmpbldgimfocbanmmkoefbi

Depending on configuration it can be used for simple Click to Call, integrate with CRMs (Salesforce, Zoho and others), and also perform caller identification from custom source. It works with or without Thirdlane platform or Asterisk

May be an old topic, thought if it helps.

so, below is the file that we generally use, save this on the webfolder of your asterisk server, with as c2c.php.

<?php

$key = $_REQUEST['key'];
$pass = "lkashf984q75qqqhdskjh98q475";

if($key == $pass)
{
#ip address that asterisk is on.
$strHost = "127.0.0.1";
$strUser = "cron";#specify the asterisk manager username you want to login with
$strSecret = "1234";#specify the password for the above user
#specify the channel (extension) you want to receive the call requests with
#e.g. SIP/XXX, IAX2/XXXX, ZAP/XXXX, etc
# $strChannel = "SIP/100";
$strChannel = $_REQUEST['exten'];
$strContext = "default";
#specify the amount of time you want to try calling the specified channel before hanging up
$strWaitTime = "30";
#specify the priority you wish to place on making this call
$strPriority = "1";
#specify the maximum amount of retries
$strMaxRetry = "2";
$number=strtolower($_REQUEST['number']);
$pos=strpos ($number,"local");
if ($number == null) :
exit() ;
endif ;
if ($pos===false) :
$errno=0 ;
$errstr=0 ;
$strCallerId = "Web Call $number";
$oSocket = fsockopen ("localhost", 5038, &$errno, &$errstr, 20);
if (!$oSocket) {
echo "$errstr ($errno)<br>\n";
} else {
fputs($oSocket, "Action: login\r\n");
fputs($oSocket, "Events: off\r\n");
fputs($oSocket, "Username: $strUser\r\n");
fputs($oSocket, "Secret: $strSecret\r\n\r\n");
fputs($oSocket, "Action: originate\r\n");
fputs($oSocket, "Channel: $strChannel\r\n");
fputs($oSocket, "WaitTime: $strWaitTime\r\n");
fputs($oSocket, "CallerId: $strCallerId\r\n");
fputs($oSocket, "Exten: $number\r\n");
fputs($oSocket, "Context: $strContext\r\n");
fputs($oSocket, "Priority: $strPriority\r\n\r\n");
fputs($oSocket, "Action: Logoff\r\n\r\n");
sleep(2);
fclose($oSocket);
}
echo "Extension $strChannel should be calling $number.";
else :
exit() ;
endif ;

}
else
{
echo "BAD : login details incorrect";
}


?>

Then try this on your browser.

http://serveripaddress/folder/c2c.php?key=lkashf984q75qqqhdskjh98q475&exten=SIP/40001&number=123445567890

SIP/40001 is the internal asterisk extension and 123445567890 is the external phone number that you wish to dial. This will first ring the internal extension and when answered will start dialling the external phone number.

1 Like

Hi,

Pls send a python for Click the call.