Superdial macro

  • This macro makes it MUCH easier to try to dial multiple extensions in a sequence you define
  • Explain why people would use this. What are the pros/cons

Pre Version 1.2


[macro-superdial]
; add some abilities to Dial(Technology/resource[&Technology2/resource2...][|timeout][|options][|URL]):
;	${ARG1} - Technology/resource[&Technology2/resource2...] (like SIP/2201)
;	${ARG2} - timeout in seconds
;	${ARG3} - Dial command options 
;	${ARG4} - URL (see Dial command for info)
;	${ARG5} - Group name (used if you want to limit the number of calls in any way)
;	${ARG6} - Max. group number (maximum number of concurrent calls you want to allow for that group)
;	${ARG7} - Caller ID name (typically for outgoing calls only)
;	${ARG8} - Caller ID number (typically for outgoing calls only)
;	${ARG9} - CDR account name (over-rides account group setting in sip.conf or iax.conf)
;	${ARG10} - voicemail to send to if noanswer (typically for incoming calls only)
; Usage instructions:
; 	for an outgoing call, in extensions.conf you just list multiple lines like: 
;		exten => s,1,Macro(superdial,IAX2/voipjet/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,voipjet) 
;		exten => s,2,Macro(superdial,IAX2/alpeh-com/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,aleph) 
;	and it will take the first one that is available
;
;	it also works for incoming like so .. 
;		exten => s,1,Wait(2)
;		exten => s,2,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
;		exten => s,3,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
;		exten => s,4,Voicemail(b${GENERALVM})
;	and then goes to unavailable voicemail if one times out .. otherwise (eg if busy) it tries the next extension 
;	if all are busy or unavailable .. it gets to the last priority which is the busy voicemail
;
exten => s,1,SetGroup(${ARG5})
exten => s,2,CheckGroup(${ARG6})	; jump to 103 if count on group ${ARG5} is already at ${ARG6}
exten => s,3,GotoIf($["${ARG7}" = ""]?macro-superdial,s,5)
exten => s,4,SetCIDName(${ARG7})	; skip this if ARG7 is empty
exten => s,5,GotoIf($["${ARG8}" = ""]?macro-superdial,s,7)
exten => s,6,SetCIDNum(${ARG8})		; skip this if ARG8 is empty
exten => s,7,GotoIf($["${ARG9}" = ""]?macro-superdial,s,9)
exten => s,8,SetAccount(${ARG9})	; skip this if ARG9 is empty
exten => s,9,Dial(${ARG1},${ARG2},${ARG3},${ARG4})
exten => s,10,Goto(s-${DIALSTATUS},1)
exten => s,103,Goto(s-CHANUNAVAIL,1)
exten => s-BUSY,1,Noop
exten => s-NOANSWER,1,GotoIf($["${ARG10}" = ""]?macro-superdial,s-NOANSWER,3)
exten => s-NOANSWER,2,Voicemail(${ARG10})
exten => s-NOANSWER,3,Noop
exten => _s-.,1,Noop


Version 1.2+


[macro-superdial]
; add some abilities to Dial(Technology/resource[&Technology2/resource2...][|timeout][|options][|URL]):
;       ${ARG1} - Technology/resource[&Technology2/resource2...] (like SIP/2201)
;       ${ARG2} - timeout in seconds
;       ${ARG3} - Dial command options
;       ${ARG4} - URL (see Dial command for info)
;       ${ARG5} - Group name (used if you want to limit the number of calls in any way)
;       ${ARG6} - Max. group number (maximum number of concurrent calls you want to allow for that group)
;       ${ARG7} - Caller ID name (typically for outgoing calls only)
;       ${ARG8} - Caller ID number (typically for outgoing calls only)
;       ${ARG9} - CDR account name (over-rides account group setting in sip.conf or iax.conf)
;       ${ARG10} - voicemail to send to if noanswer (typically for incoming calls only)
; Usage instructions:
;       for an outgoing call, in extensions.conf you just list multiple lines like:
;               exten => s,1,Macro(superdial,IAX2/voipjet/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,voipjet)
;               exten => s,2,Macro(superdial,IAX2/alpeh-com/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,aleph)
;       and it will take the first one that is available
;
;       it also works for incoming like so ..
;               exten => s,1,Wait(2)
;               exten => s,2,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
;               exten => s,3,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
;               exten => s,4,Voicemail(b${GENERALVM})
;       and then goes to unavailable voicemail if one times out .. otherwise (eg if busy) it tries the next extension
;       if all are busy or unavailable .. it gets to the last priority which is the busy voicemail
;
exten => s,1,Set(GROUP()=${ARG5})
exten => s,2,Set(GROUPCOUNT=${GROUP_COUNT(${ARG5})})
exten => s,3,GotoIf($[${GROUPCOUNT} > ${ARG6}]?104)
exten => s,4,GotoIf($["${ARG7}" = ""]?macro-superdial,s,6)
exten => s,5,Set(CALLERID(name)=${ARG7})        ; skip this if ARG7 is empty
exten => s,6,GotoIf($["${ARG8}" = ""]?macro-superdial,s,8)
exten => s,7,Set(CALLERID(number)=${ARG8})              ; skip this if ARG8 is empty
exten => s,8,GotoIf($["${ARG9}" = ""]?macro-superdial,s,10)
exten => s,9,SetAccount(${ARG9})        ; skip this if ARG9 is empty
exten => s,10,Dial(${ARG1},${ARG2},${ARG3},${ARG4})
exten => s,11,Goto(s-${DIALSTATUS},1)
exten => s,104,Goto(s-CHANUNAVAIL,1)
exten => s-BUSY,1,Noop
exten => s-NOANSWER,1,GotoIf($["${ARG10}" = ""]?macro-superdial,s-NOANSWER,3)
exten => s-NOANSWER,2,Voicemail(${ARG10})
exten => s-NOANSWER,3,Noop
exten => _s-.,1,Noop



