1

I have a very basic extensions.conf with the following context:

[LocalPhones]

exten => 1001,1,noop(Dialing ${PEX_ONE})
        same => n,Macro(DialStartMonitor,${PEX_ONE})
        same => n,Dial(SIP/${PEX_ONE},30,mTt)
        same => n,Playback(vm-nobodyavail)      ; Play "no one's available"
        same => n,Hangup()

exten => 1002,1,noop(Dialing ${PEX_TWO})
        same => n,Macro(DialStartMonitor,${PEX_TWO})
        same => n,Dial(SIP/${PEX_TWO},30,mTt)
        same => n,Playback(vm-nobodyavail)      ; Play "no one's available"
        same => n,Hangup()

exten => 1003,1,noop(Dialing ${PEX_THREE})
        same => n,Macro(DialStartMonitor,${PEX_THREE})
        same => n,Dial(SIP/${PEX_THREE},30,mTt)
        same => n,Playback(vm-nobodyavail)      ; Play "no one's available"
        same => n,Hangup()

exten => 1004,1,Dial(Dialing ${PEX_FOUR})
        same => n,Macro(DialStartMonitor,${PEX_FOUR})
        same => n,Dial(SIP/${PEX_FOUR},10,m)
        same => n,Playback(vm-nobodyavail)      ; Play "no one's available"
        same => n,Hangup()

exten => 1005,1,Dial(Dialing ${PEX_FIVE})
        same => n,Macro(DialStartMonitor,${PEX_FIVE})
        same => n,Dial(SIP/${PEX_FIVE},10,m)
        same => n,Playback(vm-nobodyavail)      ; Play "no one's available"
        same => n,Hangup()

Is there a way I can combine all these into a single block (instead of 5 blocks like it is now) so that the extensions can dial each other (the extensions are from 1001 to 1010)?

rahuL
  • 3,330
  • 11
  • 54
  • 79

2 Answers2

5

Correct value-placement dialplan for asterisk is like this

exten => 1000,1,Set(trunk=${PEX_ONE})
exten => 1002,1,Set(trunk=${PEX_TWO})
exten => 1003,1,Set(trunk=${PEX_THREE})
exten => 1004,1,Set(trunk=${PEX_PHONE})
exten => 1005,1,Set(trunk=${PEX_FIVE})
; this will be executed after any of above
; note,it start from 2 prio(1 is from set above)
exten => _100[1-5],2,Noop(Dialing ${trunk})
           same => n,Macro(DialStartMonitor,${trunk})
           same => n,Dial(SIP/${trunk},10,m)
           same => n,Playback(vm-nobodyavail)      ; Play "no one's available"
           same => n,Hangup()

Note, your dialplan is still bad, becuase it play vm-nobodyavail even if user busy or communication was ok, but hanguped called user.

For correct dialplan like that you need analyze DIALSTATUS variable, check extensions.conf.sample for dialplan like that or read dialplan of freepbx.org software.

arheops
  • 15,544
  • 1
  • 21
  • 27
  • Thank you, that worked. And thank you for pointing out the DIALSTATUS variable. I will definitely check it out :) Thank you for your help – rahuL Jan 12 '14 at 10:21
0

I think it will be something like bellow:

exten => _100[12345],1,Set(DIALTO=${PEX_ONE})
        same => n,GotoIf($["${EXTEN:-1}" = "1"]?process)
        same => n,Set(DIALTO=${PEX_TWO})
        same => n,GotoIf($["${EXTEN:-1}" = "2"]?process)
        same => n,Set(DIALTO=${PEX_THREE})
        same => n,GotoIf($["${EXTEN:-1}" = "3"]?process)
        same => n,Set(DIALTO=${PEX_FOUR})
        same => n,GotoIf($["${EXTEN:-1}" = "4"]?process)
        same => n,Set(DIALTO=${PEX_FIVE})
        same => n(process),Macro(DialStartMonitor,${DIALTO})
        same => n,Dial(SIP/${DIALTO},30,mTt)
        same => n,Playback(vm-nobodyavail)      ; Play "no one's available"
        same => n,Hangup()
arheops
  • 15,544
  • 1
  • 21
  • 27
user3131703
  • 101
  • 3