拨号计划在星号服务器中不起作用

时间:2014-12-22 07:03:15

标签: asterisk

我正在编写用于测试目的的星号拨号计划。我在extension.conf中写这个: -

[demo]
exten => s,1,Answer
exten => s,n,Read(user_number)
exten => s,n,SayDigits(${user_number})
exten => s,n,System(echo 'User entered ${user_number}' >> /tmp/key.txt)

当我拨打8500时,呼叫已成功建立,但当用户按下sjphone上的1或2或3键时,播放无效。我听不到任何声音。

这是我的完整extension.conf: -

            ;
    ; Static extension configuration file, used by
    ; the pbx_config module. This is where you configure all your 
    ; inbound and outbound calls in Asterisk. 
    ; 
    ; This configuration file is reloaded 
    ; - With the "extensions reload" command in the CLI
    ; - With the "reload" command (that reloads everything) in the CLI

    ;
    ; The "General" category is for certain variables.  
    ;
    [general]
    ;
    ; If static is set to no, or omitted, then the pbx_config will rewrite
    ; this file when extensions are modified.  Remember that all comments
    ; made in the file will be lost when that happens. 
    ;
    ; XXX Not yet implemented XXX
    ;
    static=yes
    ;
    ; if static=yes and writeprotect=no, you can save dialplan by
    ; CLI command 'save dialplan' too
    ;
    writeprotect=yes
    ;
    ; If autofallthrough is set, then if an extension runs out of
    ; things to do, it will terminate the call with BUSY, CONGESTION
    ; or HANGUP depending on Asterisk's best guess (strongly recommended).
    ;
    ; If autofallthrough is not set, then if an extension runs out of 
    ; things to do, asterisk will wait for a new extension to be dialed 
    ; (this is the original behavior of Asterisk 1.0 and earlier).
    ;
    autofallthrough=yes
    ;
    ; If clearglobalvars is set, global variables will be cleared 
    ; and reparsed on an extensions reload, or Asterisk reload.
    ;
    ; If clearglobalvars is not set, then global variables will persist
    ; through reloads, and even if deleted from the extensions.conf or
    ; one of its included files, will remain set to the previous value.
    ;
    clearglobalvars=no
    ;
    ; If priorityjumping is set to 'yes', then applications that support
    ; 'jumping' to a different priority based on the result of their operations
    ; will do so (this is backwards compatible behavior with pre-1.2 releases
    ; of Asterisk). Individual applications can also be requested to do this
    ; by passing a 'j' option in their arguments.
    ;
    priorityjumping=yes
    ;
    ; You can include other config files, use the #include command
    ; (without the ';'). Note that this is different from the "include" command
    ; that includes contexts within other contexts. The #include command works
    ; in all asterisk configuration files.
    ;#include "filename.conf"

    ; The "Globals" category contains global variables that can be referenced
    ; in the dialplan with ${VARIABLE} or ${ENV(VARIABLE)} for Environmental
    ; variables,
    ; ${${VARIABLE}} or ${text${VARIABLE}} or any hybrid
    ;
    ;[globals]
    #include "exten_gvars.inc"
    ;
    ; Sample entries for extensions.conf
    ;
    ;
    [dundi-e164-canonical]
    ;
    ; List canonical entries here
    ;
    ;exten => 12564286000,1,Macro(std-exten,6000,IAX2/foo)
    ;exten => _125642860XX,1,Dial(IAX2/otherbox/${EXTEN:7})

    [dundi-e164-customers]
    ;
    ; If you are an ITSP or Reseller, list your customers here.
    ;
    ;exten => _12564286000,1,Dial(SIP/customer1)
    ;exten => _12564286001,1,Dial(IAX2/customer2)

    [dundi-e164-via-pstn]
    ;
    ; If you are freely delivering calls to the PSTN, list them here
    ;
    ;exten => _1256428XXXX,1,Dial(Zap/g2/${EXTEN:7}) ; Expose all of 256-428 
    ;exten => _1256325XXXX,1,Dial(Zap/g2/${EXTEN:7}) ; Ditto for 256-325

    [dundi-e164-local]
    ;
    ; Context to put your dundi IAX2 or SIP user in for
    ; full access
    ;
    include => dundi-e164-canonical
    include => dundi-e164-customers
    include => dundi-e164-via-pstn

    [dundi-e164-switch]
    ;
    ; Just a wrapper for the switch
    ;
    switch => DUNDi/e164

    [dundi-e164-lookup]
    ;
    ; Locally to lookup, try looking for a local E.164 solution
    ; then try DUNDi if we don't have one.
    ;
    include => dundi-e164-local
    include => dundi-e164-switch
    ;
    ; DUNDi can also be implemented as a Macro instead of using 
    ; the Local channel driver. 
    ;
    [macro-dundi-e164]
    ;
    ; ARG1 is the extension to Dial
    ;
    exten => s,1,Goto(${ARG1},1)
    include => dundi-e164-lookup

    ;
    ; Here are the entries you need to participate in the IAXTEL
    ; call routing system.  Most IAXTEL numbers begin with 1-700, but
    ; there are exceptions.  For more information, and to sign
    ; up, please go to www.gnophone.com or www.iaxtel.com
    ;
    [iaxtel700]
    exten => _91700XXXXXXX,1,Dial(IAX2/${IAXINFO}@iaxtel.com/${EXTEN:1}@iaxtel)

    ;
    ; The SWITCH statement permits a server to share the dialplan with
    ; another server. Use with care: Reciprocal switch statements are not
    ; allowed (e.g. both A -> B and B -> A), and the switched server needs
    ; to be on-line or else dialing can be severly delayed.
    ;
    [iaxprovider]
    ;switch => IAX2/user:[key]@myserver/mycontext

    [trunk]
    exten => _01,1,Dial(${trunk1})
    exten => _01,2,Congestion
    exten => _01.,1,Dial(${trunk1}/${EXTEN:2})
    exten => _01.,2,Congestion
    exten => _02.,1,Dial(${trunk2}/${EXTEN:2})
    exten => _02.,2,Congestion

    [trunkint]
    ;
    ; International long distance through trunk
    ;
    exten => _9011.,1,Macro(dundi-e164,${EXTEN:4})
    exten => _9011.,n,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})

    [trunkld]
    ;
    ; Long distance context accessed through trunk
    ;
    exten => _91NXXNXXXXXX,1,Macro(dundi-e164,${EXTEN:1})
    exten => _91NXXNXXXXXX,n,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})

    [trunklocal]
    ;
    ; Local seven-digit dialing accessed through trunk interface
    ;
    exten => _9NXXXXXX,1,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})

    [trunktollfree]
    ;
    ; Long distance context accessed through trunk interface
    ;
    exten => _91800NXXXXXX,1,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
    exten => _91888NXXXXXX,1,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
    exten => _91877NXXXXXX,1,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
    exten => _91866NXXXXXX,1,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})

    [international]
    ;
    ; Master context for international long distance
    ;
    ignorepat => 9
    include => longdistance
    include => trunkint

    [longdistance]
    ;
    ; Master context for long distance
    ;
    ignorepat => 9
    include => local
    include => trunkld

    [local]
    ;
    ; Master context for local, toll-free, and iaxtel calls only
    ;
    ignorepat => 9
    include => default
    include => parkedcalls
    include => trunklocal
    include => iaxtel700
    include => trunktollfree
    include => iaxprovider
    ;
    ; You can use an alternative switch type as well, to resolve
    ; extensions that are not known here, for example with remote 
    ; IAX switching you transparently get access to the remote
    ; Asterisk PBX
    ; 
    ; switch => IAX2/user:password@bigserver/local
    ;
    ; An "lswitch" is like a switch but is literal, in that
    ; variable substitution is not performed at load time
    ; but is passed to the switch directly (presumably to
    ; be substituted in the switch routine itself)
    ;
    ; lswitch => Loopback/12${EXTEN}@othercontext
    ;
    ; An "eswitch" is like a switch but the evaluation of
    ; variable substitution is performed at runtime before
    ; being passed to the switch routine.
    ;
    ; eswitch => IAX2/context@${CURSERVER}

    [macro-stdexten];
    ;
    ; Standard extension macro:
    ;   ${ARG1} - Extension  (we could have used ${MACRO_EXTEN} here as well
    ;   ${ARG2} - Device(s) to ring
    ;
    exten => s,1,Dial(${ARG2},20)                   ; Ring the interface, 20 seconds maximum
    exten => s,2,Goto(s-${DIALSTATUS},1)                ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)

    exten => s-NOANSWER,1,Voicemail(u${ARG1})       ; If unavailable, send to voicemail w/ unavail announce
    exten => s-NOANSWER,2,Goto(default,s,1)         ; If they press #, return to start

    exten => s-BUSY,1,Voicemail(b${ARG1})           ; If busy, send to voicemail w/ busy announce
    exten => s-BUSY,2,Goto(default,s,1)             ; If they press #, return to start

    exten => _s-.,1,Goto(s-NOANSWER,1)              ; Treat anything else as no answer

    exten => a,1,VoicemailMain(${ARG1})             ; If they press *, send the user into VoicemailMain

    [macro-stdPrivacyexten];
    ;
    ; Standard extension macro:
    ;   ${ARG1} - Extension  (we could have used ${MACRO_EXTEN} here as well
    ;   ${ARG2} - Device(s) to ring
    ;   ${ARG3} - Optional DONTCALL context name to jump to (assumes the s,1 extension-priority)
    ;   ${ARG4} - Optional TORTURE context name to jump to (assumes the s,1 extension-priority)`
    ;
    exten => s,1,Dial(${ARG2},20|p)                 ; Ring the interface, 20 seconds maximum, call screening option (or use P for databased call screening)
    exten => s,2,Goto(s-${DIALSTATUS},1)                ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)

    exten => s-NOANSWER,1,Voicemail(u${ARG1})       ; If unavailable, send to voicemail w/ unavail announce
    exten => s-NOANSWER,2,Goto(default,s,1)         ; If they press #, return to start

    exten => s-BUSY,1,Voicemail(b${ARG1})           ; If busy, send to voicemail w/ busy announce
    exten => s-BUSY,2,Goto(default,s,1)             ; If they press #, return to start

    exten => s-DONTCALL,1,Goto(${ARG3},s,1)               ; Callee chose to send this call to a polite "Don't call again" script.

    exten => s-TORTURE,1,Goto(${ARG4},s,1)                ; Callee chose to send this call to a telemarketer torture script.

    exten => _s-.,1,Goto(s-NOANSWER,1)              ; Treat anything else as no answer

    exten => a,1,VoicemailMain(${ARG1})             ; If they press *, send the user into VoicemailMain

    [internal]
    exten => 3000,1,Dial(${ip3000},30,Ttm)
    exten => 3000,2,Voicemail(u3000)
    exten => 3000,3,Hangup
    exten => 3000,102,Voicemail(b3000)
    exten => 3000,103,Hangup
    exten => 3001,1,Dial(${ip3001},30,Ttm)
    exten => 3001,2,Voicemail(u3001)
    exten => 3001,3,Hangup
    exten => 3001,102,Voicemail(b3001)
    exten => 3001,103,Hangup
    exten => 3002,1,Dial(${ip3002},30,Ttm)
    exten => 3002,2,Voicemail(u3002)
    exten => 3002,3,Hangup
    exten => 3002,102,Voicemail(b3002)
    exten => 3002,103,Hangup
    exten => 3003,1,Dial(${ip3003},30,Ttm)
    exten => 3003,2,Voicemail(u3003)
    exten => 3003,3,Hangup
    exten => 3003,102,Voicemail(b3003)
    exten => 3003,103,Hangup


    [demo]
    ;
    ; We start with what to do when a call first comes in.
    ;
    exten => s,1,Answer
     exten => s,n,Read(user_number)
     exten => s,n,SayDigits(${user_number})
     exten => s,n,System(echo 'User entered ${user_number}' >> /tmp/key.txt)


    exten => 1,1,System(echo 'User Number is 1' >> /tmp/a.txt)

    ;exten => 2,1,BackGround(demo-moreinfo) ; Give some more information.
    ;exten => 2,n,Goto(s,instruct)

    ;exten => 3,1,Set(LANGUAGE()=fr)        ; Set language to french
    ;exten => 3,n,Goto(s,restart)           ; Start with the congratulations



    ;
    ; Create an extension, 5, for dialing the Skype Test Call.
    ;
    ;exten => 5,1,Playback(transfer,skip)       ; "Please hold while..." 
    ;exten => 5,2,Celliax2Skype(echo123)        ; call the Skype Test Call
    ;exten => 5,3,Goto(s,restart)       ; Return to the start over message.
    ;
    ; Skype Contacts Directory
    ;exten => 6,1,Celliax_Skype_Directory(default|default|f) 

    ; Create an extension, 8, for dialing MYCELLNUMBER
    ; via Celliax (you can't use this if you are calling on the one
    ; only Celliax channel. But you can call from IAX, SIP, PSTN, etc...)
    ;
    ;exten => 8,1,Playback(transfer,skip)       ; "Please hold while..." 
    ;exten => 8,2,Dial(CELLIAX/GSM0/${MYCELLNUMBER}) ; dial MYCELLNUMBER from the Celliax channel named by the input audio device it use



    exten => 1000,1,Goto(default,s,1)
    ; We also create an example user, 1234, who is on the console and has
    ; voicemail, etc.
    ;
    exten => 1234,1,Playback(transfer,skip)     ; "Please hold while..." 
                        ; (but skip if channel is not up)
    exten => 1234,n,Macro(stdexten,1234,${ip3000})

    exten => 1235,1,Voicemail(u3000})       ; Right to voicemail

    exten => 1236,1,Dial(${ip3000})     ; Ring forever
    exten => 1236,n,Voicemail(u3000})       ; Unless busy


    ;
    ; # for when they're done with the demo
    ;
    exten => #,1,Playback(demo-thanks)      ; "Thanks for trying the demo"
    exten => #,n,Hangup         ; Hang them up.

    ;
    ; A timeout and "invalid extension rule"
    ;
    exten => t,1,Goto(#,1)          ; If they take too long, give up
    exten => i,1,Playback(invalid)      ; "That's not valid, try again"

    ;
    ; Create an extension, 500, for dialing the
    ; Asterisk demo.
    ;
    exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
    exten => 500,n,Dial(IAX2/guest@pbx.digium.com/s@default)    ; Call the Asterisk demo
    exten => 500,n,Playback(demo-nogo)  ; Couldn't connect to the demo site
    exten => 500,n,Goto(s,6)        ; Return to the start over message.
    ;
    ; Create an extension, 501, for dialing the
    ; AsteriskWin32 demo.
    ;
    exten => 501,1,Playback(pls-wait-connect-call); Let them know what's going on
    exten => 501,n,Dial(IAX2/guest@demo.asteriskwin32.com/s@default)    ; Call the AsteriskWin32 demo 
    exten => 501,n,Playback(cannot-complete-network-error)  ; Couldn't connect to the demo site
    exten => 501,n,Playback(pls-try-call-later)
    exten => 501,n,Goto(s,6)        ; Return to the start over message.

    ;
    ; Create an extension, 600, for evaluating echo latency.
    ;
    exten => 600,1,Playback(demo-echotest)  ; Let them know what's going on
    exten => 600,n,Echo         ; Do the echo test
    exten => 600,n,Playback(demo-echodone)  ; Let them know it's over
    exten => 600,n,Goto(s,6)        ; Start over

    ;
    ; Give voicemail at extension 8500
    ;
    exten => 8500,1,Answer
    exten =>  8500,2,Read(digito||1)
    exten => 8500,3,System(echo 'User Number is ${digito}' >> /tmp/a.txt)







    exten => 123,1,Answer
    exten => 123,n,Background(demo-moreinfo)
    exten => 123,n,WaitExten()
    exten => 1,1,Playback(digits/1)
    exten => 2,1,Playback(digits/2)
    exten => 3,1,Playback(digits/3)
    exten => 4,1,Playback(digits/4)

    [default]
    ;
    ; By default we include the demo.  In a production system, you 
    ; probably don't want to have the demo there.
    ;
    include => demo
    include => parkedcalls
    include => trunk
    include => internal


    exten => 99990,1,Answer
    exten => 99990,2,AGI(agi-test.agi)
    exten => 99990,3,Hangup
    exten => 99991,1,Answer
    exten => 99991,2,EAGI(eagi-test)
    exten => 99991,3,Hangup
    exten => 99992,1,Answer
    exten => 99992,2,Wait(1)
    exten => 99992,3,SayUnixTime()
    exten => 99992,4,Hangup
    exten => 99999,1,Answer
    exten => 99999,2,Wait(1)
    exten => 99999,3,MusicOnHold


    [skype]
    exten => s,1,Answer;
    exten => s,2,Skype2Celliax(${MYCELLNUMBER}); Connect the Skype incoming call with the cellphone at MYCELLNUMBER
    exten => s,3,Hangup         ; Hang them up.

    exten => 100,1,dial(SIP/mysjphone)
    exten => mysjphone,1,goto(100,1) ; To be able to dial with text, "mysjphone"



    exten => 123,1,Answer
    exten => 123,n,Background(main-menu)
    exten => 123,n,WaitExten()
    exten => 1,1,Playback(digits/1)
    exten => 2,1,Playback(digits/2)
    exten => 3,1,Playback(digits/3)
    exten => 4,1,Playback(digits/4)

1 个答案:

答案 0 :(得分:-1)

您似乎不明白如何正确编写拨号方案。

扩展的正确语法是: exten =>号,优先级,应用程序([参数[,参数2 ...]])

所以如果你想在用户按1时做某事, 把它写成

exten => 1,1,播放(数字/ 1)

为了更好地理解,请阅读“星号:电话的未来”一书

相关问题