Wait(seconds)This application waits for a specified number of seconds.,一般用在用户接通之后所有的 .conf 文件都可以使用#include 声明包含另一个.conf 文件。
使用宏创建extension[globals]PHONE1=Zap/1PHONE2=SIP/6002[macro-oneline]exten => s,1,Dial(${ARG1},20,t)exten => s,2,Voicemail(u${MACRO_EXTEN})exten => s,3,Hangupexten => s,102,Voicemail(b${MACRO_EXTEN})exten => s,103,Hangup[local]//下面的${PHONE1}和${PHONE2}就是Macro-online中的${ARG1}exten => 6601,1,Macro(oneline, ${PHONE1})exten => 6602,1,Macro(oneline, ${PHONE2})section]label = value[section](+)label2 = value2In this case, the plus sign indicates that the second section (with the same name) is an addition to the first section. The second section can be in another file (by using the #include statement). If the section name referred to before the plus is missing, the configuration fails to load.asterisk的extension有两种方式被启动,一种是主动拨号,另一种是外界打来的电话For some kinds of connections — such incoming calls from an outside telephone line — the user has not dialed an extension. In that case, Asterisk behaves as if the user had dialed a special extension named "s" (for Start). Asterisk looks for an extension "number" s in the definition of the context for that channel for instructions about what it should do to handle the call.Predefined Extension NamesAsterisk uses some extension names for special purposes:∙i : Invalid∙s : Start∙h : Hangup∙∙∙∙ReloadingIf you want to reload the dial plan after changes, without reloading all of Asterisk's config, use the dialplan reload Asterisk CLI command.Either connect to your asterisk process with asterisk -r or rasterisk and type in the command, or send the command directly with:asterisk -rx 'dialplan reload'One big file or several small?With the #include <filename> statement in extensions.conf, other files are included. This way you can setup a system where extensions.conf is the main file, users.conf (SEE IMPORTANT NOTE BELOW) contain your local users, services.conf contain various services, like conferencing. This way, the dial plan may be easier to maintain(通过将不同类型的服务和信息放在不同的文件中,然后在extensions.conf中用#incldude命令将它们包含进来,这样便于管理和维护), depending on the size of your setup. The #include <filename> statement is not the same as the include <context>statement. The #include statement works in all Asterisk configuration files.Including Globals defined in other files; A plus is needed (tested in 1.4.28) to add on to globals defined in extensions.conf [globals](+)EXTRA_VAR => Zap/6X matches any digit from 0-9Z matches any digit from 1-9N matches any digit from 2-9[1237-9] matches any digit or letter in the brackets(in this example, 1,2,3,7,8,9)[a-z] matches any lower case letter (introduced in which Asterisk version?)[A-Z] matches any UPPER case letter (introduced in which Asterisk version?). wildcard, matches one or more characters! wildcard, matches zero or more characters immediately(!能够匹配所有的情况,相当于switch中的default,可以匹配0个或多个的任意字符)_9011. matches any string of at least five characters that starts with 9011,but it does not match the four-character string 9011 itself.(. 至少要匹配一个字符)_9011! matches 9011 too(!可以匹配0个或多个的任意字符)_# matches a single # keypress_7[04-6]可以匹配70,74,75,76这四个数,注意0和4之间无需加空格[context]exten => someexten,priority,application(arg1,arg2,...)exten => someexten,priority,application,arg1|arg2...可以用“|”代替“,”作为间隔的标志general context的作用[general]∙At the top of your extensions.conf file, you configure a few general settings in the section headed [general]. For details, see:o Dialplan General Settings[globals]∙Next, in the [globals] section, you may define global variables (or constants) and their initial values. For details, see:o Dialplan Global Variables∙Using Variables in Asterisk DialplansoAsterisk Dialplan Generalextensions.conf General Settings Section[general]Here you define a few general options regarding the Dialplan.static: At this stage, this option affects only the operation of the "dialplan save"(Asterisk 1.6) or "save dialplan"(Asterisk 1.4) command. The default value is no, but the sample extensions.conf installed with Asterisk explicitly sets static=yes.writeprotect: If writeprotect=no and static=yes, then you may save the current dialplancategory remain unchanged.) The default value is no but the sample extensions.conf installed with Asterisk explicitly sets writeprotect=no and static=yes."save dialplan" will overwrite your existing extensions.conf with a new one generated from the current dialplan. A copy of your old extensions.conf will not be kept. All comments in your extensions.conf will be lost.autofallthrough: New in 1.2. From the sample extensions.conf: "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)."clearglobalvars: New in 1.2. From the sample extensions.conf: "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 if its included files, will remain set to the previous value."priorityjumping: New in 1.2. From the sample extensions.conf: "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." (There is currently no documentation detailing what the preferred way of reading return codes is. If you know and/or have time to read the source, please post details here!)Example[general]static=yeswriteprotect=yesautofallthrough=yesclearglobalvars=nopriorityjumping=no可以下载虚拟拨号方案软件进行练习If you are not so familiar with Asterisk dialplan syntax, dialplan priorities, or you simply do not prefer coding using text editors, you may find Visual Dialplan for Asterisk useful tool for your dialplan development. Visual Dialplan for Asterisk is modern rapid application development platform for Asterisk dialplan development, it provides similar interface and approach like Visual Basic provides for rapid application development and comes with real world dialplan examples (extensions.conf files that can be used without visual dialplan) .Dial()的用法The Dial() application takes four parameters:exten => 6003,1,Dial(SIP/demo-alice&SIP/demo-bob,30)1. Devices∙ A list of the device(s) you want to call. Devices are specified as technology or channel driver, a forward slash, and the device or account name. Forexample, SIP/demo-alice would use the SIP channel driver to call the devicespecified in the demo-alice section of sip.conf. Devices using the IAX2channel driver take the form of IAX2/demo-george, and DAHDI channelstake the form of DAHDI/1.∙When calling through a device (such as a gateway) or service provider to reach another number, the syntax is technology/device/number suchas SIP/my_provider/5551212 or DAHDI/4/5551212.(如果是借助于一个其它工具如网关来打通一个电话,那dial的第一个参数的组成就应该为“技术/工具/号码”的形式)∙To dial multiple devices at once, simply concatenate the devices together whith the ampersand character (&). The first device to answer will get bridgedwith the caller, and the other endpoints will stop ringing.(使用&可以一下子连接多个号,第一个接通的号将会与呼叫者通话,其它所有的号同时将停止振铃)2. Timeout∙The number of seconds to allow the device(s) to ring before giving up and moving on to the next priority in the extension.3. Options∙There are dozens of options that you can set on the outbound call, including call screening, distinctive ringing and more. Type core show applicationdial at the Asterisk CLI for a complete list of all available options. If you wantto specify multiple options, simply concatenate them together. For example, ifyou want to use both the *m*and H options, you would set mH as the optionsparameter.4. URL∙The fourth parameter is a URL that will be sent to the endpoint. Few endpoints do anything with the URL, but there are a few (softphones mostly) that do acton the URL.。