FreePBX - customized call control

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?

I use FreePBX and microSIP as end point client.

@lgaetz posted a whilelisting script a month or two ago. That might be interesting to you.

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).

thanks Lorne!

my current setup is:
cat extensiona_custom.conf
exten => _X.,1,NoOp(+++++++++++++++++++++++++++++++++DID: ${CDR(did)})
exten => _X.,n,ExecIF($[${VALID_EXTEN(010-cid,${CALLERID(num)})}]?Gosub(010-cid,${CALLERID(num)},1))

;exten => _010XXXX,1,Set(CALLERID(num)=${CALLERID(num):3})
;exten => _010XXXX,n,Set(CALLERID(ANI-all)=${CALLERID(num)})
;exten => _010XXXX,n,Return()
;exten => _X.,1,Set(CALLERID(num)=${CALLERID(num)})
;exten => _X.,n,Set(CALLERID(ANI-all)=${CALLERID(num)})
;exten => _X.,n,Return()

exten => _X.,1,NoOp(+++++++++++++++++++++++++++++++++DID: ${FROM_DID})
;exten => _X.,n,Set(CALLERID(num)=${CDR(did)})
;exten => _X.,n,Set(CALLERID(ANI-all)=${CDR(did)})
exten => _X.,n,Return()

Can you please explain solution a bit more?
it would be perfect if possible to include blacklist solution (mentioned in your other post).

I haven’t purchased Sagoma support so far. I can see that gold package includes 60 min of work, would it be sufficient for this?

As I’ve written in the past, don’t use from-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.

1 Like

ok, all clear.
60 min is not much for sure.

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.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.