Add member to queue via url

Hi all, I’m looking for someone with a yoda-like skillset who can explain to me in layperson terms what I need to do to achieve my end goal.

We run two servers side by side - A FreePBX Asterisk box (just rebuilt on latest distro with Asterisk 13), and a Windows server which runs the rostering and lone worker systems for the company, which is essentially an Access DB that responds to SMS messages from the guard’s mobile phones. (probably too much information, but in the hope I can build an understanding of what I’m trying to achieve).

When one of our security personnel sends an SMS and logs in to the Access server, what I’d like it to do is add their mobile as a dynamic end-point to our main support queue, thus including them on any inbound calls. What we currently have is half a dozen phones permanently included on the queue, but as the company grows, I’d like to make it a little more slick.

When the member of the team logs out at the end of their shift, I’d like it to remove them from the end points.

My programming knowledge is very basic, but I can generally muddle through with VB.net and a little PHP. My ideal solution would be to send the variables to a php script via a HTTP link, and for a php script to use a GET statement to read in the mobile number and create the extension, then similarly to end the connection at the end of shift…

i.e. https://mypbx/loginuser.php?secret=myVerySecretPhrase&exten=447762123456&penalty=0 would log them in and
https://mypbx/logoutusr.php?secret=Same&exten=447762123456 would remove the dynamic extension.

Any thoughts on a) whether this is possible, and b) whether this already exists somewhere that you could signpost me to, and c) whether there’s a better why to achieve the end result that I haven’t thought of.

You are looking for the Asterisk Manager Interface or “direct to Asterisk” programming.

In AMI, you connect to the server through a port and set up a bidirectional conversation at the “manager” level. This is easily accomplished through direct communication with the port or through one of the many PHP libraries designed to communication with AMI.

The other way is to send “console” command to Asterisk through a “shell” interface. There are well-known agent login and logout commands that you can issue in the Asterisk “CLI” that can do the things you are trying to accomplish.

Both approaches are relatively simple and do not require any modification to the server, with the possible exception of opening a management port for AMI to something other than “localhost”.

There are several examples floating around here in the forum from the past few months. Try it and see what you can see…

Just a point of note, you can communicate with AMI with any language that knows about /dev/stdin and /dev/stdout over a tcp/5038 network connection. That’s pretty well everything, from bash use a telnet wrapper

http://marcelog.github.io/articles/php_asterisk_manager_interface_protocol_tutorial_introduction.html

for various ‘languages’

1 Like