[Asterisk-Dev] Comedian Mail features

Ryan Tucker rtucker at netacc.net
Fri Jul 25 10:57:24 MST 2003


On Thu, 24 Jul 2003 15:56:56 -0400, Alex Lopez <alex at opsys.com> wrote:
>> I was thinking of using a database to keep track of things.  Perhaps
> even
>> base extension handling altogether out of the database.
>
> I haven't had a chance to play with that yet, how hard was it the
> configure??? Can you share some examples??

We don't have anything *too* useful yet, but someone a couple weeks back 
posted their call forwarding, etc, extensions.conf entries, which we're 
basing things off of.

Here's our [macro-stdexten]:

[macro-stdexten]
;
; Standard extension macro:
;   ${ARG1} - Device to ring
;   ${ARG2} - Context
;   ${ARG3} - Extension
;
exten => s/_XXXX,1,SetCallerID()   ; 4 digits == no caller ID.  blank it.
exten => s,1,LookupCIDName         ; maybe we have a name
exten => s,2,SetAccount(${ARG2})   ; set the account code
; do they have privacy guard?  if so, do it.  if not...
exten => s,3,DBget(foo=FEAT/${MACRO_EXTEN}/PRIVMGR)
exten => s,4,PrivacyManager        ; they do!
exten => s,104,Goto(s|5)           ; they don't!
exten => s,105,Hangup              ; they failed privacy guard
; do they have call-forward-unconditional?
exten => s,5,DBget(fwdexten=FEAT/${MACRO_EXTEN}/CFWD/CFU)  ; they do!
exten => s,6,DBget(fwdcontext=FEAT/${MACRO_EXTEN}/CFWD/CFUC)  ; grab 
context
exten => s,7,Goto(${fwdcontext}|9${fwdexten}|1)        ; call it
exten => s,106,Goto(s|10)          ; they don't
exten => s,107,Goto(s|10)
; try ringing them
exten => s,10,Dial(${ARG1}|20|r)   ; timeout 20s, give ringback
; no answer?
exten => s,11,DBget(fwdexten=FEAT/${MACRO_EXTEN}/CFWD/CFNA)  ; call- 
forward-na
exten => s,12,DBget(fwdcontext=FEAT/${MACRO_EXTEN}/CFWD/CFNAC)
exten => s,13,Goto(${fwdcontext}|9${fwdexten}|1)         ; go there
exten => s,112,Goto(s|15)     ; no call forward
exten => s,113,Goto(s|15)
; no answer vm greeting
exten => s,15,Answer
exten => s,16,VoiceMail2(su${ARG3}@${ARG2})
exten => s,17,Hangup
; busy?
exten => s,111,Goto(s|211)    ; to avoid conflicts
exten => s,211,DBget(fwdexten=FEAT/${MACRO_EXTEN}/CFWD/CFB)  ; call- 
forward-busy
exten => s,212,DBget(fwdcontext=FEAT/${MACRO_EXTEN}/CFWD/CFBC)
exten => s,213,Goto(${fwdcontext}|9${fwdexten}|1)
exten => s,312,Goto(s|20)    ; no call forward
exten => s,313,Goto(s|20)
; busy vm greeting
exten => s,20,Answer
exten => s,21,VoiceMail2(sb${ARG3}@${ARG2})
exten => s,22,Hangup

The DBget() application does the main retrieval from the internal database. 
 If the value is there, it goes to +1; otherwise, +101.  Quite handy.

Putting stuff in there and removing it is pretty simple, too:

exten => _1121X.,1,Answer
exten => _1121X.,2,ChanIsAvail(Local/9${EXTEN:4}@${CONTEXT})
exten => _1121X.,103,Playback(invalid)
exten => _1121X.,104,Hangup
exten => _1121X.,3,DBput(FEAT/${CALLERIDNUM}/CFWD/CFU=${EXTEN:4})
exten => _1121X.,4,DBput(FEAT/${CALLERIDNUM}/CFWD/CFUC=${CONTEXT})
exten => _1121X.,5,Playback(${SOUNDS}/loligo/call-fwd-unconditional)
exten => _1121X.,6,Playback(${SOUNDS}/loligo/has-been-set-to)
exten => _1121X.,7,SayDigits(${EXTEN:4})
exten => _1121X.,8,Hangup
exten => 1121,1,Answer
exten => 1121,2,DBdel(FEAT/${CALLERIDNUM}/CFWD/CFU)
exten => 1121,3,DBdel(FEAT/${CALLERIDNUM}/CFWD/CFUC)
exten => 1121,4,Playback(${SOUNDS}/loligo/call-fwd-unconditional)
exten => 1121,5,Playback(${SOUNDS}/loligo/has-been-cleared)
exten => 1121,6,Hangup

(See the ChanIsAvail(Local/9${EXTEN:4}@${CONTEXT})?  That's the coolest 
thing since sliced bread, IMHO)

> Editing outside of * may pose a problem. How ever MySql or Postgress
> should not be a big problem, as php exist for both.

Oh, the web side is no problem.  It's the phone side I'm worried about... 
e.g. what'll happen if the database backend wanders off to Tahoe for a 
little bit.  :-)

(We don't usually use PHP; C, Python, and ASP seem to win out usually, 
depending on the purpose and the platform.  Purely web-based stuff 
occasionally ends up in PHP, but that's rare enough that it's merely done 
as practice.)

> I was planning on putting the whole Dial string ie SIP/999 or ZAP/999,
> or  IAX/blah:blah at 10.1.1.1...., or even ZAP/g2/18005551212 in the
> database.  If I was doing this in shell, I would do something like this:
>
> Where 123 is the argument:
>
> Grep "$1" /etc/asterisk/extensions.list
>
> It returns:
> 123:SIP/9999
>
> I store that in a Variable call DIALARG
>
> Then I would
>
> Exten => 123,1,Dial(${DIALARG})
>
> Simple......

*nod*... it'd probably end up being something like that.  Significantly 
more complex for over here, though; here's a standard extension, for 
instance:

exten => 5854199895,1,Macro(stdexten|SIP/netacc-9895|netacc|9895)

And that's not even getting into the outbound context for that phone being 
rochnyint.  :-)

I'm pondering making it so that everything lives in the billing system; 
that'd be funner than a barrel of monkeys.  Our billing system is able to 
do various useful things on creation/deletion/modification of an object.  
Hmmm.  Let me see if I can get my boss to start twitching... -rt

-- 
Ryan Tucker
Network Engineer
NetAccess, Inc.
1159 Pittsford-Victor Road
Bldg. 5, Suite 140
Pittsford, New York 14534
585-419-8200
www.netacc.net



More information about the asterisk-dev mailing list