17.3. Asterisk Dial-PlanAll calls placed to, from, and through the Asterisk PBX are handled on logical voice pathways. A pathway may consist of a single hard line, like an analog telephone line interfaced with Asterisk via an X100P card, or there may be hundreds of pathways sharing a single physical connection, like a bunch of SIP phones connected to the Asterisk server via an Ethernet interface. In any scenario, the pathways are called channels , and the Asterisk PBX's purpose is to handle their voice traffic according to a set of rules known as a dial-plan . The effect the dial-plan has on a call is called a call flow . Many conventional PBX systems use dial-plans to deal only with calls that can be placed and answered when a human is present and require an offboard voice mail server with an auto-attendant to answer calls when nobody's in the office. But the Asterisk PBX uses dial-plan for a much larger purpose: complete call processing for both scenarios. The Asterisk dial-plan includes rules that specify what to do when:
The dial-plan is the command center of the Asterisk system. Almost every dial-plan function you can access requires a visit to the dial-plan's main configuration file: extensions.conf . This file defines all of the possible call destinations (extensions), which may include users' telephones, hold queues, voice mailboxes, or call processors.
In Asterisk, extensions aren't defined as physical PBX telephones in the traditional sense, but as what-to-do scenarios that are referenced by numbers. Put another way, each extension answers the question, "What should the PBX do when this extension number is invoked?" The answer isn't always to ring a phonenot all extension numbers are actually related to phones as they tend to be on a traditional PBX. Indeed, on Asterisk, some extensions may be related to voice mailboxes or custom call processors. Extension number 501 might ring a phone, but extension number 105 might play a voice mail announcement and then record the caller's message. The numbersphone numbersprovide legacy compatibility so that Asterisk extensions can be used with the old 12-key dial-pad on legacy phones. This conforms to the conventions of the ITU's numbering standard, E.164. But, as VoIP becomes more prevalent , you'll discover that Asterisk can be used with alphanumeric addresses, which are common with SIP. When the extension asks "What should the PBX do when this extension is invoked," the answer comes in the form of an Asterisk application commanda task-specific call-handling function. There are many application commands for different tasks , and each answers that question with its own functionality. Here's a (very) partial list:
17.3.1. VariablesAsterisk's extensions.conf and voicemail.conf files can use variables in a manner similar to shell scripts. Variables can be contained within a particular voice channel or be made "global," available to all contexts of the dial-plan. (More on contexts later.) Variables are referenced using curly brackets ( { and } ) around the variable name , preceded by a dollar sign ( $ ). Here's an example of a variable called announceBox being assigned, then recalled: exten => 1,1,SetGlobalVar(announceBox=15) exten => 1,2,NoOp(${announceBox}) 17.3.1.1 Built-in variablesAsterisk has a number of built-in variables to handle specific tasks. They behave like functions: ${DATETIME} provides a reference to the current system time, while ${ CALLERID } provides caller ID information. Built-in variables are almost always channel-specificthat is, they don't have much meaning outside the scope of a particular call. The PBX can behave differently depending on the time of day, the caller's identification, and even the channel used to handle a call. The more you use configuration settings, commands, and variables with Asterisk's configuration files, the more the syntax of the configuration files will make sense. For now, let's talk about the place where commands and variables are most often employed: the dial-plan. 17.3.1.2 The layout of extensions.confThere are three section categories in the extensions.conf file, each headed by a square-bracketed ( [ and ] ) string that contains each section's name. The first section category, called [general] , allows you to change two settings static and writeprotect . Neither of these settings has much consequence in learning Asterisk, so you can ignore both of them or even leave them out of the file altogether for now. The second section category, called [ globals ] , is for defining global variables, which are administrator-assignable values that can be recalled throughout the dial-plan. A good example would be assigning a vague channel name ( Zap/1 ) to a meaningful variable ( TELEPHONECOMP ), like this: [globals] TELEPHONECOMP => Zap/1 You could also use the globals section to store a list of hard-to-remember channel names for a group of SIP or analog phones: [globals] CAFEPHONE => SIP/105@oreilly.com:5060 OFFICEPHONE => SIP/106@oreilly.com:5060 CORDLESSPHONE => Zap/2 Notice how the structure of a channel name variesa Zaptel legacy channel has a very simple name structure ( Zap/2 ), but a SIP channel has a complex name structure ( SIP/106@oreilly.com:5060 ). SIP has a URI naming, while legacy channels have no such convenience. Asterisk therefore names legacy POTS and PRI channels by referencing their hardware interfaces ( Zap/1 , Zap/2 , and so forth).
The variables assigned in the globals section don't actually cause Asterisk to do anything. They merely store information that can be used elsewhere in the dial-plan. 17.3.1.3 ContextsThe third section of extensions.conf consists of multiple sections known as contexts. While there can only be one general and one globals section in extensions.conf , there can be many context sections. In fact, there can be as many contexts as you like. But, just what is a context? With a cutomizable softPBX like Asterisk, you have the ability to set up limitless dial-plan scenarios. So, you may still have day and night modes, but you may also have lunchtime mode, happy hour mode, etc., depending on your users' needs. Asterisk refers to these modes of operation contexts . Contexts organize related extension numbers in the dial-plan so that they create call flows that are explicitly defined for any combination of:
For example, an initial catchall greeting might say, "Press 1 for Marketing, 2 for Sales, and 3 for Service." Let's say the user presses 1. He may then hear another greeting that says, "Press 1 for the Head of Marketing, 2 for the Secretary of Marketing, or 3 for the Ad Buyer." So, in one context, option 1 is for the Marketing Department, but in a subsequent context, option 1 is for the head of marketing. Contexts give you, the administrator, programmatic control over call flows, but they also give you access control abilities at the application layer. Here's the configuration of three contexts to re-create the call flow described in Figure 17-1: [default] ; (main context) exten => s,Playback(main-greeting) exten => s,2,WaitExten( ) exten => 1,1,Goto(Sales,1) exten => 2,1,Goto(Marketing,1) [Sales] exten => s,1,Playback(sales-dept-greeting) exten => s,2,WaitExten( ) exten => 1,1,Goto(NewCustomers,1) exten => 2,1,Goto(ReturningCustomers,1) [Marketing] exten => s,1,Playback(marketing-dept-greeting) exten => s,2,WaitExten( ) exten => 1,Dial(${headOfMarketing}) exten => 2,Dial(${secyOfMarketing}) Figure 17-1. Contexts define extensions that are localized and grouped logicallySo, extensions 1 and 2 are actually defined several places in the dial-plan, but they have different meaning in different contexts. In the main context, extension 2 transfers the caller to the Marketing Department, but in the Sales context, extension 2 transfers the call to the secretary of marketing's phone. 17.3.1.4 Including contextsIn the Asterisk dial-plan configuration, it is possible to include one context within another, so that all of the extensions defined in a context are inherited by the context that includes it. Suppose you have this context: [voipco] include => sales exten => 102,1,Dial(${TEDSPHONE}) exten => 103,1,Dial(${KELLYSPHONE}) exten => 104,1,Dial(${MADDIESPHONE}) Note the include directive just below the section heading voipco that names this context. The include directive causes this context to implicitly inherit all of the directives of the sales context. So, from the voipco context, I can dial extensions 1 or 2 from the sales context in the previous example.
17.3.1.5 The syntax of extensionsNotice the exten directives that begin each extension definition in the prior examples. In order to establish an extension in extensions.conf , you'll need this directive. The second half, the definition, contains three elements, separated by commas: exten => extension number , priority , application command The first element of the definition is the extension numbergenerally, this means that a caller or a process has requested the extension by dialing it into their telephone set, or by signaling it during a call transfer. The second element is the priority, or the order in which the third element, the application command, is executed. Consider the following: [sales-after-hours] exten => 110,1,Answer exten => 110,2,Playback(sales-greeting) exten => 110,3,Voicemail(110) exten => 110,4,Hangup Even though there are four lines of configuration, this is actually just a single extension (110) that makes use of several application commands. In the order defined by the priorities, extension 110 is answered by Asterisk, a sound file called sales-greeting is played to the caller, a voice mail message is recorded, and then the channel is hung up. In this way, the question, "What should the PBX do when someone dials 110?" is answered. Besides user-defined extensions, Asterisk has a very important built-in extension, called the start extension , or simply S . This is the de facto extension for calls not associated with any other extensionlike calls coming in to the Asterisk PBX from a single-line X100P interface. Using the start extension in place of the extension number in a definition tells Asterisk how to handle these calls: [incoming] exten => s,1,Dial(SIP/105) exten => s,2,VoiceMail(105) In this case, all unqualified calls are sent first to SIP phone 105 and, if that fails, to voice mailbox 105. 17.3.1.6 Extension pattern matchingNot all extensions are defined as static strings; some are defined as pattern-matched strings. If you're familiar with regexp or some other pattern-matching concept, this idea is nothing new. Consider the following: 914403651964 914403652642 Two different strings of digits, right? Not always. When the following pattern mask is applied, the second string and the first string are both the same extension definition, even though they are actually different phone numbers. Take a look at the pattern that makes these two numbers become a single extension definition: _91440XXXXXXX Like all Asterisk pattern masks, this one begins with the underscore character. It's purpose is to match any 12-digit phone number beginning with 91440 . When this pattern mask is used in the dial-plan, it causes all numbers that match its pattern to be treated as though they are all the same extension. The following extension definition matches all numbers dialed that begin with 91 and connects them to the public telephone company using the Zaptel channel provided by the X100P card, assuming the variable ${TELCO} contains the name of the Zaptel channel: exten => _91.,1,Dial(${TELCO}/${EXTEN}) exten => _91.,2,Congestion( ) The first priority of this extension is to use the Dial( ) application command to connect the caller's channel to the telephone company's line at the phone number contained in ${EXTEN} , a variable which always contains the most-recently dialed sequence of digits on the current channel. If this priority fails, the caller will hear a busy tone, as indicated by the Congestion( ) application command. The wildcard characters that are used to match patterns consist of:
Matched patterns can be any length. You might wonder why you would need extremely long patterns, but if you're using IVR applications, you may be collecting long data entries like credit card numbers (16 digits or more). While you can use other techniques to collect this data, extensions.conf is the only place where you can use powerful pattern matching for extensions. So routing calls based on credit card numbers, social security numbers and so on, is easy to do here. Pattern matching can be applied to both human-dialed and machine-signaled strings.
With the flexibility of Asterisk's application commands, variables, priorities, and contexts, there are nearly infinite ways of combining contexts and extension definitions in the dial-plan. 17.3.1.7 Special extensionsSpecial extensions are alphabetic characters that have a logical meaning in the dial-plan. They are used to describe scenarios in which an extension number doesn't exist, as when a call first enters the context from the outside world.
17.3.2. String Processing in the Dial-PlanSince the dial-plan defines call flows, it infers programmatic logic. So, when you set up a dial-plan, you're really programming the PBX. For that reason, Asterisk includes some syntactic capabilities that make your life as a PBX programmer simpler. One of the most important of these capabilities is string processing. In most dial-plan commands, arguments are supplied as textual expressions. They may contain a mixture of literal values and variables. These expressions may be used in whole or in partthrough Asterisk's extensive chopping capabilities. Consider the following: exten => 1,1,SetVar(wholename=DestinysEnd) exten => 1,2,SetVar(firstword=${wholename:1:8}) In this example, ${wholename} is assigned the value DestinysEnd . Then, in the next priority, ${firstword} is assigned the value of the first eight characters of ${wholename} . The syntax for string chopping and substringing is as follows : ${substring} = ${string: offset : length } If the offset is less than 0, then it will be an offset from the end of the string, not the beginning. If length isn't supplied, the remainder of the string, from the offset on, will be included in the yielded substring. The following two examples produce identical results: exten => 1,1,SetVar(wholename=DestinysEnd) exten => 1,2,SetVar(lastword=${wholename:9}) exten => 2,1,SetVar(wholename=DestinysEnd) exten => 2,1,SetVar(lastword=${wholename:-1:4}) In either extension 1 or 2, ${lastword} is End . 17.3.2.1 Getting string lengthsThe ${LEN} function measures the length of strings. Use it with SetVar to assign the length of an expression to a variable: exten => 1,1,DBGet(creditCard=${CALLERIDNUM}/creditcard) exten => 1,2,SetVar(length=${LEN(${creditCard})}) exten => 1,3,GotoIf(${length}!=16?100:200) exten => 1,100,Playback(thank-you) exten => 1,101,Hangup( ) exten => 1,200,Playback(invalid-credit-card-number) exten => 1,201,Goto(default,1,1) In this example, a credit card number is pulled from the Asterisk database. If its length is 16, the system plays a thank you message. Otherwise, it plays an invalid message and changes contexts. 17.3.2.2 Concatenating stringsAs in Perl and PHP quoted string expressions, multiple strings can be concatenated simply by putting them inline: exten => 1,1,SetVar(wholename=DestinysEnd) exten => 1,2,SetVar(firstword=${wholename:1:8}) exten => 1,3,SetCIDName("Gilneas ${firstword}") ; Caller ID Name is now "Gilneas Destiny" exten => 1,4,SetCIDName("Gilneas${firstword}") ; Caller ID Name is now "GilneasDestiny" 17.3.3. Dial-Plan Command ReferenceEach extension you define in the dial-plan can have one of many commands. These commands are, as pointed out earlier, executed in order of their priority. Some of the commands are dependent upon one another. Here is a list of the most commonly used commands. 17.3.3.1 AbsoluteTimeoutAbsoluteTimeout( seconds ) Sets absolute maximum time of call, in seconds. Once this time elapses, the call will be disconnected or handled by the t special extension, if one is defined in extensions.conf . Could be useful for calling card applications. 17.3.3.2 AddQueueMemberAddQueueMember( queue [ channel ]) Adds the current channel as a member to a call queue as configured in /etc/asterisk/queues.conf . If channel is specified, uses that channel instead of the current one. 17.3.3.3 ADSIProg ADSIProg( script ) Programs an ADSI (Analog Display Services Interface) script into an ADSI-capable phone. ADSI is a standard developed by the telecom industry for creating text-based interactive applications that augment traditional calling services. 17.3.3.4 AGIAGI( program arguments ) Executes an Asterisk Gateway Interface program on the current channel. See "The Asterisk Gateway Interface," later in the chapter, for more information on AGI. 17.3.3.5 AnswerAnswer( ) Answers the incoming call on the current channel. Should be followed up with other commands or the calling party will just hear silence. 17.3.3.6 AppendCDRUserField AppendCDRUserField( value ) Appends the specified string value to the Call Detail Record user field.
17.3.3.7 BackGround BackGround( filename ) Plays the specified GSM format sound file on the current channel and ends, giving control of the context to the next priority, if any, or goes back to the s extension if not. This can be used for IVR prompts like "Dial 1 for sales, 2 for support," and so on. If these numbers are valid within the context, then the context will handle them appropriately. 17.3.3.8 BackgroundDetect BackgroundDetect( filename ) Plays a sound file on the current channel while waiting for the caller to dial some digits or speak. Upon speaking, the user will be transferred to the special talk extension if it exists. 17.3.3.9 BusyBusy( ) Plays a busy signal on the current channel and waits for the caller/callee to disconnect. 17.3.3.10 ChangeMonitor ChangeMonitor( filename ) Changes the filename to which the audio dump of the current channel is being or will be sent, when used with Monitor . 17.3.3.11 ChanIsAvail ChanIsAvail( channel ) Checks to see if the specified channel is available, and store its name in ${AVAILCHAN} . Generally , this is used with the Cut command to reformat the channel name for use later in the dial-plan. ; Check if line 3 is available. If not, try line 2, then line 1. exten => s,1,ChanIsAvail(Zap/3&Zap/2&Zap/1) ; ${AVAILCHAN} may now contain the value: Zap/2-1 ; Strip off the session ID, putting just the channel number in ${MyChannel} exten => s,2,Cut(MyChannel=AVAILCHAN,,1) ; ${MyChannel} would now contain the value: Zap/2 ; Dial the intended number on this channel, which we'll assume is in ${PSTTNumber} exten => s,3,Dial(${MyChannel}/${PSTNNumber}) exten => s,4,Hangup ; If neither line is available, play a busy message. exten => s,102,Playback(all-circuits-busy-now) exten => s,103,Hangup 17.3.3.12 CheckGroup CheckGroup( count ) Determines whether the current channel's channel group is handling more than count calls. If so, redirects current call to priority equal to the current priority plus 101. 17.3.3.13 CongestionCongestion( ) Plays a congestion message to the caller/callee and waits for disconnect. 17.3.3.14 ControlPlaybackControlPlayback( filename , skip , forward , rewind , stop , pause ) Plays the specified sound file, giving fast forward, rewinds and exit controls to the user on the current channel. Dialed digits are used to control playback. The arguments are the name of the GSM sound file, the number of milliseconds to use as an interval for rewinding and forwarding, and the dial-pad digits (including # and * ) that will be used to control the playback. Control of the call proceeds to the next priority when the end of the sound file is reached. exten => 2112,1,ControlPlayback(syrinx-song.gsm,4000,*,#,1,0) 17.3.3.15 CutCut( expression , delimiter , fieldspec ) Function that splits delimited strings. Could be used to split area codes from phone numbers. ; OldString is 'A&B&C&D' exten => s,1,Cut(NewString=OldString,&,2) ; NewString is 'B' 17.3.3.16 DBdelDBdel( keytree / key ) Drops the named key from the Asterisk database. 17.3.3.17 DBdeltree DBdeltree( keytree ) Drops a key tree from the Asterisk database. 17.3.3.18 DBgetDBget( varname = keytree / key ) Gets a value from the Asterisk database. The following example gets a customer who is calling in to enter some digits and then uses those digits to look up the extension of that customer's service agent in the Asterisk database. Then, it transfers the call to that extension. [ServiceIVR] exten => s,1,Answer( ) exten => s,2,Background(enter-your-8-digit-account-number.gsm) exten => _NXXXXXXX,1,dbget(repExten=${EXTEN}/rep) exten => _NXXXXXXX,2,Goto(${repExten}) 17.3.3.19 DBputDbput( keytree / key = value ) Sets a value in the Asterisk database. value can be a variable or a string literal. 17.3.3.20 DeadAGI DeadAGI( program ) Runs an AGI program on a channel after the call has ended. 17.3.3.21 DialDial( channel / identifier [, timeout ][, options ][, url ]) Makes an outbound call on the specified channel and bridges it with the current channel. Dial is one of the most capable, and most frequently used commands in Asterisk. Here are its arguments:
17.3.3.22 DigitTimeoutDigitTimeout( seconds ) Sets the maximum time out, in seconds, allowed between dialed digits on the current channel only. 17.3.3.23 DirectoryDirectory( ) Presents the user on the current channel with an IVR directory of voice mailboxes. 17.3.3.24 DISADISA, password context Gives the user direct inward system access capability, or the ability to obtain dial-tone and the ability to originate calls from the current channel in the specified context. User must enter a password using the dial-pad that matches the specified password. 17.3.3.25 EchoEcho( ) Immediately plays back the incoming audio signal back on the same channel it's coming from. Used to give testers an idea of how significant echo is on any given connection. Users can exit to the next priority by pressing the pound key ( # ). 17.3.3.26 EnumLookup EnumLookup( extension ) Looks up the specified extension number in ENUM and returns the SIP or TEL URI to the variable called ENUM. If a SIP entry exists, the next priority will be reached. If a TEL entry exists, the next priority plus 50 will be reached. If no entry is found, the next priority plus 100 will be reached. This example least-cost-routes all calls that start with a 9 to SIP via ENUM first before routing them to the PSTN. ; Any calls starting with 9 will undergo ENUM lookup. exten=> _9[1-9]XXX.,1,BackGround(enum-doing) exten=> _9[1-9]XXX.,2,EnumLookup(431${EXTEN:1}) ; ${EXTEN:1} is the dialed number with the leading 9 removed. ;EnumLookupsets ${ENUM} on success. On failure jumps to priority+101. exten=> _9[1-9]XXX.,3,BackGround(enum-successful) exten=> _9[1-9]XXX.,4,Dial(${ENUM},30) exten=> _9[1-9]XXX.,5,Goto(104) ; No answer on SIP after 30 seconds, so dial the number on the PSTN exten=> _9[1-9]XXX.,103,BackGround(enum-failed) exten=> _9[1-9]XXX.,104,Dial,${TRUNK}/${EXTEN:1} 17.3.3.27 Festival Festival( speech text ) Says the specified text using the Festival voice synthesizer, if it's installed. The audio is sent to the current channel, and the user has the option of interrupting by dialing digits. exten => 200,1,Answer 17.3.3.28 FlashFlash( ) Sends a flash signal on the current Zaptel channel. Works only on Zaptel channels. Not useful unless the connected trunk has flash signaling features like call-waiting or three-way calling. 17.3.3.29 GetGroupCountGetGroupCount( ) Obtains the number of channels in the group the current channel belongs to and stores it in ${GROUPCOUNT} . 17.3.3.30 GotoGoto([ priority ],[ extension ],[ context ]) Immediately changes the current channel to the specified context, priority, or extension. Goto(101) ; go to priority 101 in current extension Goto(incoming,101) ; go to extension 101 in context 'incoming' Goto(incoming,101,2) ; go to priority 2 in extension 101 in context 'incoming' 17.3.3.31 GotoIfGotoIf( condition ? target1 [: target2 ]) Go to target1 if the condition is true or to target2 if the condition is false. When target1 and target2 are Goto -compatible targets, see "Goto" for target syntax. condition is a string of the same expression syntax used for normal string processing within the dial-plan. This example does some simple ACD when an incoming call dials the 210 extension: ; See if area code is 216 and go to priority 3 or 5, depending. Exten => 210,1,SetGlobalVar(myAreaCode=${CALLERIDNUM}:0:3) exten => 210,2,GotoIf($[${myAreaCode}=216]?3:5) exten => 210,3,Dial(${SPHONE1},15,rt) exten => 210,4,Hangup exten => 210,5,Dial(${PHONE2},15,rt) exten => 210,6,Hangup 17.3.3.32 GotoIfTimeGotoIfTime( timecondition ,[ priority ],[ extension ],[ context ]) Immediately changes the current channel to the specified context, priority, or extension, if the supplied time condition is true. The time condition is provided in the format of time-based context includes, which are described in "Time-based context includes" in Chapter 12. 17.3.3.33 HangupHangup( ) Hangs up the current channel, ending the call, but going to the next priority for this extension, if one exists. 17.3.3.34 LookupBlacklistLookupBlacklist( ) If there's a caller ID for the caller on the current channel, looks up her name and number in the Asterisk database key tree called blacklist . If it exists, the command changes the priority to the next priority plus 100. 17.3.3.35 MailboxExist MailboxExist( mailbox ) Checks to see if the specified voice mailbox exists. Useful for intercepting misdialed numbers. 17.3.3.36 MathMath( result , operation ) Performs a simple mathematical operation and assigns its value to the variable named by result . Here are some examples: exten => 1,1,Math(var,3*2) ; multiplication exten => 1,2,Math(var,10-2) ; subtraction exten => 1,3,Math(var,${EXTEN}>1000) ; greater-than exten => 1,4,Math(var,${EXTEN}>=1000) ; greater-than or equal-to
17.3.3.37 MeetMeMeetMe( confno [ options ][ password ]) Creates an Asterisk conference bridge. Requires Zaptel hardware to be installed, even if all bridge participants aren't on Zaptel channels. This is because the Zaptel hardware provides the conference mixing and timing functions needed for multiparty bridging. The configuration file /etc/meetme.conf is used to configure the Asterisk conference mixer. (Users without Zaptel hardware may consider compiling the ztdummy timing module instead.) options may be:
17.3.3.38 MeetMeAdminMeetMeAdmin( conference , command [, user ]) Issues conference administration commands to Asterisk conferences. The options are as follows:
17.3.3.39 MeetMeCountMeetMeCount( conference ,[ variable ]) Plays back the conference participant count on the current channel. If a variable is specified, records the count in that variable and skips playing back the count. 17.3.3.40 MilliwattMillwatt( ) Generates a 1,000 Hz signal at 0 dBm on the current channel. This tone can be used by a lineman to measure transmissions on a phone line from a remote site, such as a residence or office for which the Asterisk server provides an FXO port. 17.3.3.41 MonitorMonitor( format , name [,M]) Records the telephone conversation from the current channel to a sound file or caller and callee parts of the conversation to separate sound files. format is the desired sound file format. The default is wav . name is the base name of the output file(s), and the M flag can be added if you want SoxMix to automatically mix the two parts of the conversation into a single file upon termination of the call. The Sox package must be compiled and installed in order for this to work. 17.3.3.42 MP3Player MP3Player( filename ) Plays an MP3 sound file on the current channel. Playback can be stopped and the priority incremented by dialing any digit. 17.3.3.43 MusicOnHold MusicOnHold( class ) Plays hold music indefinitely from the specified class . Music-on-hold classes are established with simple directives in /etc/asterisk/musiconhold.conf . Normally these directives just point a certain class to a certain directory that contains MP3 files, but as this example shows, you can also use a streaming source: ; musiconhold.conf default => mp3:/var/lib/asterisk/onhold,http://www.streamvoip.us/royalty-free:8000 The config needs a blank directory called onhold in /var/lib/asterisk using: # mkdir /var/lib/asterisk/onhold 17.3.3.44 NoCDRNoCDR( ) Insures Asterisk will not save any CDR data for the current call. 17.3.3.45 NoOp NoOp( value ) Echos values to the console for debugging purposes. 17.3.3.46 ParkedCall ParkedCall( extension ) Answers the parked call at the specified parked call extension. 17.3.3.47 Playback Playback( filename ) Answers the call on the current channel and plays the specified sound file. 17.3.3.48 Playtones Playtones( tone ) Play a tone from among those specified in /etc/asterisk/ indications .conf while executing other commands. Tone will continue to play indefinitely until StopPlaytones is called. Can also accept a tone list that consists of frequencies and durations, rather than a simple tone name. The tone list must be in the format specified in tones.conf . 17.3.3.49 PrivacyManagerPrivacyManager( ) Requires a phone number to be entered on incoming calls when no caller ID signals are received. If the user doesn't enter the phone number, the priority advances to next plus 100. Currently supports only 10-digit phone numbers. Configured by /etc/asterisk/privacy.conf . 17.3.3.50 QueueQueue( queue options ) Puts the current call into a call queue specified by queue . options is one or more of the following:
The hold queue configuration is stored in /etc/asterisk/queues.conf . Consult its comments for configuration instructions. 17.3.3.51 RandomRandom( likelihood , priority ) Goes to a random priority based on the supplied likelihood, which is expressed as a percent. Useful for controlling traffic splitting. 17.3.3.52 ReadRead( variable [ filename ][ maxdigits ]) Reads a string of digits from the user on the current channel, storing them in variable . Optionally, filename , a sound file, can be played prior to receiving the digits. maxdigits indicates the maximum number of digits that you'll allow, which can be no greater than 255. exten => s,1,Answer( ) exten => s,2,Read(credCardNumenter-cred-num16) exten => s,3,Read(credExpDateenter-exp-date4) exten => s,4,Playback(thank-you) exten => s,5,Noop(${credCardNum} ${credExpDate}) 17.3.3.53 ResetCDRResetCDR( ) Resets CDR data for the current call, as if it were beginning now. 17.3.3.54 ResponseTimeout ResponseTimeout( seconds ) Sets maximum timeout awaiting a dialing activity from the user. Default is 15 seconds, after which time the call will be transferred to t or hung up if t doesn't exist. 17.3.3.55 RingingRinging( ) Plays a ringback tone on the current channel. 17.3.3.56 RptRpt( ) Allows ham radio systems and two-way repeaters to be interfaced with Asterisk through special hardware, so that radio calls can be signaled from the PBX. For more information, visit http://zapatatelephony.org/app_rpt.html. 17.3.3.57 SayAlpha SayAlpha( string ) Audibly says the string , one character at a time, on the current channel. Besides letters and number, SayAlpha has sounds for #, *,-,+, !, @, and $. 17.3.3.58 SayDigits SayDigits( string ) Audibly says the string, ignoring any non-numeric characters. 17.3.3.59 SayNumber SayNumber( string ) Uses full-word pronunciation to say the number, from 0 to 99 million. If the string is 405120 , the caller will hear "Four hundred five thousand, one hundred twenty." 17.3.3.60 SayPhonetic SayPhonetic( string ) Says the string using NATO phonetic pronunciation. Recommend using Festival instead for most applications. 17.3.3.61 SayUnixTimeSayUnixTime([ unixtime ], timezone , format ) Says the date and time on the current channel. unixtime is a Unix timestamp, the number of seconds since January 1, 1970. If unixtime is omitted, the current time is used. timezone is a timezone consistent with the configuration of /usr/share/zoneinfo . format is a string that uses the strftime(3) function's convention. For more information, see the manpage for strftime(3) . 17.3.3.62 SendDTMF SendDTMF( digits ) Sends the DTMF digits on the current channel. 17.3.3.63 SendText SendText( text ) Sends a text message to the endpoint on the current channel. Works only with devices that support text messaging, such as SIP clients . 17.3.3.64 SendURL SendURL( url [,wait]) Sends the device on the current channel a web page URL to display, if it can. Devices that don't support HTML transport will result in going to the next priority plus 100. 17.3.3.65 SetAccount SetAccount( account ) Sets the CDR account code to be used for this call. Also, stores the account code in ${ACCOUNTCODE} for further reference within the dial-plan. 17.3.3.66 SetCallerID SetCallerID( newcallerid ) Overrides the existing caller ID string for the current call. SetCallerID is overridden if SIP peer has a fromuser configuration. 17.3.3.67 SetCDRUserField SetCDRUserField( user ) Sets the name of the user to appear in the CDR record for this call. 17.3.3.68 SetCIDName SetCIDName( name ) Sets the caller ID name for originating calls from the current channel, using, for example, the Dial command. 17.3.3.69 SetCIDNum SetCIDNum( number ) Sets the caller ID number for originating calls from the current channel. 17.3.3.70 SetGlobalVarSetGlobalVar( variable = value ) Sets a global dial-plan variable to the value supplied. Value can be another variable's value. Here are some examples: ; set the name of a PSTN trunk to a Zaptel channel name exten => _N*,1,SetGlobalVar(PSTNtrunk=Zap/1) ; store the extension in a variable exten => _N*,2,SetGlobalVar(CallInProgress=${EXTEN}) exten => _N*,3,Noop(${CallInProgress}) 17.3.3.71 SetLanguage SetLanguage( language ) Changes localization setting for sound playback of digits, characters, and fully pronounced numbers. 17.3.3.72 SetMusicOnHold SetMusicOnHold( class ) Sets default hold music class for the current channel. 17.3.3.73 SetVarSetVar( variable = value ) Sets a local variable (local to this call) to the value supplied. 17.3.3.74 SIPdtmfMode SIPdtmfMode( option ) Changes DTMF mode during a SIP call in progress on the current channel. option is one of these three: info , inband , or rfc2833 . inband should be used only with G.711. 17.3.3.75 SMS SMS( options ) Sends and receives SMS (short messaging service) messages from within the dial-plan. For more information, see http://www.smsclient.org/. 17.3.3.76 SoftHangup SoftHangup( channel ) Ends the call on the specified channel. To hang up the current channel, use Hangup( ) instead. 17.3.3.77 StopMonitorStopMonitor( ) Stops monitoring a channel that is currently being monitored using Monitor( ) . 17.3.3.78 StopPlaytonesStopPlaytones( ) Stops playing a tone list or a tone. Returns audio on the current channel to the call in progress. 17.3.3.79 StripLSD StripLSD( number ) Strips the least-significant digitsi.e., from the right of the current extension. The number of digits to strip is specified by number . So, if extension 5241900 stripped down to 1900 at the first priority, processing would continue at the second priority of extension 1900. 17.3.3.80 StripMSD StripMSD( number ) Strips most significant digitsi.e., from the left of the current extension. The number of digits to strip is specified by number . Continues processing at the next priority in the new extension. So, if extension 5241900 stripped down to 524 at the first priority, processing would continue at the second priority of extension 524. 17.3.3.81 System System( command ) Executes a system command in a shell as the user that runs Asterisk. Can substitute variables within the command line, as in this example, which creates a new directory for every call before recording it into a sound file in that directory using Monitor( ) : exten => s,1,Answer( ) exten => s,2,System('mkdir /var/spool/calls/${exten}') exten => s,3, Monitor( WAV , /var/spool/calls/${exten}/call ,M) 17.3.3.82 Transfer Transfer( extension ) Transfers the call on the current channel to the specified extension. 17.3.3.83 VoiceMailVoiceMail([ options ] box ) Connects the current channel to a local voice mailbox specified by box . options is one or more of the following (or none of them):
17.3.3.84 VoiceMailMain VoiceMailMain( box ) Connects the current call to the generic voice mail subscriber greeting. If box is given, the voice mail server assumes the specified subscriber is trying to log in to retrieve messages or manage her voice mailbox.
17.3.3.85 Wait Wait( seconds ) Waits for the number of seconds specified before proceeding to the next priority. 17.3.3.86 WaitExten WaitExten( duration ) Waits for the number of seconds specified for the user on the current channel to enter a valid extension; otherwise, proceeds to next priority. Also, can accept the duration in decimal numbers for tenths of a second (1.2, 10.5, 0.5, etc.). 17.3.3.87 WaitMusicOnHold WaitMusicOnHold( seconds ) Identical to Wait( ) , but plays the music-on-hold class associated with this call or context while the caller is waiting. 17.3.3.88 ZapatellerZapateller( ) Sends the do-not-call signal to incoming callers. 17.3.3.89 ZapBarge ZapBarge( channel ) Allows caller to clandestinely listen in on another channel's call in progress, as long as it's a Zaptel channel. Neither party in the conversation will know that the call is being monitored by the "barging" caller. If you don't provide a channel name, the caller will be prompted for one. Entering 1# would listen in on Zap/1, while entering 3# would listen in on Zap/3. 17.3.3.90 ZapScanZapScan( ) Scans Zaptel channels to monitor calls. Pressing # moves to the next channel. Pressing the star key ( * ) exits to the next priority. |