Dynamic Queue Configuration

Hi Everyone!
Hope you guys are doing well.

I am new to asterisk. I have configured a dynamic queue name support. When user dial *300 from it’s extension he will be login or logout from the queue.Now every extension can dial *300 to login or logout from the queue and it’s working fine. But I want to do it such way that user can dial his own extension starting with * to logout and login to the queue. And if he tries to dial some other extension to login/logout then hangup. In this way every user has to dial his own extension starting with * to login or logout.

I am using 001 extension in the dialplan. Let’s say you have 3 extension 000,001 and 002 then how would you do it?

exten => *300,1,NoOp(001 login/logout)
same => n,GotoIf({REGEX("SIP/001",{DB(Queue/PersistentMembers/support)})}?*300-logout,1:*300-login,1)
same => n,Hangup

exten => *300-logout,1,NoOp(SIP 001 exists, logout)
same => n,RemoveQueueMember(support,SIP/001)
same => n,Playback(beeperr)
same => n,Hangup

exten => *300-login,1,NoOp(SIP 001 doesn’t exist, login)
same => n,AddQueueMember(support,SIP/001)
same => n,Playback(beep)
same => n,Hangup

Kindly provide support. Thanks.

You don’t need to do anything for Asterisk to hang up on an invalid extension. That makes me think there is something missing from the information you have provided.

You might want to note that priority 3, on extension *300, can never be executed, as the Goto will always succeed, one way or the other.

Hi David!
The configuration I have provided is working fine. For the ref see Asterisk Tutorial No. 27 on youtube.

If it is working fine, why are you asking for support to make it work?

Kindly provide support. Thanks.

(Note the unreachable GoTo has no effect on function; it is completely redundant.)

He’s one of the most active and knowledgable guys on this forum. What he suggested still holds true in your case.
This is a community forum and people help one another in their free time and don’t get paid for it.

:frowning: Ahan. What informtion do you need more?

Hi David!
It’s working fine. Let me tell you more what I have done.

1- I have created a queue called support in queues.conf file.
2- Second I have added 2 peers in it. 001 and 002 (Extensions)
3- My purpose is I want to make a dynamic queue. *300 is to add/remove queue member dynamically. But as you can see in the Dial plan it would add/remove only extension 001 from the queue. Even if user with extension 002 would dial *300 from it’s phone then it will add/remove 001 from the queue.

But I don’t want that. I want that if only user with extension 001 would can use *300 to add him or remove him from the queue. Or maybe if user 001 dial *001 or any other then it allows him to add/remove from the queue.

I have seen this video for that purpose. But I am not getting what I want. Let me know if it is better now.


I don’t claim this is a perfect code (and un-tested) but you can do something like below. Treat this as a hint and work on to improve it.

;Accepts call for *000 to *009
exten => _*00X,1,NoOp(${CALLERID(num)} login/logout)
Same => n,ExecIf($[“${CALLERID(num)}” = “${EXTEN:1}”]?NoOp(Accepts call):HangUp())
same => n,GotoIf({REGEX("SIP/${CALLERID(num)}",{DB(Queue/PersistentMembers/support)})}?logout,1:login,1)

exten => logout,1,NoOp(SIP ${CALLERID(num)} exists, logout)
same => n,RemoveQueueMember(support,SIP/${CALLERID(num)})
same => n,Playback(beeperr)
same => n,Hangup

exten => login,1,NoOp(SIP ${CALLERID(num)} doesn’t exist, login)
same => n,AddQueueMember(support,SIP/${CALLERID(num)})
same => n,Playback(beep)
same => n,Hangup
1 Like

Thanks a lot satish4asterisk. Your configs are working fine. I just added $ before REGEX expression.

I really appreciate your help. Your code is perfect.
Please explain little bit about ${CALLERID(num)}?

In simple words, that’s your SIP endpoint. However you can read/write CallerID so you need to be careful when using it in your dialplan.

1 Like

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