TAPI Click-To-Dial possible?

Hi,

I can’t find out if this is already in FreePBX or if it is being considered or if it can be hacked, but basically, I would absolutely love to be able to dial numbers from the computer, preferably with some sort of IE add-on like Skype has so you can simply click a number and have it dialed on your extension, with or without a certain prefix.

Obviously, I don’t necessarily expect such a solution to exist as a package, but I’m wondering if anyone has tried to put something like this together, and have perhaps found a combination of TAPI dialers and Asterisk add-ons and .conf editing that could do it.

I know that there are some applications like OpenFire, which may or may not do it, although my impression is that they take over your computer and require a bit of a commitment, where all I’m after is the ability to basically copy/paste a phone number to my phone, either from a web-page or from Outlook.

Has anybody worked out how to do this?

Thanks,

Per

There are a lot of applications out there that do this already.

One that might help you is snapanumber. It has a Firefox plugin, and an IE plugin has been expected Real Soon Now for quite a while.

The basic free version does not do TAPI, but it does what you’ve asked for in summary. The “pro” version does do TAPI.

http://www.snapanumber.com

HTH.

Hi,

Thanks, I appreciate it, although Snapanumber comes in essentially every variation BUT internet explorer. Do you know of another dialer that integrates with IE? I’ve searched quite a lot for Asterisk Dialer and I’m coming up short.

Thanks,

Per

BTW, I’m not particularly after TAPI, in my confusion I simply thought it was needed.

Best,

Per

I’m not aware of anything that specifically targets IE. With snapanumber you can easily copy the number out of IE and paste it into the snap dialer box.

The only thing the plugin adds is the ability to click to dial in Firefox. I turned it off because it detects phone numbers where there aren’t any, like UPS tracking numbers and long URLs. Copy and paste works for me.

You should give the free version a try just to see if you like it.

TAPI works yes it can be setup in outlook

or you can use a PHP script
http://www.voipjots.com/2006/02/click-to-call-with-your-asteriskhome.html
there are four different PHP pages here, you can use in a few ways

One will allow you to paste in a number click call your exten will ring you pick it up and the other number is called.

Very interesting! I’m looking into making it possible to use the script from the IE7 right-click menu, which you can configure through the following registry keys:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt<Menu Text>

to run a script and send the text selection as a variable. Maybe I can figure out a way where you simply select the phone, right-click and select dial, and the rest is automatic. I’ll keep you posted.

Best,

Per

It seems somebody did this at http://www.voip-info.org/wiki/index.php?page=Asterisk+manager+Example%3A+PHP

I’ll check it out.

Per

OK, I got this figured out in a great way. I adapted the script above quite heavily. It was first of all very old.

The method is that the script uses a registry entry to call an external url with the highlighted text, so it calls o.php on the server, which then takes the highlighted text, trims is and send it to p.php, which sends the dial command to the management API. I adapted it to not open a window when you dial, to properly trim non-digit characters, and to add a 1 in front of numbers that are 10 digits. In addition, I made it so that you can send a prefix as an URL variable, so you can easily configure multiple right-click entries in Internet Explorer to dial various outgoing lines, i.e. you can have one entry for “Dial Home Line” and one for “Dial Business Line” which might add a 9 in front.

In var/www/html/clicktocall (clicktocall is a new directory), create a file called “o.php” containing the following:


<script language="javascript"> 
       var hlobj = external.menuArguments.window.document.selection; 
       var hlrng = hlobj.createRange();
       var hlarg = hlrng.text; 

       hlarg = hlarg.replace(/[^\d]/g, "");
       if (hlarg.length==10 && hlarg.charAt(0)!="1") hlarg = "1" + hlarg;

       var url="http://asterisk.mydomain.com/clicktocall/p.php?n=" + hlarg + "&x=<? echo $_REQUEST['x']; ?>" + "&p=<? echo $_REQUEST['p']; ?>";

//     location.replace(url);

       function makeRequest(url) { 

         if (window.XMLHttpRequest) { // Mozilla, Safari,... 
             http_request = new XMLHttpRequest(); 
         } else if (window.ActiveXObject) { // IE 
             http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
         } 
         http_request.open('GET', url, true); 
         http_request.send(null); 

       } 
       makeRequest(url);

</script>

Next, in the same directory, create a file called “p.php”, containing the following:


<html> 
<head> 
<title>Dialing...</title> 
</head> 
<body style="background: blue; color: yellow; font: 12pt bold sans-serif;"> 
<pre> 
<? 

