I am trying to configure FreePBX to have different call handling depending on external script output:
When call comes (SIP invite), FreePBX should recognize CID/DID, and before sending call to extension and before sending ringing (or session in progress) to originator, to trigger external script. Script will invoke call on external system and get feedback.
Based on this feedback, call should be either: - forwarded to specific extension with normal call flow (ringing and then answer) - deny call and send SIP 503 (or any other denial SIP code) to originator
From sender/originator point of view, in case of call denial, call should have SIP INVITE and SIP 503 at end (with no intermediate messages).
Any suggestion how to solve this or what would be best approach for this?
If the action must be done before any 1XX messages are sent to the provider, then your only option is a block of custom dialplan. Config the trunk with context set to your dialplan, do the API call etc, and then end with a goto to from-trunk. Sounds like fun, if there is budget for this, we can prob assist at Sangoma Support (link above).
my current setup is:
cat extensiona_custom.conf
[from-pstn-custom]
exten => _X.,1,NoOp(+++++++++++++++++++++++++++++++++DID: ${CDR(did)})
exten => _X.,n,ExecIF($[${VALID_EXTEN(010-cid,${CALLERID(num)})}]?Gosub(010-cid,${CALLERID(num)},1))
As I’ve written in the past, don’t usefrom-pstn-custom. Since I only have a vague sense of what you’re trying to accomplish, I have no idea if 60 minutes would be enough, but know that the initial call to get things started can take 20+ minutes, so an hour is not as generous as you think it might be.
In next days I will finish preparation on my side (external scripts and some other stuff), then I will come back and buy support hours.
many thanks for feedback.