Posts Tagged ‘ael’

Asterisk: removing all queue dynamic members

Sunday, March 20th, 2022

Users add themselves as queue members by dialing some short number (AddQueueMember dialplan app is used). The queue may contain several dynamic members.

The task is to remove all queue members by dialing some number, no matter how much members are in this queue. Queue name is ‘superQueue’ (example for AEL, Asterisk 13):

// remove all dynamic queue members
0000 =>
{
    NoOp(superQueue member  list: ${QUEUE_MEMBER_LIST(superQueue)});

    // count members of a queue
    count=${QUEUE_MEMBER(superQueue,count)};

    // and remove all, one by one
    while (${count} >= 1) {
        Set(QMLsuperQueue=${QUEUE_MEMBER_LIST(superQueue)});
        Set(kicked=${CUT(QMLsuperQueue,\,,1)});
        Log(NOTICE, removing dynamic member: ${kicked});
        RemoveQueueMember(superQueue,${kicked});
        count=${count}-1;
    }

    Hangup();
};

Asterisk: block inbound call by CALLERID(num) (AEL syntax)

Friday, January 31st, 2014

One number :

    73522123456 =>
    {
        if(${CALLERID(num)} = 74995008119)
            {
            Hangup;
            }
        Dial(IAX2/iaxpeer/somedevice);
    }

Several numbers:

    73522123456 =>
    {
    switch (${CALLERID(num)}) {

         case 74957805170:
            NoOp(Block call from Susan);
            Hangup();
            break;

        pattern [78]4957805174:
            NoOp(Block call from Anna);
            Hangup();
            break;

        pattern [78]4957805061:
            NoOp(Block call from Lily );
            Hangup();
            break;

        pattern [78]495780508X:
            NoOp(Block call from Samantha);
            Hangup();
            break;

        default:
            Set(CDR(accountcode)=some-accountcode);
            Dial(SIP/somepeer/tomsphone01,,r);
        }
    }

pattern – here you may use constructions like [167] and/or 123X.
case – is exact sequence of symbols.

https://wiki.asterisk.org/wiki/display/AST/AEL+Conditionals