Page 1 of 1

click to call from website

PostPosted: Fri Aug 30, 2019 2:45 am
by Jitin
Hello Sir

Asterisk version : 11.22.0
VERSION: 2.14-588a
BUILD: 170211-1041
OS : centos 6.9
It is a scratch install.

I want to use click to call on my website. Customer will fill his information(phone number) and then click "click to call" button.
As soon as the button is pressed, a call will be initiated on customer number and once he answers, he will be connected to call menu/ingroup in vicidial
it could be done with the help of DID number if required or directly to call menu/Ingroup.

Not able to go through that

Can you please help on the same.

Re: click to call from website

PostPosted: Fri Aug 30, 2019 9:08 am
by ambiorixg12
A very simple task I have done it many times, create a PHP script who will originate the call using the Asterisk's manager action originate

fputs($socket, "Action: Originate\r\n" );

Re: click to call from website

PostPosted: Mon Sep 02, 2019 2:42 am
by Jitin
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");


I have used this
but it connects number passed with extension

I want number to be connected directly with DID number(and not SIP extension)

Re: click to call from website

PostPosted: Mon Sep 02, 2019 10:03 am
by ambiorixg12
I dont know the values for the following variables : $strChannel , $strContext and $number but assuming are using the extension value as the one for dial to the agent, change the context to trunkinbound and extension value to a DID pointing to the ingroup

$strContext="trunkinbound";

$number ="DID WHO is ROUTED to the INGROUP";

Re: click to call from website

PostPosted: Tue Sep 03, 2019 12:42 am
by Jitin
$strChannel = $_REQUEST['exten'];
$strContext = "trunkinbound";
#specify the amount of time you want to try calling the specified channel before hangin 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");

and in api I am passing : http://server_IP/call.php??exten=SIP/10 ... 9999999999

please let me know the exact changes
I want to use DID instead of exten and connect it with number entered by customer in website

please let me know the exact changes.

Re: click to call from website

PostPosted: Tue Sep 03, 2019 8:06 pm
by ambiorixg12
Instead of dial to the SIP device directly, send the call to a local channel pointing to the DID number

fputs($socket, "Channel: Local/$DIDNUMBER@trunkinbound\r\n" );

Re: click to call from website

PostPosted: Wed Sep 04, 2019 3:16 am
by Jitin
fputs($socket, "Channel: Local/$DIDNUMBER@trunkinbound\r\n" );

It created a local channel. I should be able to create a SIP channel with DID
Otherwise it doesn't dial outbound number which we sending via api

Please check it again and let me know the correct solution.

Re: click to call from website

PostPosted: Wed Sep 04, 2019 3:53 pm
by williamconley
local is how you dial any number initially through most vicidial systems. you are meant to invoke the dial pattern (dialplan entry) from your carrier. Alternately, you could dial the sip account for the carrier directly if you like.

But none of this should be happening in the first place. Vicidial already has a "click to dial" method in the non-agent API. Use the "Add lead" with the optional "add to hopper". This will put the lead directly into the hopper and if the campaign is LIVE the call will be dialed immediately.