if (( !empty( $_REQUEST['n'] ) ) && ( !empty( $_REQUEST['x'] ) ) ) 
{ 
       $num = $_REQUEST['n']; 
       $ext = $_REQUEST['x']; 
       $pre = $_REQUEST['p'];

       $num = preg_replace( "/\D/", "", $num ); 
       $num = $pre . $num;

       if ( ! empty( $num ) ) 
       { 
               echo "Dialing $num\r\n"; 

               $timeout = 10; 
               $asterisk_ip = "127.0.0.1"; 

               $socket = fsockopen($asterisk_ip,"5038", $errno, $errstr, $timeout); 
               fputs($socket, "Action: Login\r\n"); 
               fputs($socket, "UserName: admin\r\n"); 
               fputs($socket, "Secret: elastix456\r\n\r\n"); 

               $wrets=fgets($socket,128); 

               echo $wrets; 

               fputs($socket, "Action: Originate\r\n" ); 
               fputs($socket, "Channel: SIP/$ext\r\n" ); 
               fputs($socket, "Exten: $num\r\n" ); 
               fputs($socket, "Variable: _SIPADDHEADER55=Call-Info: answer-after=0\r\n" );
                fputs($socket, "Context: from-internal\r\n" );
	       fputs($socket, "CallerId: Dialing <$num>\r\n"); 
               fputs($socket, "Priority: 1\r\n" ); 
               fputs($socket, "Async: yes\r\n\r\n" ); 

               $wrets=fgets($socket,128); 
               echo $wrets; 
       } 
       else 
       { 
               echo "Unable to determine number from (" . $_REQUEST['n'] . ")\r\n"; 
       } 
} 
else 
{?> 
Please enter a number to dial. 
<?} 

?> 
</pre> 
</body> 
</html> 


(change relevant variables).

Next create the following registry key:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Dial Business Line
For the Default, enter the URL “http://asterisk.mydomain.com/clicktocall/o.php?x=210&p=9
… where x is the extension you want to ring with the dialed called, and p is the prefix to add.
Add a Hex key called “Contexts” with the value of 0x10

Create another registry key called:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Dial Home Line
Do the same as above for Default and Contexts, except omit the &p=9 part of the URL so no prefix is dialed.

This of course assumes a setup where the phone is a home phone unless you dial 9, in which case it’s a business phone.

You can now highlight any phone number on a web-page, right-click, and have the number dialed on your phone using any outgoing line of your choice.

I’m trying to find out if there’s a way I can also automatically activate speakerphone, because you otherwise either have to activate it yourself or you have to pick up the phone to start ringing the number. I’ve tried various ways of inserting *80, but it somehow doesn’t do it.

Anyway, try it out. It works like a charm here.

Per

Use the bbcode code tag. Like this:

[code]

Got it, didn’t know it existed. Thanks!

Great news, I made it so that the phone now auto-answers, so you now have click-to-dial with a phone that goes on speakerphone right away.

I added the following code to the fputs block (I’ve edited the above code, no copy/paste needed):

               fputs($socket, "Variable: _SIPADDHEADER55=Call-Info: answer-after=0\r\n" );

The variable _SIPADDHEADER55 has the numbers at the end to be unique. If you’re adding more, they should have different numbers. The auto-answer string is for Grandstream phones.

But this totally works.

Best,

Per

If you are looking for something that integrates click to call into OSX, check out Dialectic:

http://www.jonn8.com/dialectic/

I am interested in doing what you have done here. I am new to *. I am playing with a couple of versions of it. Switchvox is one of them and Freepbx is the other. I am assuming this will work with either. Can you tell me where these scripts go?

here is a quote
In var/www/html/clicktocall (clicktocall is a new directory), create a file called “o.php” containing the following:

Is this on the * server?

Thanks
ChickenDog77

Yes, this is on the Asterisk server. Using FreePBX, I don’t know if it should work with others, but I don’t see why not.

Best,

Per

How would I initiate this script from a C++ app?

This looks very cool. But I can’t see how I would interface this from my C++ app runing on my local computer.

My C app knows the number I want to dial. I would like to click somewhere in my application running on my local computer, and start the connection to the Asterisk server to initiate this process. What should my application do? I’m guessing I would open a socket to the Asterisk server, but how do I then start the process? And will I have any termination issues? Do I close the socket once the call is initiated?

Thanks much for your assistance.

OK, this looked very cool. I downloaded the scripts, and copied them to my Asterisk server. Whew, had to google the vI commands, it’s been a long time. but I’m still a command line kind of guy.

I Edited the server IP, user name, password (I assume that is the secret variable) and extension.

Registry keys were no problem, and the menu entry came up. The first time I received a script error because I used the wrong user name. This was good because it showed me I was getting to the script properly.

After double checking the user name and changing it, I am getting nothing visible. When I evoke the script, nothing happens. When I look at my call log, I see no entry. Nothing happens on my phone.

So how can I troubleshoot this to determine where lies my breakdown? I assume it’s running the script, what logs should have been updated?

Thanks much for your help.
GB

Hi,

I would check what happens when you invoke “p.php?n=18004644446&x=201” (this is the number for FedEx, set to ring on extension 201). Or try to temporarily hard-code p.php to these variables. P.php is the script that actually does the hard work, so I would test directly on that.

Best,

Per

