Announcing AstJAX Firefox Dialer Script

Posted by YapTele on Mon, 05/21/2007 - 09:22

Firefox asterisk click to dialYapTele.com is proud to bring you a cool little greasemonkey script which allows you to click and dial phone numbers, automatically recognised from any webpage and originate the call to your IP phone via Asterisk.

The advantage of this script, is that it makes use of the greasemonkey ajax callbacks, which allows you to click and dial a number from a hyperlink, without navigating away from the current webpage.

You can download AstJax here, click read more for Installation instructions.

Installation Instructions

  • Download AstJax
  • Install greasemonkey
  • Edit clickToCall.php (self explanatory)
  • Deploy clickToCall.php to your webserver
    (does not have to be the server Asterisk is on, as long as the webserver's IP has manager access (see manager.conf)
  • Edit astjax2.user.js
    • Define the url where you have deployed clickToCall.php
    • For US/Canada number recognition, uncomment the US numberRegex constant, and comment or delete the UK one
  • Navigate firefox to the location of astjax2.user.js
    eg "file:///home/rick/astjax2.user.js" or "c:\astjax2.user.js" etc. to install the greasemonkey script

Currently there are number parsing RegEx's for UK and US/Canada. Although this is very simple to modify for another country. You can even probably find an existing regex for numbers in your county's format at RegexLib. If you write a regex for your country's phone number format, be sure to tell us by leaving a comment so that we can add it to the script for others.

The script is based on the UPS linkify concept by by Logan Ingalls, and clickToCall.php by VoipJots.com - Props!. It also requires a manager connection to Asterisk.

Dial away! Feel free to leave any comments.

Another regexp to try...

This is great but the regexp was getting a bit too specific for me. Telephone numbers are a pain to match:

const numberRegex = /(\+\d{1,3}[\-\.\s\d\(\)]{9,17}|\b0\d{2,4}[\-\.\s\d\(\)]{7,15})/ig;

We mostly want to dial from a datbase where numbers are either written in international format, or UK format.

This matches:

1. Anything beginning +, followed by 1-3 digits, then some more digits or [- . space ( ) ] from 9 to 17 characters. (International IDDD format numbers like: +44 20 7043 7996)

2. Anything beginning "0" followed by 2-4 digits. (i.e. a UK number like 020 xxxxxxxx or 01733 xxxxxx)

Any other wacky country specific number formats at the moment are not picked up, but you could just modify this regexp or add your own matches into the list.

Posted by Anonymous on Fri, 02/01/2008 - 14:57
A few changes.

Hi
This is a nice script. to aid it being used in "larger" deployments. I have changed the script and PHP so that the calling channel is now stored in the .js script and passed to the PHP. This means that only the .js needs to be altered for each user which is simple as they just install their own one into greasemonkey.

Changes are in the .js script
Below
//Server address and clicktocall file name
const scriptURL = 'http://SERVERADDRESS/clickToCall.php';
The following line is added.
//Users Extension channel. Is now and passed to the C2C script
const scriptEXTEN = 'SIP/2206';
and
url: scriptURL + '?EXTEN=' + scriptEXTEN + '&number=' + String(numb).replace(/[\-\s\/\(\)\.]/g, "")
});
in place of the original url line

in the PHP
the line
$strChannel = "SIP/2206"; removed as now passed from the .js file
is replaced by
$strChannel .= $_GET['EXTEN'];

then all you need is a astjaxXXXX.user.js for each extension.

also in the PHP a sleep(2) does need to be added.

Ian

Posted by Anonymous on Tue, 01/01/2008 - 20:07
US Regex

try this for all United States numbers:
const numberRegex = /((\(\d{3}\)?)|(\d{3}))([\s-./]?)(\d{3})([\s-./]?)(\d{4})/ig;

Also - do not forge to follow the post below with the sleep statement

Posted by Anonymous on Mon, 12/10/2007 - 15:22
could not get this

Hi ,

Am new to Voip and give some detailed information for install and develop this.do not know how to install greasemonkey .

Thnks in advance

Posted by Anonymous on Tue, 11/20/2007 - 06:32
Help Please....

The script logs in and out (seen in *CLI) but doesn't make the call. No matter what I do, I can't get the script to dial. If I do everything manually, in * Manager, it works, but when I run the script, I just get
== Manager 'admin' logged on from 127.0.0.1
== Manager 'admin' logged off from 127.0.0.1
No call info.

Any ideas? Please help.. this is a great script, If I could get it to work.

Thanks in advance.

Marcus

Posted by mnucci on Sun, 08/12/2007 - 19:24
Asterisk Manager needs more time

I got it.

I needed to add a Sleep(2); before the fclose($oSocket);

That fixed it. Finally.

Marcus

Posted by Anonymous on Wed, 08/15/2007 - 10:46
Updated the script

Thanks, I have updated the zip package to reflect this change.

Posted by YapTele on Tue, 01/01/2008 - 22:10
please help

Hi guys!

Could you make a regex pattern for me for this number +632xxxxxxx and +63xxxxxxxxxx where x represents any number from 0 to 9.

Also, how can i used it after following the installation instructions above?

Thanks in advance,
jess

Posted by Anonymous on Wed, 06/13/2007 - 11:36
thanks man

very good! working just fine! here in Brazil!
thanks nice work!

Posted by Anonymous on Wed, 05/30/2007 - 17:33
Here's a better regex for

Here's a better regex for Brazilian users.
It will match 8 digit numbers, with or without "dash" preceded or not with prefix using or not using () eg. (031)
const numberRegex = /\b((0\d{2}|\d{2})(\)|) (\d{4}(\-\d{4}(?= )|\d{4}(?= ))))| (\d{4}(\-\d{4}|\d{4}(?= )))\b/ig

enjoy,
Caio Zanolla

Posted by Anonymous on Tue, 06/19/2007 - 18:04
Really Great!!! Works for me

Really Great!!! Works for me in France I have just change the pattern
and that's ok reallygood job!

Cheers,

Alex

Posted by Anonymous on Mon, 05/21/2007 - 19:05
Feedback

Worked a charm for me in UK. Thanks!

Posted by Anonymous on Mon, 05/21/2007 - 12:34
I'ts cool but

It works ok.. but i always have to set an account SIP in clickToCall.php If i want to the script get a channel of the user who is using the web site. How can i send the channel to the scrpit dinamically..?

Thanks from Peru.

Posted by Anonymous on Fri, 06/08/2007 - 01:33
German regex

Can someone paste a German regex?
Great Work!!

Thx

Posted by Anonymous on Thu, 06/07/2007 - 00:18
Not working

Not working here, works on some websites but most it doesn't work or only matches some numbers, even when there are multiple numbers in the same format on a page, it will turn some into a link, but not others.

Im in australia using the following regex:

/\b\d\d\d(-|\)\s|\s)\d\d\d-(\d\d\d\d|\w\w\w\w)\b/ig;

However, when I go to http://www.westnet.com.au/phone/contact/ (for example) you will see that there are some 1300 XXX XXX numbers listed on that page, all listed in identical formats.

Only 1 of them is being converted too a link, all the others are being ignored.

Any ideas?

Posted by Anonymous on Thu, 02/14/2008 - 13:18
If you look in the script

If you look in the script you will see an array which defines the types of element to search in.

If the numbers are not within this type of element (eg <span>) etc then you will need to look at the source and add the elements to the list.

Rick

Posted by YapTele on Sat, 02/23/2008 - 18:17