AEL2 Version

macro superdial (dial_type_res,dial_timeout,dial_options,dial_url,group,group_max,cid_name,cid_num,cdr_acc,voicemail) {
    //
    // add some abilities to Dial(Technology/resource[&Technology2/resource2...][|timeout][|options][|URL]):
    //  ${dial_type_res} - Technology/resource[&Technology2/resource2...] (like SIP/2201)
    //  ${dial_timeout} - timeout in seconds
    //  ${dial_options} - Dial command options
    //  ${dial_url}     - URL (see Dial command for info)
    //  ${group}        - Group name (used if you want to limit the number of calls in any way)
    //  ${group_max}    - Max. group number (maximum number of concurrent calls you want to allow for that group)
    //  ${cid_name}     - Caller ID name (typically for outgoing calls only)
    //  ${cid_num}      - Caller ID number (typically for outgoing calls only)
    //  ${cdr_acc}      - CDR account name (over-rides account group setting in sip.conf or iax.conf)
    //  ${voicemail}    - voicemail to send to if noanswer (typically for incoming calls only)
    //
    // Usage instructions:
    //  for an outgoing call, in extensions.conf you just list multiple lines like:
    //  s => {
    //      &superdial(IAX2/voipjet/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,voipjet);
    //      &superdial(IAX2/alpeh-com/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,aleph);
    //  }
    //  and it will take the first one that is available
    //
    //  it also works for incoming like so ..
    //  s => {
    //      Wait(2);
    //      &superdial(${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM});
    //      &superdial(${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM});
    //      Voicemail(b${GENERALVM});
    //  }
    //  and then goes to unavailable voicemail if one times out .. otherwise (eg if busy) it tries the next extension
    //  if all are busy or unavailable .. it gets to the last priority which is the busy voicemail
    //

    Set(GROUP()=${group});
    Set(GROUPCOUNT=${GROUP_COUNT(${group})});

    if(${GROUPCOUNT} > ${group_max}) { goto chanunavail; }

cid_name:
    if("${cid_name}" = "") { goto cid_num; }    // skip this if cid_name is empty
    Set(CALLERID(name)=${cid_name});
cid_num:
    if("${cid_num}" = "") { goto cdr_acc; } // skip this if cid_num is empty
    Set(CALLERID(number)=${cid_num});
cdr_acc:
    if("${cdr_acc}" = "") { goto dial; }    // skip this if cdr_acc is empty
    Set(${ACCOUNTCODE}=${cdr_acc});
dial:
    // AEL2 is not accepting the 4th argument to Dial
    // Dial(${dial_type_res},${dial_timeout},${dial_options},${dial_url});
    Dial(${dial_type_res},${dial_timeout},${dial_options});

    switch (${DIALSTATUS}) {
        case CHANUNAVAIL:
        case CONGESTION:
        case NOANSWER:
        case BUSY:
            if("${voicemail}" != "") {
                Voicemail(${voicemail});
                Hangup;
            }
        default:
            Noop(${DIALSTATUS});
            break;
    }

chanunavail:
}


