[asterisk-users] Dial an extension to modify dialplan

Stefan Becker becker at yukonho.de
Tue May 9 07:21:06 CDT 2017


I think this is a better solution:

I've created a simular solution for our main incoming line.  Extentions 
can add/remove themselfs from
the distrubuting extention.

I used the DATABASE functions of Asterisk to accomplish this following.

my example:
first create a few Database/Keys in the Asterisk CLI to express which 
phones may use this feature
and how the extention will actually be dialed. Like I have two phones on 
differant hardware that
BOTH act as "169" and both get called by "169" but need special 
intrustions to be dialed.

In Asterisk CLI

> DATABASE put zentrale 111 0: SIP/111a&SIP/111b
> DATABASE put zentrale 115 0:SIP/114&SIP/115
> DATABASE put zentrale 118 0:SIP/118
> DATABASE put zentrale 298 1:DAHDI/r1/298
> DATABASE put zentrale 168 1:SIP/168&DAHDI/r1/169

add these lines to

  exten => s,1,Set(OPER=${DB_KEYS(zentrale)})
  exten => s,n,Set(DailOut=)
  exten => s,n,While($["${SET(XXX=${SHIFT(OPER)})}"!=""])
  exten => s,n,GotoIf($["${DB(zentrale/${XXX}):0:2}"!="1:"]?skp)
  exten => s,n,Set(DailOut=${DailOut}&${DB(zentrale/${XXX}):2})
  exten => s,n(skp),EndWhile
  exten => s,n,Set(DailOut=${DailOut:1})
  exten => s,n,Set(DB(zentrale/ist)=${DailOut})

;incoming call for "0" --> Operator
  exten = 0,1,GotoIfTime(07:45-17:05,mon-fri,*,*?inhours)
  same =  n,Dial(${DB(zentrale/ist)},10,txk)
  same =  n,GoTo(SIP-Phones,300,1)
  same =  n(inhours),Dial(${DB(zentrale/ist)},10,txk)
  same =  n,SIPAddHeader(Alert-Info:\;info=abwurf)
  same =  n,Dial(SIP/297&${DB(zentrale/ist)},30,txk)
  same =  n,GoTo(SIP-Phones,300,1)
  same =  n,HangUp()

  exten = 300,1,Answer()
   same =  n,Wait(1)
   same =  n,VoiceMail(300)
   same =  n,HangUp()

exten = 301,1,Set(OPER=${DB_KEYS(zentrale)})
  same =     n,Answer()
  same =     n,PlayBack(/etc/asterisk/wav/301-zentrale)
  same =     n,PlayBack(/etc/asterisk/wav/500-nbstl)
  same =     n,While($["${SET(XX=${SHIFT(OPER)})}"!=""])
  same =     n,GotoIf($["${DB(zentrale/${XX}):0:2}"!="1:"]?skp)
;same =     n,SayNumber(${XX})
  same =     n,SayPhonetic(${XX})
  same =     n,Wait(1)
  same =     n(skp),EndWhile
  same =     n,Wait(1)
  same =     n,PlayBack(vm-goodbye)
  same =     n,HangUp()

exten = 302,1,Answer()
  same =     n,Set(CDR(accountcode)=${CALLERID(number):-3})
  same = 
  same = 
  same = 
  same =     n,macro(SetZentrale)
  same =   n,PlayBack(beep)
  same =   n,PlayBack(beep)
  same =   n,PlayBack(/etc/asterisk/wav/500-nbstl)
;same =   n,SayNumber(${CALLERID(number)})
  same =   n,SayPhonetic(${CALLERID(number)})
  same =   n,PlayBack(/etc/asterisk/wav/302-hinzu)
  same =     n,Goto(bye)
  same = 
  same =     n,macro(SetZentrale)
  same =   n,PlayBack(beep)
  same =   n,PlayBack(/etc/asterisk/wav/500-nbstl)
;same =   n,SayNumber(${CALLERID(number)})
  same =   n,SayPhonetic(${CALLERID(number)})
  same =   n,PlayBack(/etc/asterisk/wav/302-hinab)
  same =     n(bye),Wait(1)
  same =     n,PlayBack(vm-goodbye)
  same =     n,HangUp()


Incoming calls to "0"  -->  Dial all phones listed via "302"
  --->  Dial(${DB(zentrale/ist)})

"300" - VoiceMail-Box
"301" - "reads off" the list of phones registered via "302"

"302" - if extention not registered, adds calling extention (database 
entry must exist) to Dial-List
            DATABASE entry "zentrale/ist" is created or modified by this 
"302" - if extention registered, removes calling extention from Dial-List 

I hope this may interest and help you along ....

my best regards,

Stefan Becker

On Mon, May 8, 2017 at 4:35 PM, Frank Vanoni <mailinglist at linuxista.com> 
>I have the following scenario:
>exten => 2000,1,Dial(SIP/deviceA&SIP/deviceB&SIP/deviceC)
>As expected, by dialing 2000, all three devices will ring. And that's
>However, there are situations where I only want "deviceA" and "deviceB"
>to ring. I would like to have an extension to dial in order to modify
>the dialplan.

More information about the asterisk-users mailing list