Asterisk has Asterisk Manager Interface (AMI) and Asterisk Gateway Interface (AGI), using which one can trigger PHP scripts at certain events from Asterisk. Using the same PHP scripts can also instruct Asterisk what to do next to a call/conference. Are there parallels to AMI and AGI in FreeSWITCH?
For the AMI you're looking for the Event Socket Library. There are a few examples available on the mod_event_socket page.
AGI is a little different. You can do things similar in FreeSWITCH but they would recommend using lua. I've personally used the FreeSWITCH mod_perl with good results.