Dear Per:
Thanks much for your suggestions.
I added a bunch of alerts to o.php, as well as p.php to find out where I am failing.
Everything works great right up to the makeRequest function in o.php. I have good numbers, extensions, etc. But I don’t seem to be getting to p.php.

The url variable appears perfect. It seems as if the makeRequest function is not being set up correctly. I don’t know where the variable are coming from for the XMLHttp or ActiveX requests, so I’m not sure whats happening here.

I then tried to evoke the p.php html page directly from the URL line in IE, with the url variable created in o.php. I received my p.php alert telling me I stated the page, but then nothing.

do I need to do something on the server to enable the php processing? It appears to work since I can evoke the .php files from the IE menu as you described.

Any thoughts?
I appreciate you help,
GB

I think it’s something much simpler than that. What happens if you do a manually constructed URL to p.php? What happens if you hardcode the desired numbers into p.php? I would start there.

But it might be something else. About a month ago, we had our asterisk host update our Elastix to 1.0, and they killed something that made our script malfunction, basically, there was a problem sending variables from page to page, and it’s totally an error, but neither our host or Elastix seems to think it’s a problem. But the variables that hold the right-click data are suddenly out of security scope, so the same script works on every other server EXCEPT the Elastix server. For that reason, I had to just leave p.php on the Elastix server, and run o.php on another server. P.php HAS to run on the Asterisk machine or it’s not in the right security context. O.php has now been split into two files that run on our WEB server. So here is our latest working version, which you may want to try if this same bug (and I insist it’s a bug or a malconfiguration as this script works EVERYWHERE else).

On the webserver (NOT Asterisk server), there are two scripts, first O.PHP:

<script language="javascript"> 
       var hlobj = external.menuArguments.window.document.selection; 
       var hlrng = hlobj.createRange();
       var hlarg = hlrng.text; 

       hlarg = hlarg.replace(/[^\d]/g, "");
       if (hlarg.length==10 && hlarg.charAt(0)!="1") hlarg = "1" + hlarg;

       var url="http://www.mywebserver.com/o2.php?n=" + hlarg + "&x=<? echo $_REQUEST['x']; ?>" + "&p=<? echo $_REQUEST['p']; ?>";

//     location.replace(url);

       function makeRequest(url) { 

         if (window.XMLHttpRequest) { // Mozilla, Safari,... 
             http_request = new XMLHttpRequest(); 
         } else if (window.ActiveXObject) { // IE 
             http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
         } 
         http_request.open('GET', url, true); 
         http_request.send(null); 

       } 
       makeRequest(url);

</script>

Then still on the webserver, we have another file called O2.PHP, which basically just passes the data on to P.PHP on the Asterisk server:

<?php
	$x=$_GET['x'];
	$n=$_GET['n'];
	$p=$_GET['p'];
	$handle = fopen("http://pbx.myasteriskserver.com/ctc/p.php?x=$x&n=$n&p=$p", "r");
	fclose($handle);
?> 

And then finally there’s P.PHP on the Asterisk server in the /ctc directory (short for click-to-call, create it):

<html> 
<head> 
<title>Dialing...</title> 
</head> 
<body style="background: blue; color: yellow; font: 12pt bold sans-serif;"> 
<pre> 
<? 

if (( !empty( $_REQUEST['n'] ) ) && ( !empty( $_REQUEST['x'] ) ) ) 
{ 
       $num = $_REQUEST['n']; 
       $ext = $_REQUEST['x']; 
       $pre = $_REQUEST['p'];

       $num = preg_replace( "/\D/", "", $num ); 
       $num = $pre . $num;

       if ( ! empty( $num ) ) 
       { 
               echo "Dialing $num\r\n"; 

               $timeout = 10; 
               $asterisk_ip = "127.0.0.1"; 

               $socket = fsockopen($asterisk_ip,"5038", $errno, $errstr, $timeout); 
               fputs($socket, "Action: Login\r\n"); 
               fputs($socket, "UserName: admin\r\n"); 
               fputs($socket, "Secret: elastix456\r\n\r\n"); 

               $wrets=fgets($socket,128); 

               echo $wrets; 

               fputs($socket, "Action: Originate\r\n" ); 
               fputs($socket, "Channel: SIP/$ext\r\n" ); 
               fputs($socket, "Exten: $num\r\n" ); 
               fputs($socket, "Variable: _SIPADDHEADER55=Call-Info: answer-after=0\r\n" );
               fputs($socket, "Context: from-internal\r\n" );
	       fputs($socket, "CallerId: Dialing <$num>\r\n"); 
               fputs($socket, "Priority: 1\r\n" ); 
               fputs($socket, "Async: yes\r\n\r\n" ); 

               $wrets=fgets($socket,128); 
               echo $wrets; 
       } 
       else 
       { 
               echo "Unable to determine number from (" . $_REQUEST['n'] . ")\r\n"; 
       } 
} 
else 
{?> 
Please enter a number to dial. 
<?} 

?> 
</pre> 
</body> 
</html> 

See if that works.

Per