Run script on call inbound

maurizio261

Member
May 7, 2020
31
1
8
40
Hi everybody and happy new year :).

I've got some trouble with this, i need to run a script (bash or lua) on call inbound to the ring group or call center (i can route them on what i want, no special needs) for open and close an ip relay... by the way i need to execute it in loop until the phone still ringing.
I've try to put it on dial plan but it only execute it once, there is any way to do that?
 

markjcrane

Active Member
Staff member
Jul 22, 2018
532
184
43
50
You need to make sure you have the freeswitch module called curl or mod_curl. You can see this from the Advanced -> Modules page.

You can create a dialplan from the main dialplan and set the condition to look for calls that have call_direction ^inbound$ if you want. Or if you want to apply it to call calls you can put it in the global-variables dialplan.
 

maurizio261

Member
May 7, 2020
31
1
8
40
Hi markjcrane and thank you for your reply, by the way that was my first option but i've got the needs to still run the script until the call it's ringing, because it open and close cycling theip relay. So i've decided to make a bash script that read the Event Socket, filtered on my ring groups. It's little challenging but at least seems to work properly, after cleaning and approfondite test i will post it, i don't know if could be useful for someone.
 

maurizio261

Member
May 7, 2020
31
1
8
40
Here we got, there it's my bash script for my trouble, i hope this will help someone.
The script establish an Netcat connection to the Events Socket, filter events and number of the Ring Group (501 in my case), then check the NC output. I've checked the output of the Event Socket, isolate some strings to verify the call state changing (ringing , answered, dropped) and then grep everything in a loop that read anytime the nc output and then execute commands in case of call. In my exaple, it still open and close an ip relay until the call it's ringing, and then stops when the call it's answerd or dropped. The relay activate an huge lamp for let them see that an incoming call it's ringing.
After tested everything i've put it on a systemd service for automatic start after system boot and reboot, and check everything on the JuornalCtl.
 

Attachments

  • nc_socket.txt
    1.5 KB · Views: 8