I am using freepbx and facing issue that my agents on multiple extenstion dial same number at same time

I am using freepbx and facing issue that my agents on multiple extenstion dial same number at same time
i want to fix that if one agent is dial a number then if second agent at same time then freepbx reject second agent to dial same number and reply that agent is already in call
I try extension_custom.config but my issue not solve

The use of this file is open ended. You aren’t really telling us what you put in there.

However, my feeling is that this would be a big job, and is something that really needs to be done in the CRM (customer relationship management system), not in the PABX, as you are still going to waste some agent time before the PABX blocks the call.

but are you talking about agents in queue? in that case Autofill = yes

No. That is for inbound calls to agents from the queue.

CRM is in development phase
and i put in extension_custom.conf
[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(*** GLOBAL LOCK CHECK START ***)
same => n,Set(TARGET_NUMBER=${OUTNUM})
same => n,Set(LOCK_NAME=lock_${TARGET_NUMBER})
same => n,TryLock(${LOCK_NAME},1)
same => n,GotoIf($[“${LOCK_RESULT}” = “0”]?locked,1)
same => n,MacroExit()

exten => locked,1,NoOp(Number ${TARGET_NUMBER} is already in use)
same => n,Playback(busy)
same => n,Hangup(17)


i am not using any callcenter module and also not talking about inbound calls
only talking about outbound calls

Which version of FreePBX? For the latest version, MacroExit should be “Return”

You’re misusing Trylock, it’s a function not an application. Your gotoif should look something like

same => n,GotoIf($[“${Trylock(${LOCK_RESULT})}” = “0”]?locked,1)

There will be edge cases where this dialplan may block legitimate calls, most notably for emergency calls.

How are you unlocking these locks once they are no longer needed? If you don’t do an Unlock() at some point the lock_123456789 will always show locked even when there is no call active.

It looks to me as though a data store is added to a channel with a lock, and channel termination will result in all its locks being released.

I haven’t followed this through completely, but it seems to be the only sensible thing to do, given that Asterisk doesn’t make it easy to catch every exit from a channel.