ftocc

Right click to dial

Domhampton
Posts: 21
Member Since:
2007-07-21

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



Praeter
Posts: 379
Member Since:
2006-10-26
If you are a php programmer

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.

--

James Fainer - FtOCC
Praeter Tech
www.praetertech.com
nexusRE - Real Estate Audio Listing



Domhampton
Posts: 21
Member Since:
2007-07-21
Still a little confused

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?



Praeter
Posts: 379
Member Since:
2006-10-26
Take your pick on

Take your pick on programming languages:

http://www.voip-info.org/wiki/view/Asterisk+manager+Examples

--

James Fainer - FtOCC
Praeter Tech
www.praetertech.com
nexusRE - Real Estate Audio Listing



Domhampton
Posts: 21
Member Since:
2007-07-21
Still need help!

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



jtknapp
Posts: 90
Member Since:
2006-06-07
Still having issues

If your still having issues send me a message as this is something that ASTassistant may help you with.

www.astassistant.com

Scott

--


Praeter
Posts: 379
Member Since:
2006-10-26
The definition of channel

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.

--

James Fainer - FtOCC
Praeter Tech
www.praetertech.com
nexusRE - Real Estate Audio Listing



Domhampton
Posts: 21
Member Since:
2007-07-21
It works!

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.



SkykingOH
Posts: 3533
Member Since:
2007-12-17
Context

Take a look at the O'reilly book "Asterisk, The future of telephony' it is the definitive reference on asterisk programing.

--

Scott

aka "Skyking"



mmitchel
Posts: 320
Member Since:
2007-01-10
FYI - Extremely Useful...

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



SkykingOH
Posts: 3533
Member Since:
2007-12-17
A context is a section of

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
--

Scott

aka "Skyking"



Praeter
Posts: 379
Member Since:
2006-10-26
Just beware of syntax

Just beware of syntax changes from asterisk 1.2 to >=1.4. I am not certain they have updated the book to capture the changes.

--

James Fainer - FtOCC
Praeter Tech
www.praetertech.com
nexusRE - Real Estate Audio Listing



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.