context myivr{ s => { goto myivr|ivr|background; }; ivr => { Set(QUEUENAME=support); x=0; Answer; Wait(1); background: Background(ivr_welcome); backgroundoptions: Background(ivr_options); WaitExten(3); Queue(reception); }; 1 => { // Support goto myivrsupport|support|1; }; 2 => { // Sales Queue(sales); }; i => { x=${x}+1; Playback(ivr_invalid_option); goto myivr|ivr|backgroundoptions; }; }; context myivrsupport { support => { NoOp(Support selected); code: y=0; entercode: y=${y}+1; Read(code,ivr_customer_code,4); NoOp(Code ${code}); agi(getCustomer.agi,${code}); NoOp("${CUSTOMER_ID}"); if ("${CUSTOMER_ID}" = "") { if (${y}=3) { wait(1); Playback(ivr_invalid_customer_code); Playback(ivr_bye); Playback(congestion); Hangup; } wait(1); Playback(ivr_invalid_customer_code); Playback(ivr_try_again); goto myivrsupport|support|entercode; } else { goto support|${CUSTOMER_NAME}|1; } }; }; context support { h => { Hangup; } _. => { NoOP (Customer ${CUSTOMER_NAME}); Set(JABBERMSG="Support: Customer ${CUSTOMER_NAME}"); &XMPPSupportMSG(${JABBERMSG}); wait(1); Playback(ivr_support_announce1); Playback(ivr_support_announce2); Playback(ivr_support_announce3); Queue(support); }; }; context macro-XMPPSupportMSG { s => { &XMPPSupportMSG(${ARG1}); return; }; }; macro XMPPSupportMSG(JABBERMSG) { x=0; Set(members_count=${QUEUE_MEMBER(${QUEUENAME},free)}); if (${members_count} > 0) { Set(queue_members=${QUEUE_MEMBER_LIST(${QUEUENAME})}); NoOP(${members_count} member(s) in queue support - ${queue_members}); while (${x} < ${members_count}) { x = ${x} + 1; if (${members_count} = 1) { Set(chan=${queue_members}); } else { Set(chan=${CUT(queue_members,",",${x})}); } Set(member=${CUT(chan,/,2)}); agi(getJID.agi,${member}); // get jid of extension in jid variable Set(user=${CUT(jid,"@",1)}); NoOP(Sending message to extension ${member} - jabber id ${jid}); if ("${IVR}" = "example2") { agi(rt.agi); } &SendJabberIvr(${user},${JABBERMSG}); } } return; }; context macro-SendJabberIvr { s => { &SendJabberIvr(${ARG1},${ARG2}); return; }; }; macro SendJabberIvr(DST, MSG) { NoOp (Sending message to ${DST}); JabberSend(asterisk,${DST}@${XMPPDOMAIN},${MSG}); return; };