I am new to FreePBX and I am looking to create some automation on inbound routes.
I have written a Python script that does a REST lookup into our service management software and extracts an extension number based on the incoming caller ID, of a queue for the team that services the customer. The script works, but I was not sure how to integrate it into the system. It looks like I need to use AGI for this, but I cannot see any way to add the agi module to Python. I am using the Freepbx ISO which has Python installed, yet there is no Asterisk module, or AGI module and I can’t seem to see a way to get it installed. I could then use the get and set variable functions to parse the caller ID in and the destination number back.
Yes thanks for this. I read this and figured this was the way. I struggle with Perl and PHP, but I can get around Python.
I have written a script in python and tested it. The script needs to make a few successive rest calls and parse the json, so it needs to be done externally. It looks like there are modules for python to import for AGI, but they don’t seem to exist on the native Freepbx ISO. I installed pip, and from there pyst, but I still didn’t seem to get the AGI functions to read and write Asterisk variables. I’ll reread again tomorrow and see if I can figure it out. The script takes the caller ID, does some rest calls and returns an extension number to forward the call to, so I think I have done the hard part.
I took another look this morning. I used the PHP example to simply grab the caller ID and return it. I figure if I get this working, I can either figure out how to do rest calls and json extraction in PHP, or simply call my Python script from within the PHP script.
I’ll see if I can do the REST calls and JSON directly for neatness and learn a new programming language as well.
Yes I saw this in the docos. However there is some branching logic required. I have to do a lookup first on contact. If there is no return, I have to search company. On either of these, I get a company id. I then need to search the territory record based on the company, to pull out the appropriate target queue number.
I think this needs to be scripted. I have it working with PHP calling python as I can’t seem to get an AGI module for python, but I am now learning PHP syntax and writing the script entirely in PHP.
Well I knuckled down and started to get ofay with PHP. It wasn’t too tricky and I have a tidy script to do what I want and I have begun to learn a new programming language.
Very happy with the outcome. Thanks again all.