Click to call button to call Asterisk user number

Is this possible to If i create Click to call button on my company web site & when ever any user will click on that button with mouse that call for my toll free come to my Asterisk pbx .
Actually my Asterisk Server reciove call from my softswtich (openser )when incoming call is theer for toll free number or DID’s, Meanbs all thsi Autrhenticate with My open ser to make & recive calls.
1.When any user cleck that button then any need to make any type of interface between my web site & open ser or Asterisk if yes which tye & what is that ?
2. is theer any chance directly route that call to Asterisk.
3. what are the settings i want to do on Asterisk in conf file & any script?
Plz tell me & help me with thsi deatils or send me Link for that.
Mainly i want to create by own without any hosting so help me plz


Do you want a soft phone integrated in to the web site or where you have them enter their number and the system calls them and then you. If it is the later I have been using the php script to connect to the AMI.


echo '<title>Call Me</title>';
echo '<form action="make_call.php" method="post">
<table width="35%">
<tr><td>Enter your phone number here, country code plus number (e.g. 972732444211 or 17185551212)</td></tr>
<tr><td> <input type="text" name="number" /></td></tr>
<tr><td colspan="1" align="left"><input type="submit" value="Submit" /></td></tr>
<img alt="FPP Logo" src="">';
$_SESSION['calling'] = 'yes' ;

and make_call.php

if (!isset($_SESSION['calling'])) {
        echo '<META HTTP-EQUIV="Refresh"CONTENT="0; URL=mc.php">';
else {

$n2c = $_POST['number'] ;

$_SESSION['calling'] = NULL;

$socket = fsockopen("","5038", $errno, $errstr);
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: username\r\n");
fputs($socket, "Secret: password\r\n");
fputs($socket, "Events: off\r\n\r\n");
# fputs($socket, "\r\n");
# fputs($socket, "\r\n\r\n");
fputs($socket, "Action: Originate\r\n");
fputs($socket, "Channel: SIP/".$n2c."@sip_peer\r\n");
fputs($socket, "Context: some-context\r\n");
fputs($socket, "Exten: s\r\n");
fputs($socket, "Priority: 1\r\n");
fputs($socket, "Callerid: ".$n2c."\r\n");
fputs($socket, "Timeout: 100000\r\n");
#fputs($socket, "Action: ListCommands\r\n\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
$wrets .= fread($socket, 8192);
echo '<title>Call being placed</title>';
echo 'Your call is being placed. Please wait a moment';


and from extensions.conf

exten => s,1,Answer
exten => s,2,Dial(SIP/100)

Hi Dovid
Thanks for this
i want to connect softphone type image or square time button which our pbx borad number is diplayed. once that square button onwhich our number is disaplying click by user that call come to my satersik server.
for that what changes i want to do on my website, web sever so that can connect to my Astersik server.
Also where i need to write & save above mention script as i have no idea about this.if my board number is supose 646xxxxxxx then what chages i have to do in scripts.
which conf file in astersik i have to set if i need to add this feature thru my website.
Plz help me as i have no idea about AMI.


I still do not understand the call flow. Do you want a SIP/IAX phone built in to the browser or do you want the user to enter a phone number which the system will then call them on and then connect the call to you ?


i need simple web button on whcih out click to call number is displaying & when user just click to that buton that call come to my Asttersik server to support

my web site click to call button ---------> astersik pbx board number to recive call