You might want to look at this thread:
https://community.freepbx.org/t/hooking-for-fun-and-income/57718/25