Right click to dial
I'm not sure if this is a hud lite or trix box query but may you can tell me.
I have a tribox running with a recptionist using hudlite to screen incoming calls which works great. I also run a booking system which uses the PHP and mySql running with trixbox.
What i would like to do is navigate to a booking and see the phone number and either click a button next to it to run a php script or right click and select an option ring number.
This would then call a script in hudlite or via php to ring the reception phone and connect that call to the relevent number (adding a 9 of course)
I'm sure this is probably very easy but my backend coding is not so good and the php is handled by another developer but if i can give hime the code then he can add it to the booking system.
Thanks in advance
If you are a php programmer it would be much easier to accomplish this from your booking system directly without needing to integrate HUDlite into the mix. This can directly be done utilizing the Asterisk Manager interface. There are some php classes out there that can make it easy or if this is also a learning moment you can cook your own. I find www.voip-info.org is always a good source of information to both find existing classes or to find the available commands and a good quantity of examples. Check out :
http://www.voip-info.org/wiki/view/Asterisk+manager+API
for the Manager API.
Thanks that looks like just what i'm after, however i'm a little confused still.
I can set the permisions up in the conf file fine but my php is a little weak, is there any where i can see some example code on how to set up a connection and run a command similar to orginate that i would need to use?
Take your pick on programming languages:
http://www.voip-info.org/wiki/view/Asterisk+manager+Examples
Right, seem to be making progress. I click the link on my php page and my sip phone rings, the code also passes back success, however when i pick the phone up i get the trixbox saying hello then a tone.
My code:-
$num = $_POST['DialNumber'];//200;
$ext = 200;
$num = preg_replace( "/\D/", "", $num );
if ( ! empty( $num ) )
{
echo "Dialing $num\r\n";
$num = $num;
$timeout = 10;
$asterisk_ip = "192.168.7.5";
$socket = fsockopen($asterisk_ip,"5038", $errno, $errstr, $timeout);
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: USERNAME\r\n");
fputs($socket, "Secret: PASSWORD\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: 9$num\r\\n" );
fputs($socket, "Context: default\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['DialNumber'] . ")\r\n";
}
Any ideas welcome
If your still having issues send me a message as this is something that ASTassistant may help you with.
Scott
The definition of channel and extension can be a bit confusing. I still have to look at it carefully to ensure I don't mess it up in my mind. So hopefully I will describe it correctly and not get it backwards again.
You need to think of channel to be the equivalent of both the outbound trunk you want to use and the external phone number. IE SIP/myprovider/2035551212
Extension would be the local number or potentially a custom extension if you use 'Context' of the custom script.
I would be careful of the use of async. That could leave you customers answering what would appear to be a dead phone if you have not answered yet. It clearly has its purpose just be cautious.
Thanks for your help, that was one of the problems. The other is that the context was set to default and not "from-internal"
I've had a read of trixbox without tears but am still unsure of what the whole context thing is all about. Is there a decent explination of it as I only solved that part by luck!
Thanks once again that has sorted me right out.
I've attempted several times to get some basic functionality like this, but apparently lack the programming skills. I've read and have ALL the books, but sometimes it just takes a working example to break thru. Just wanted you to know that your snippet of code was extremely useful to me and I was able to incorporate it into a simple phone book app that I'm working on.
thanks...
- Matt
A context is a section of code in any of the extension???.conf files.
The context is the identifier that is enclsed int he brackets. The code in the context can be accessed by the context name.
There are two contexts in this example from extensions_custom.conf - One name 'custom-recordme' and the other 'app-pbdirectory-custom'
A context ends when the next one starts or the end of file is reached.
; custom-recordme,5678,1 can be used as a custom target for ; a Digital Receptionist menu or a Call Group ;[custom-recordme] ;exten => 5678,1,Wait(2) ;exten => 5678,2,Record(/tmp/asterisk-recording:gsm) ;exten => 5678,3,Wait(2) ;exten => 5678,4,Playback(/tmp/asterisk-recording) ;exten => 5678,5,Wait(2) ;exten => 5678,6,Hangup [code] [app-pbdirectory-custom] exten => Hangup,1,Hangup



Member Since:
2007-07-21