See Also:

  • This macro makes it MUCH easier to try to dial multiple extensions in a sequence you define
  • Explain why people would use this. What are the pros/cons

Pre Version 1.2


[macro-superdial]
; add some abilities to Dial(Technology/resource[&Technology2/resource2...][|timeout][|options][|URL]):
;	${ARG1} - Technology/resource[&Technology2/resource2...] (like SIP/2201)
;	${ARG2} - timeout in seconds
;	${ARG3} - Dial command options 
;	${ARG4} - URL (see Dial command for info)
;	${ARG5} - Group name (used if you want to limit the number of calls in any way)
;	${ARG6} - Max. group number (maximum number of concurrent calls you want to allow for that group)
;	${ARG7} - Caller ID name (typically for outgoing calls only)
;	${ARG8} - Caller ID number (typically for outgoing calls only)
;	${ARG9} - CDR account name (over-rides account group setting in sip.conf or iax.conf)
;	${ARG10} - voicemail to send to if noanswer (typically for incoming calls only)
; Usage instructions:
; 	for an outgoing call, in extensions.conf you just list multiple lines like: 
;		exten => s,1,Macro(superdial,IAX2/voipjet/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,voipjet) 
;		exten => s,2,Macro(superdial,IAX2/alpeh-com/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,aleph) 
;	and it will take the first one that is available
;
;	it also works for incoming like so .. 
;		exten => s,1,Wait(2)
;		exten => s,2,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
;		exten => s,3,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
;		exten => s,4,Voicemail(b${GENERALVM})
;	and then goes to unavailable voicemail if one times out .. otherwise (eg if busy) it tries the next extension 
;	if all are busy or unavailable .. it gets to the last priority which is the busy voicemail
;
exten => s,1,SetGroup(${ARG5})
exten => s,2,CheckGroup(${ARG6})	; jump to 103 if count on group ${ARG5} is already at ${ARG6}
exten => s,3,GotoIf($["${ARG7}" = ""]?macro-superdial,s,5)
exten => s,4,SetCIDName(${ARG7})	; skip this if ARG7 is empty
exten => s,5,GotoIf($["${ARG8}" = ""]?macro-superdial,s,7)
exten => s,6,SetCIDNum(${ARG8})		; skip this if ARG8 is empty
exten => s,7,GotoIf($["${ARG9}" = ""]?macro-superdial,s,9)
exten => s,8,SetAccount(${ARG9})	; skip this if ARG9 is empty
exten => s,9,Dial(${ARG1},${ARG2},${ARG3},${ARG4})
exten => s,10,Goto(s-${DIALSTATUS},1)
exten => s,103,Goto(s-CHANUNAVAIL,1)
exten => s-BUSY,1,Noop
exten => s-NOANSWER,1,GotoIf($["${ARG10}" = ""]?macro-superdial,s-NOANSWER,3)
exten => s-NOANSWER,2,Voicemail(${ARG10})
exten => s-NOANSWER,3,Noop
exten => _s-.,1,Noop


Version 1.2+


[macro-superdial]
; add some abilities to Dial(Technology/resource[&Technology2/resource2...][|timeout][|options][|URL]):
;       ${ARG1} - Technology/resource[&Technology2/resource2...] (like SIP/2201)
;       ${ARG2} - timeout in seconds
;       ${ARG3} - Dial command options
;       ${ARG4} - URL (see Dial command for info)
;       ${ARG5} - Group name (used if you want to limit the number of calls in any way)
;       ${ARG6} - Max. group number (maximum number of concurrent calls you want to allow for that group)
;       ${ARG7} - Caller ID name (typically for outgoing calls only)
;       ${ARG8} - Caller ID number (typically for outgoing calls only)
;       ${ARG9} - CDR account name (over-rides account group setting in sip.conf or iax.conf)
;       ${ARG10} - voicemail to send to if noanswer (typically for incoming calls only)
; Usage instructions:
;       for an outgoing call, in extensions.conf you just list multiple lines like:
;               exten => s,1,Macro(superdial,IAX2/voipjet/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,voipjet)
;               exten => s,2,Macro(superdial,IAX2/alpeh-com/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,aleph)
;       and it will take the first one that is available
;
;       it also works for incoming like so ..
;               exten => s,1,Wait(2)
;               exten => s,2,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
;               exten => s,3,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
;               exten => s,4,Voicemail(b${GENERALVM})
;       and then goes to unavailable voicemail if one times out .. otherwise (eg if busy) it tries the next extension
;       if all are busy or unavailable .. it gets to the last priority which is the busy voicemail
;
exten => s,1,Set(GROUP()=${ARG5})
exten => s,2,Set(GROUPCOUNT=${GROUP_COUNT(${ARG5})})
exten => s,3,GotoIf($[${GROUPCOUNT} > ${ARG6}]?104)
exten => s,4,GotoIf($["${ARG7}" = ""]?macro-superdial,s,6)
exten => s,5,Set(CALLERID(name)=${ARG7})        ; skip this if ARG7 is empty
exten => s,6,GotoIf($["${ARG8}" = ""]?macro-superdial,s,8)
exten => s,7,Set(CALLERID(number)=${ARG8})              ; skip this if ARG8 is empty
exten => s,8,GotoIf($["${ARG9}" = ""]?macro-superdial,s,10)
exten => s,9,SetAccount(${ARG9})        ; skip this if ARG9 is empty
exten => s,10,Dial(${ARG1},${ARG2},${ARG3},${ARG4})
exten => s,11,Goto(s-${DIALSTATUS},1)
exten => s,104,Goto(s-CHANUNAVAIL,1)
exten => s-BUSY,1,Noop
exten => s-NOANSWER,1,GotoIf($["${ARG10}" = ""]?macro-superdial,s-NOANSWER,3)
exten => s-NOANSWER,2,Voicemail(${ARG10})
exten => s-NOANSWER,3,Noop
exten => _s-.,1,Noop



