[Asterisk-bsd] dial plan

Tim St. Pierre tim at communicatefreely.net
Mon Apr 16 11:07:27 MST 2007


I have one or two that I might contribute.

I use a lot of macros to make my system do what I want.  Currently, I'm using CDR user fields for a price-per-minute flag to rate the calls later.

This is a macro I use to handle incoming calls based on DID number.  It can optionally add a tag to the caller ID to identify the what line the caller is coming in on (ie. to separate companies, home vs. business numbers, etc)

[macro-did] ; ARGS - accountcode,rate,Gotocontext,gotoexten
exten => s,1,Set(CDR(accountcode)=${ARG1})
exten => s,2,SetAMAFlags(BILLING)
exten => s,3,SetCDRUserField(${ARG2})
exten => s,4,Set(__INRATE=${ARG2})
exten => s,5,GotoIf($[${LEN(${CALLERID(name)})} > 0]?7:6)
exten => s,6,Set(CALLERID(name)=${CALLERID(num)})
exten => s,7,Goto(${ARG3},${ARG4}|1)

[macro-did-label] ; ARGS - accountcode,rate,Gotocontext,Gotoexten,label
exten => s,1,Set(CDR(accountcode)=${ARG1})
exten => s,2,SetAMAFlags(BILLING)
exten => s,3,SetCDRUserfield(${ARG2})
exten => s,4,Set(__INRATE=${ARG2})
exten => s,5,GotoIf($[${LEN(${CALLERID(name)})} > 0]?7:6)
exten => s,6,Set(CALLERID(name)=${CALLERID(num)})
exten => s,7,Set(CALLERID(name)=${ARG5}${CALLERID(name)})
exten => s,8,Goto(${ARG3},${ARG4}|1)

It then uses Goto() to send the call where it needs to go (all set by arguments)

This allows for a single line entry into a DID list.

The next group is used for a two line extension entry.
Depending on the macro you call, it affects whether or not the cellphone is rung simultaneously, 
or only if the phone is unreachable.  If you make a database entry 
(CELLNUMBER "extension number" "cellphone number")
the calls can be forwarded out to a cell phone from voice mail if the caller presses #
Pressing * during the outgoing messages lets them check voicemail.

[macro-stdexten] ;ARG1 is operator context ARG2 is ring timeout
exten => s,1,Dial(SIP/${MACRO_EXTEN}/${MACRO_EXTEN}|${ARG2}|w)
exten => s,n,Goto(10)
include => macro-cellfail
exten => a,1,VoicemailMain(${MACRO_EXTEN})                      ; If they press *, send the user into VoicemailMain

[macro-stdexten-cell] ;ARG1 is operator context ARG2 is ring timeout
exten => s,1,Dial(SIP/${MACRO_EXTEN}/${MACRO_EXTEN}&SIP/${MACRO_EXTEN}-cell/${MACRO_EXTEN}-cell|${ARG2}|w)
exten => s,n,Goto(10)
include => macro-cellfail
exten => a,1,VoicemailMain(${MACRO_EXTEN})                      ; If they press *, send the user into VoicemailMain

[macro-stdexten-cell-alt] ;ARG1 is operator context ARG2 is ring timeout
exten => s,1,Dial(SIP/${MACRO_EXTEN}/${MACRO_EXTEN}&SIP/${MACRO_EXTEN}-cell/${MACRO_EXTEN}-cell&SIP/${MACRO_EXTEN}-alt/${MACRO_EXTEN}-alt|${ARG2}|w)
exten => s,n,Goto(10)
include => macro-cellfail
exten => a,1,VoicemailMain(${MACRO_EXTEN})                      ; If they press *, send the user into VoicemailMain

