WEB Calling

From KlavoWiki
Jump to navigationJump to search

I have just completed creating a WEB based calling system. It is broken into three different sections.

Point to Point

This allows the ability to type in a source and destination phone number and the 2 calls are then connected together.

point-to-point.htm

<html>

<head>
<meta http-equiv="Content-Language" content="en-au">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Klaverstyn call back portal</title>
</head>

<body>

<p align="center"><img border="0" src="klaverstyn.jpg" width="521" height="249"></p>
<div align="center">
	<table border="1" width="500">
		<tr>
			<td width="33%" align="center"><b><font color="#FF0000">Point to Point</font></b></td>
			<td width="33%" align="center"><a href="conferencing.htm">Conference</a></td>
			<td width="33%" align="center"><a href="call-back.htm">Call Back</a></td>
		</tr>
	</table>
</div>
<p>Point to Point Calling</p>
<table border="0" width="500" cellspacing="0" cellpadding="0">
        <tr>
                <td>By entering your phone number you will receive a phone call from our phone
system.  Once answered you will be prompted with a menu system allowing you
                to speed dial predefined people or access a dial tone.</td>
        </tr>
</table>
<form method="POST" action="connectme.php">
	<table border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="120"> </td>
			<td align="right" width="210">Enter your Phone Number :</td>
			<td width="35"> </td>
			<td width="55"><select size="1" name="Source_Area_Code">
                                <option>02</option>
                                <option>03</option>
                                <option>04</option>
                                <option selected>07</option>
                                <option>08</option>
                                </select></td>
			<td>
			 <!--webbot bot="Validation" s-data-type="Integer" s-number-separators="x" b-value-required="TRUE" i-minimum-length="8" i-maximum-length="8" --><input type="text" name="Source_Phone_Number" size="8" maxlength="8"></td>
			<td width="35"> </td>
			<td> </td>
		</tr>
		<tr>
			<td> </td>
			<td align="right">Enter destination Number :</td>
			<td> </td>
			<td><select size="1" name="Dest_Area_Code">
                                <option>02</option>
                                <option>03</option>
                                <option>04</option>
                                <option selected>07</option>
                                <option>08</option>
                                </select></td>
			<td>
			 <!--webbot bot="Validation" s-data-type="Integer" s-number-separators="x" b-value-required="TRUE" i-minimum-length="8" i-maximum-length="8" --><input type="text" name="Dest_Phone_Number" size="8" maxlength="8"></td>
			<td> </td>
			<td><input type="submit" value="Submit" name="B3"><input type="reset" value="Reset" name="B4"></td>
		</tr>
		</table>
</form>

</body>
</html>


connectme.php

<?php
  header("Refresh: 5; url=point-to-point.htm");

  $Source_No = "$_POST[Source_Area_Code]$_POST[Source_Phone_Number]";
  $Dest_No = "$_POST[Dest_Area_Code]$_POST[Dest_Phone_Number]";

  $FileName = "$Source_No" . "-" . "$Dest_No.call";
  
  $FileHandle = fopen("/tmp/".$FileName, 'w') or die("can't open file $FileName");

  fwrite($FileHandle,"Channel: SIP/GoTalk/$Source_No\n");
  fwrite($FileHandle,"Application: Dial\n");
  fwrite($FileHandle,"Data: SIP/GoTalk/$Dest_No\n");
  fwrite($FileHandle,"Context: internal\n");
  fwrite($FileHandle,"MaxRetries: 1\n");
  fwrite($FileHandle,"RetryTime: 60\n");
  fwrite($FileHandle,"Priority: 1\n");
  fwrite($FileHandle,"WaitTime: 20\n");
  fclose($FileHandle);

  rename("/tmp/$FileName", "/var/spool/asterisk/outgoing/$FileName");

  print "A call has been placed to $Source_No connecting $Dest_No";

?>

Conferencing

This will allow you to dial multiple people to join a conference.

conferencing.htm

<html>

<head>
<meta http-equiv="Content-Language" content="en-au">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Klaverstyn call back portal</title>
</head>

<body>

<p align="center"><img border="0" src="klaverstyn.jpg" width="521" height="249"></p>
<div align="center">
	<table border="1" width="500">
		<tr>
			<td width="33%" align="center"><a href="point-to-point.htm">Point to Point</a></td>
			<td width="33%" align="center"><font color="#FF0000"><b>Conference</b></font></td>
			<td width="33%" align="center"><a href="call-back.htm">Call Back</a></td>
		</tr>
	</table>
</div>
<p>Conferencing</p>
<table border="0" width="500" cellspacing="0" cellpadding="0">
        <tr>
                <td>Please enter the phone number that you would like to 
				participate in a conference call along with the conference room 
				number.</td>
        </tr>
</table>
<form method="POST" action="conferencing.php">
	<table border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="120"> </td>
			<td align="right" width="210">Enter Phone Number :</td>
			<td width="35"> </td>
			<td width="55"><select size="1" name="Area_Code">
                                <option>02</option>
                                <option>03</option>
                                <option>04</option>
                                <option selected>07</option>
                                <option>08</option>
                                </select></td>
			<td>
			 <!--webbot bot="Validation" s-data-type="Integer" s-number-separators="x" b-value-required="TRUE" i-minimum-length="8" i-maximum-length="8" --><input type="text" name="Phone_Number" size="8" maxlength="8"></td>
			<td width="35"> </td>
			<td> </td>
		</tr>
		<tr>
			<td> </td>
			<td align="right">Enter Conference Room Number :</td>
			<td> </td>
			<td><select size="1" name="Conference_Room">
                                <option>8205</option>
								<option>8206</option>
								<option>8207</option>
								<option>8208</option>
								<option>8209</option>
								<option>8210</option>
                                </select></td>
			<td>
			 </td>
			<td> </td>
			<td><input type="submit" value="Submit" name="B3"><input type="reset" value="Reset" name="B4"></td>
		</tr>
		</table>
