xmpp asterisk

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.


context macro-XMPPSupport {

  s => {




    if (${num_members} > 0) {


      NoOP(${num_members} members on queue ${QUEUE_XMPP} - ${queue_members});

      while (${x} < ${num_members}) {

        x = ${x} + 1;

        if (${num_members} = 1) {

        else {


        agi(get_exten_jid.agi); // This AGI gets the JID from extension. Download the script here (DB Postgresql)
        NoOP(Sending message to extension ${ramal} - jabber id ${jid});

context macro-SendJabberUra {

  s => {


macro SendJabberUra(DST, MSG) {

  NoOp (Sending message to ${DST});

  // ${XMPPDOMAIN} can be setted in [globals] context too.
  // Don't forget to set ${RESOURCE_XMPP} variable in [globals] context. 
  // It should be the resource configured in xmpp.conf

That is it. Now you just need to adapt the code to your system and start to use the new feature.

See you soon.

Social Network Widget by Acurax Small Business Website Designers
Visit Us On FacebookVisit Us On TwitterCheck Our FeedVisit Us On Linkedin