Let’s imagine the following scenario: your company have a phone helpdesk to provide support to your customers and you use an Asterisk queue to answer this calls. Several extensions are members of this queue, but the users logon and logoff on the queue based on their work hours. All users also have a XMPP account used for internal purposes.
What if in every call directed to helpdesk queue all members logged in the queue received a XMPP notification informing the customer name that is calling?
This can be done and works great!
But how?
Well, there are a few requisites that must be accomplished.
Ok, what do I need?
You need:
- A running Asterisk 11 (or later)
- A running XMPP server (Openfire, for example)
- Asterisk XMPP support configured (like described here).
- A column in sippeers table used to store extension’s JID.
- A script to identify your customer name based on callerid number.
Done, what else?
Edit /etc/asterisk/extensions.conf, and insert the following lines before send call to queue:
; Next AGI (getclient.agi) is not the subject of this post ; It should identify your customer name based in its callerid number ; You should store customer name in ${CUSTOMER} variable. same => n,agi(getclient.agi) ; ${QUEUE_XMPP} can be setted in [globals] context. same => n,Set(QUEUE_XMPP="helpdesk") same => n,Set(MSGXMPP="Support: Customer ${CUSTOMER}") same => n,macro(XMPPSupport,${MSGXMPP},${QUEUE_XMPP})
XMPPSupport is an Asterisk macro that must exists in /etc/asterisk/extensions.ael.
Code:
context macro-XMPPSupport { s => { &XMPPSupport(${ARG1},${ARG2}); }; }; macro XMPPSupport(MSGXMPP,QUEUE_XMPP) { x=0; num_members=${QUEUE_MEMBER(${QUEUE_XMPP},count)}; if (${num_members} > 0) { Set(queue_members=${QUEUE_MEMBER_LIST(${QUEUE_XMPP})}); NoOP(${num_members} members on queue ${QUEUE_XMPP} - ${queue_members}); while (${x} < ${num_members}) { x = ${x} + 1; if (${num_members} = 1) { Set(member=${queue_members}); } else { Set(member=${CUT(queue_members,\,,${x})}); } Set(ramal=${CUT(member,"/",2)}); agi(get_exten_jid.agi); // This AGI gets the JID from extension. Download the script here (DB Postgresql) Set(jid=${XMPPJID}); Set(user=${CUT(jid,"@",1)}); NoOP(Sending message to extension ${ramal} - jabber id ${jid}); &SendJabberUra(${user},${MSGXMPP}); } } }; context macro-SendJabberUra { s => { &SendJabberUra(${ARG1},${ARG2}); }; }; macro SendJabberUra(DST, MSG) { NoOp (Sending message to ${DST}); // ${XMPPDOMAIN} can be setted in [globals] context too. XMPPDOMAIN="yourjabberdomain"; // Don't forget to set ${RESOURCE_XMPP} variable in [globals] context. // It should be the resource configured in xmpp.conf JabberSend(${RESOURCE_XMPP},${DST}@${XMPPDOMAIN},${MSG}); };
That is it. Now you just need to adapt the code to your system and start to use the new feature.
See you soon.