Well, as promised. Here is a short thing I did today for making freepbx signal incoming calls on one/more trunks using mqtt (as the “old” mqtt script was still python2 and this is not really supported anymore).
This was tested under freepbx 15
At first we have to install some package (using ssh):
yum upgrade
yum install python-paho-mqtt
For better convenience we link python3.6 to python3
ln -s /usr/bin/python3.6 /usr/bin/python3
Then we use the python-script enlcosed.
trunk_mqtt.tgz (660 Bytes)
Save it to /var/lib/asterisk/agi-bin/trunk_mqtt.py and set mqtt-server and credentials at your need.
do a chmod +x on it
You can easily test it:
/var/lib/asterisk/agi-bin/trunk_mqtt.py your/topic sip:[email protected]:5060`
and you should see a mqtt-message in your brokers logfiles (or wherever)
Then, we navigate to our trunk in freepbx and set a context (eg from-sipprovider).
We now edit /etc/asterisk/extensions_custom.conf and add:
[from-sipprovider]
exten => _X.,1,System(/var/lib/asterisk/agi-bin/trunk_mqtt.py your/topic ${SIPURI})
exten => _X.,2,DumpChan()
exten => _X.,3,Goto(from-trunk,${EXTEN},1)
and now we reload the dialplan using the shell:
rasterisk -x'dialplan reload'
Thats all. Now we should get a notification with the calling number by mqtt whenever there is an incoming call on our trunk.
I hope, this helps someone. It is surely not beautiful and maybe there are better possibilities for this, but at least it works…
And sorry for the weird formatting. But this forum does not seem to know source-code tags (or maybe I am just too stupid)