[macro-stdexten-home];sends to cell, alt, and local @home context for alternate phones
exten => s,1,Set(_CID=${CALLERID(name)})
exten => s,2,Set(CALLERID(name)=${ARG3}:${CID})
exten => s,n,Dial(SIP/${MACRO_EXTEN}/${MACRO_EXTEN}&SIP/${MACRO_EXTEN}-cell/${MACRO_EXTEN}-cell&SIP/${MACRO_EXTEN}-alt/${MACRO_EXTEN}-alt&Local/${MACRO_EX$
exten => s,n,Goto(10)
include => macro-cellfail
exten => a,1,VoicemailMain(${MACRO_EXTEN})                      ; If they press *, send the user into VoicemailMain

[macro-stdexten-simulcell] ;ARG1 is operator context ARG2 is ring timeout
exten => s,1,GotoIf($[${LEN(${CALLERID(num)})} > 9]?4:2)
exten => s,2,Set(__PSTNCALLERID=9999999${CALLERID(num)})
exten => s,3,Goto(s|5)
exten => s,4,Set(__PSTNCALLERID=${CALLERID(num)})
exten => s,5,Dial(SIP/${MACRO_EXTEN}/${MACRO_EXTEN}&SIP/${MACRO_EXTEN}-alt/${MACRO_EXTEN-alt}&Local/${DB(CELLNUMBER/${MACRO_EXTEN})}@forward/n|${ARG2}|tw)
exten => s,6,Goto(s-${DIALSTATUS},1)
exten => s-NOANSWER,1,Voicemail(${MACRO_EXTEN}|su)
exten => s-NOANSWER,2,Hangup
exten => s-CHANUNAVAIL,1,Voicemail(${MACRO_EXTEN}|su)
exten => s-CHANUNAVAIL,2,Hangup
exten => s-BUSY,1,Voicemail(${MACRO_EXTEN}|sb)
exten => s-BUSY,2,Hangup
exten => a,1,VoicemailMain(${MACRO_EXTEN})
exten => o,1,Goto(${ARG1}|0|1)


[macro-stdexten-sequenced] ;ARG3 is outgoing CID, ARG1 is operator context ARG2 is ring timeout
exten => s,1,Dial(SIP/${MACRO_EXTEN}/${MACRO_EXTEN}&SIP/${MACRO_EXTEN}-alt/${MACRO_EXTEN-alt}|${ARG2})
exten => s,2,GotoIf($[${LEN(${CALLERID(num)})} > 9]?5:3)
exten => s,3,Set(__PSTNCALLERID=${ARG2})
exten => s,4,Goto(s|6)
exten => s,5,Set(__PSTNCALLERID=${CALLERID(num)})
exten => s,6,Dial(Local/${DB(CELLNUMBER/${MACRO_EXTEN})}@forward/n||t)
exten => s,7,Goto(${ARG1}|0|1)

[macro-voicemail]
exten => s,1,Goto(10)
include => macro-cellfail

[macro-cellfail]
exten => s,10,Goto(s-${DIALSTATUS},1)
exten => s-NOANSWER,1,Voicemail(${MACRO_EXTEN}|su)
exten => s-NOANSWER,2,Gotoif(DB_EXISTS(CELLNUMBER/${MACRO_EXTEN})?3:5)
exten => s-NOANSWER,3,Dial(Local/${DB(CELLNUMBER/${MACRO_EXTEN})}@forward/n|20|t)
exten => s-NOANSWER,4,Voicemail(${MACRO_EXTEN}|sb)
exten => s-NOANSWER,5,Hangup
exten => s-CHANUNAVAIL,1,Gotoif(DB_EXISTS(CELLNUMBER/${MACRO_EXTEN})?2:3)
exten => s-CHANUNAVAIL,2,Dial(Local/${DB(CELLNUMBER/${MACRO_EXTEN})}@forward/n|20|t)
exten => s-CHANUNAVAIL,3,Voicemail(${MACRO_EXTEN}|su)
exten => s-CHANUNAVAIL,4,Hangup
exten => s-BUSY,1,Voicemail(${MACRO_EXTEN}|sb)
exten => s-BUSY,2,Hangup
exten => _s-.,1,Goto(s-NOANSWER,1)                              ; Treat anything else as no answer
exten => a,1,VoicemailMain(${MACRO_EXTEN})                      ; If they press *, send the user into VoicemailMain
exten => o,1,Goto(${ARG1}|0|1)
exten => t,1,Playback(ss-noservice)
exten => t,2,Congestion

I hope this is useful.

If it's too messy, or if you need clarification, e-mail me and I'll send direct text attachments to whomever.

-Tim


On Saturday 14 April 2007 15:00, Richard Neese wrote:
> ok I am working on a full featured dial plan and need functions. If any of
> you have some good dial plan functions you want to contrib send my way. the
> idea is to get a full working dialp plan into asterisk and the gui. Please
> donate what you can.
> _______________________________________________
> Asterisk-BSD mailing list
> Asterisk-BSD at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-bsd

-- 
Tim St. Pierre

IP telephony specialist
sip://5101@communicatefreely.net
Toronto: 647 722 6930
Toll-Free 1 888 488 6940
tim at communicatefreely.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-bsd/attachments/20070416/114af92d/attachment-0001.pgp


More information about the Asterisk-BSD mailing list