</form>

</body>
</html>


conferencing.php

<?php
  header("Refresh: 5; url= conferencing.htm");

  $Source_No = "$_POST[Area_Code]$_POST[Phone_Number]";
  $Dest_No = "$_POST[Conference_Room]";

  $FileName = "$Source_No" . "-" . "Conference_Room.call";
  
  $FileHandle = fopen("/tmp/".$FileName, 'w') or die("can't open file $FileName");

  fwrite($FileHandle,"Channel: SIP/GoTalk/$Source_No\n");
  fwrite($FileHandle,"Application: MeetMe\n");
  fwrite($FileHandle,"Data: $Dest_No,1cM(SkyFM-80s)\n");
  fwrite($FileHandle,"Context: internal\n");
  fwrite($FileHandle,"MaxRetries: 1\n");
  fwrite($FileHandle,"RetryTime: 60\n");
  fwrite($FileHandle,"Priority: 1\n");
  fwrite($FileHandle,"WaitTime: 20\n");
  fclose($FileHandle);

  rename("/tmp/$FileName", "/var/spool/asterisk/outgoing/$FileName");

  print "A call has been placed to $Source_No connecting to conference room $Dest_No.";

?>

Call Back

The third option allows a phone number to be dialled and then presented with a menu system allowing the ability to call multiple people without having to be dialled back after a call is terminated.

call-back.htm

<html>

<head>
<meta http-equiv="Content-Language" content="en-au">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Klaverstyn call back portal</title>
</head>

<body>

<p align="center"><img border="0" src="klaverstyn.jpg" width="521" height="249"></p>
<div align="center">
	<table border="1" width="500">
		<tr>
			<td width="33%" align="center"><a href="point-to-point.htm">Point to Point</a></td>
			<td width="33%" align="center"><a href="conferencing.htm">Conference</a></td>
			<td width="33%" align="center"><font color="#FF0000"><b>Call Back</b></font></td>
		</tr>
	</table>
</div>

<p>Welcome to the Klaverstyn call-back site.</p>
<table border="0" width="500" cellspacing="0" cellpadding="0">
        <tr>
                <td>By entering your phone number you will receive a phone call from our phone
system.  Once answered you will be prompted with a menu system allowing you
                to speed dial predefined people or access a dial tone.</td>
        </tr>
</table>
<form method="POST" action="callme.php">
        <table border="0" cellspacing="0" cellpadding="0">
                        <tr>
                                <td width="120"> </td>
                                <td align="right" width="210">Enter the Number for call back :</td>
                                <td width="35"> </td>
                                <td><select size="1" name="Area_Code">
                                <option>02</option>
                                <option>03</option>
                                <option>04</option>
                                <option selected>07</option>
                                <option>08</option>
                                </select>     
								<!--webbot bot="Validation" s-data-type="Integer" s-number-separators="x" b-value-required="TRUE" i-minimum-length="8" i-maximum-length="8" -->
        <input type="text" name="Phone_Number" size="8" maxlength="8"></td>
                                <td width="35"> </td>
                                <td> </td>
                        </tr>
                        <tr>
                                <td> </td>
                                <td align="right">Call Back Menu :</td>
                                <td> </td>
                                <td><select size="1" name="Menu">
                                <option>dial tone</option>
                                <option selected>David</option>
                                <option>Lee</option>
                                </select></td>
                                <td> </td>
                                <td><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></td>
                        </tr>
                </table>
</form>

</body>
</html>

callme.php

<?php
  header("Refresh: 5; url= call-back.htm");

  $code = $_POST[Area_Code];
  $destination = $_POST[Phone_Number];

  if ($_POST[Menu] == "David"){$from = "041xxxxxxx"; $CID = "\"WEB: David Klaverstyn\" <041xxxxxxx>";}
       elseif ($_POST[Menu] == "Lee")  {$from = "041xxxxxxx"; $CID = "\"WEB: Lee Klaverstyn\" <041xxxxxx>";}
       elseif ($_POST[Menu] == "dial tone"){$from = "dialtone"; $CID = "\"WEB: Unknown\" <$destination>";}


  $FileName = "$code"."$destination.call";
  
  $FileHandle = fopen("/tmp/".$FileName, 'w') or die("can't open file $FileName");

  fwrite($FileHandle,"Channel: SIP/GoTalk/$code$destination\n");
  fwrite($FileHandle,"Context: callback\n");
  fwrite($FileHandle,"Extension: $from\n");
  fwrite($FileHandle,"Callerid: $CID\n");
  fwrite($FileHandle,"MaxRetries: 1\n");
  fwrite($FileHandle,"RetryTime: 60\n");
  fwrite($FileHandle,"Priority: 1\n");
  fwrite($FileHandle,"WaitTime: 20\n");
  fclose($FileHandle);

  rename("/tmp/$FileName", "/var/spool/asterisk/outgoing/$FileName");

  print "A call has been placed to $code$destination using menu $_POST[Menu] -> $from";

?>

The main advantage to this is that it has powerful routing and resume functions. The functionality is base on the section Callback Advanced Call Routing

Prerequisite

For the above to work you must have Apache and PHP installed. Usually this is done when installing Linux. You also have to change the permissions of an Asterisk folder so that Apache can write a file so Asterisk can initiate calls.

chmod 757 /var/spool/asterisk/outgoing