AEL2 Version

macro superdial (dial_type_res,dial_timeout,dial_options,dial_url,group,group_max,cid_name,cid_num,cdr_acc,voicemail) {
    //
    // add some abilities to Dial(Technology/resource[&Technology2/resource2...][|timeout][|options][|URL]):
    //  ${dial_type_res} - Technology/resource[&Technology2/resource2...] (like SIP/2201)
    //  ${dial_timeout} - timeout in seconds
    //  ${dial_options} - Dial command options
    //  ${dial_url}     - URL (see Dial command for info)
    //  ${group}        - Group name (used if you want to limit the number of calls in any way)
    //  ${group_max}    - Max. group number (maximum number of concurrent calls you want to allow for that group)
    //  ${cid_name}     - Caller ID name (typically for outgoing calls only)
    //  ${cid_num}      - Caller ID number (typically for outgoing calls only)
    //  ${cdr_acc}      - CDR account name (over-rides account group setting in sip.conf or iax.conf)
    //  ${voicemail}    - voicemail to send to if noanswer (typically for incoming calls only)
    //
    // Usage instructions:
    //  for an outgoing call, in extensions.conf you just list multiple lines like:
    //  s => {
    //      &superdial(IAX2/voipjet/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,voipjet);
    //      &superdial(IAX2/alpeh-com/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,aleph);
    //  }
    //  and it will take the first one that is available
    //
    //  it also works for incoming like so ..
    //  s => {
    //      Wait(2);
    //      &superdial(${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM});
    //      &superdial(${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM});
    //      Voicemail(b${GENERALVM});
    //  }
    //  and then goes to unavailable voicemail if one times out .. otherwise (eg if busy) it tries the next extension
    //  if all are busy or unavailable .. it gets to the last priority which is the busy voicemail
    //

    Set(GROUP()=${group});
    Set(GROUPCOUNT=${GROUP_COUNT(${group})});

    if(${GROUPCOUNT} > ${group_max}) { goto chanunavail; }

cid_name:
    if("${cid_name}" = "") { goto cid_num; }    // skip this if cid_name is empty
    Set(CALLERID(name)=${cid_name});
cid_num:
    if("${cid_num}" = "") { goto cdr_acc; } // skip this if cid_num is empty
    Set(CALLERID(number)=${cid_num});
cdr_acc:
    if("${cdr_acc}" = "") { goto dial; }    // skip this if cdr_acc is empty
    Set(${ACCOUNTCODE}=${cdr_acc});
dial:
    // AEL2 is not accepting the 4th argument to Dial
    // Dial(${dial_type_res},${dial_timeout},${dial_options},${dial_url});
    Dial(${dial_type_res},${dial_timeout},${dial_options});

    switch (${DIALSTATUS}) {
        case CHANUNAVAIL:
        case CONGESTION:
        case NOANSWER:
        case BUSY:
            if("${voicemail}" != "") {
                Voicemail(${voicemail});
                Hangup;
            }
        default:
            Noop(${DIALSTATUS});
            break;
    }

chanunavail:
}


See Also:

Created by: bjohnson, Last modification: Thu 19 of Apr, 2007 (05:57 UTC) by jason@debian.org
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+