<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/2033/1/7/_/styles/combined.css?spaceKey=AST&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/AST/Controlling+the+way+Queues+Call+Agents">Controlling the way Queues Call Agents</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~mdavenport">Malcolm Davenport</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        change to OUTBOUND_GROUP_ONCE so we don't have to worry about inheritance<br />
    </div>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >macro callagent(device,exten) { <br>    if( ${GROUP_COUNT(${exten}@agents)}=0 ) {  <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words">Set(OUTBOUND_GROUP<span class="diff-added-chars"style="background-color: #dfd;">_ONCE</span>=${exten}@agents);</span> <br></td></tr>
            <tr><td class="diff-unchanged" >        Dial(${device},300,t); <br>        switch(${DIALSTATUS}) { <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>Notice in the above, that the commands to manipulate agents in queues have "@agents" in their arguments. This is a reference to the agents context:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: Confluence; brush: java; gutter: false"><![CDATA[
context agents { 
    // General sales queue 
    8010 =&gt; {
        Set(QUEUE_MAX_PENALTY=10); 
        Queue(sales-general,t); 
        Set(QUEUE_MAX_PENALTY=0); 
        Queue(sales-general,t); 
        Set(CALLERID(name)=EmptySalQ); 
       goto dispatch,s,1;
    } 
    // Customer Service queue 
    8011 =&gt; { 
        Set(QUEUE_MAX_PENALTY=10);
        Queue(customerservice,t); 
        Set(QUEUE_MAX_PENALTY=0);
        Queue(customerservice,t); 
        Set(CALLERID(name)=EMptyCSVQ);
        goto dispatch,s,1; 
    } 
    8013 =&gt; {
        Dial(iax2/sweatshop/9456@from-ecstacy);
        Set(CALLERID(name)=EmptySupQ); 
        Set(QUEUE_MAX_PENALTY=10); 
        Queue(support-dispatch,t); 
        Set(QUEUE_MAX_PENALTY=20); 
        Queue(support-dispatch,t);
        Set(QUEUE_MAX_PENALTY=0); // means no max 
        Queue(support-dispatch,t); 
        goto dispatch,s,1; 
    } 
    6121 =&gt; &amp;callagent(${RAQUEL},${EXTEN}); 
    6165 =&gt; &amp;callagent(${SPEARS},${EXTEN});
    6170 =&gt; &amp;callagent(${ROCK},${EXTEN}); 
    6070 =&gt; &amp;callagent(${SALINE},${EXTEN}); 
}
]]></script>
</div></div>

<p>In the above, the variables ${RAQUEL}, etc stand for actual devices to ring that person's phone (like DAHDI/37). </p>

<p>The 8010, 8011, and 8013 extensions are purely for transferring incoming callers to queues. For instance, a customer service agent might want to transfer the caller to talk to sales. The agent only has to transfer to extension 8010, in this case. </p>

<p>Here is the callagent macro, note that if a person in the queue is called, but does not answer, then they are automatically removed from the queue.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: Confluence; brush: java; gutter: false"><![CDATA[
macro callagent(device,exten) {
    if( ${GROUP_COUNT(${exten}@agents)}=0 ) { 
        Set(OUTBOUND_GROUP_ONCE=${exten}@agents);
        Dial(${device},300,t);
        switch(${DIALSTATUS}) {
            case BUSY: 
                Busy(); 
                break;
            case NOANSWER:
                Set(queue-announce-success=0);
                goto queues-manip,O${exten},1; 
            default: 
                Hangup(); 
                break; 
        } 
    }
    else { 
        Busy(); 
    } 
}
]]></script>
</div></div>

<p>In the callagent macro above, the ${exten} will be 6121, or 6165, etc, which is the extension of the agent. </p>

<p>The use of the GROUP_COUNT, and OUTBOUND_GROUP follow this line of thinking. Incoming calls can be queued to ring all agents in the current priority. If some of those agents are already talking, they would get bothersome call-waiting tones. To avoid this inconvenience, when an agent gets a call, the OUTBOUND_GROUP assigns that conversation to the group specified, for instance 6171@agents. The ${GROUP_COUNT()} variable on a subsequent call should return "1" for that group. If GROUP_COUNT returns 1, then the busy() is returned without actually trying to dial the agent.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://wiki.asterisk.org/wiki/users/viewnotifications.action" class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://wiki.asterisk.org/wiki/display/AST/Controlling+the+way+Queues+Call+Agents">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=5243037&revisedVersion=2&originalVersion=1">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/AST/Controlling+the+way+Queues+Call+Agents?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>