It’s my first time working with asterisk and I came across the following project.
I’m working with raspberry pi with installed RasPBX.
The purpose of the project is to action a relay when an internal number receives a call.
I create a python script that action the relay (tested and it works if it is launched manually via cli).
The problem is that I can’t understand to trigger a python script when the internal number (300) receives a call.
I tried to add a command into extensions_custom.conf file like:
Specifying the full path to the python binary usually does the trick for me. You could also include an appropriate #! line at the top of the python file, pointing to the python binary you want to run.
The path of your console session, and the path when running the System application, can be very different.
Also, while for this project it may not matter much, be aware of the security implications if using caller controlled/influenced variables with calls to System.
Additionally just adding an “action_relay” context doesn’t mean it’ll be used. If FreePBX is in use, you also need to find out how to get your context used.
I add the #! string into python file and i delete the context.
I used AGI command.
Now when I call the internal number into log file i see this two lines:
res_agi.c: Launched AGI Script /path_to_file/file.py
res_agi.c: <SIP/xxxxxxx>AGI Script file.py completed, returning 0
I presume that the python script was running but the relay remained off.
Permissions are also a frequent culprit. You can change permissions to ‘777’ (a true mark of a newbie) as long as you remember to change them back. If you have a permissions problem, seek to grant as little (only read and/or execute) access as possible.
Maybe moving your script to an Asterisk directory (like astagidir which is usually /var/lib/asterisk/agi-bin/). Your script isn’t an AGI, but ‘agi adjacent.’