extensions.conf – This is your Dialplan.

The configuration file “extensions.conf” contains the “dial plan” of Asterisk, the master plan of control or execution flow for all of its operations. It controls how incoming and outgoing calls are handled and routed. This is where you configure the behavior of all connections through your PBX.

The content of “extensions.conf” is organized in sections, which can be either for static settings and definitions, or for executable dialplan components in which case they are referred to as contexts. The settings sections are general and globals and the names of contexts are entirely defined by the system administrator. A special type of contexts are macros, label by a userdefined name prefixed with macro-. These are reusable execution patterns, like procedures in a programming language. Every section in extensions.conf starts with the name of the section contained within square brackets. This gives the extensions.conf file a similar structure to the traditional .ini file format of the Windows world.

Asterisk Dialplan Planning – General discussion about organizing a dialplan

New in Asterisk v1.2: By default, there is a new option called “autofallthrough” in extensions.conf that is set to yes. Asterisk 1.0 (and earlier) behavior was to wait for an extension to be dialed after there were no more extensions to execute. “autofallthrough” changes this behavior so that the call is terminated immediately with BUSY, CONGESTION, or HANGUP based on Asterisk’s best guess. If you are writing an extension for IVR, you must use the WaitExtenapplication if “autofallthrough” is set to yes.


  • At the top of your extensions.conf file, you configure a few general settings in the section headed [general]. For details, see:


Contexts and Extensions

  • After the [general] and [globals] categories, the remainder of the extensions.conf file is taken up by the definition of the Dialplan. The Dialplan consists of a collection of contexts. Each context consists of a collection of extensions. For an introduction to these topics, see:

Extension Patterns

  • When you define the extensions within a context, you may not only use literal numbers, not only alphanumeric names, but also you may define extensions that match whole sets of dialed numbers by using extension patterns. For more information about this, see:

Context Inclusion

One extension context can include the contents of another. For example, consider the following contexts:

Context “default”:

Extension Description

101 Mark Spencer

102 Wil Meadows

0 Operator

Context “local”:

Extension Description

_9NXXXXXX Local calls

include => “default”

Context “longdistance”:

Extension Description

_91NXXNXXXXXX Long distance calls

include => “local”

Here we have defined three extensions:

  • The context default permits dialing three telephone extensions: Mark, Wil, and the Operator.
  • The context local has one extension pattern to permit dialing 7-digit numbers only (local calls), and also includes the context “default”, thus also permitting a user to dial Mark, Wil, or the Operator.
  • The context long distance has one extension pattern to permit dialing a long-distance call, and it also includes the context “local”, thus permitting the user to make local calls and also to dial the extensions of Mark, Wil or the Operator.

Using extension contexts, you can carefully control who has access to toll services.

If more than one pattern matches a dialed number, Asterisk may not use the one you expect. See Sort Order of Extension Patterns.

Adding to an existing section (I believe this is a 1.4 feature; additional info on similar option are in doc/configuration.txt of asterisk src tree)


label = value


label2 = value2

In 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.

When Asterisk receives an incoming connection on a channel, Asterisk looks at the context defined for that channel for commands telling Asterisk what it should do. The context defines different sets of commands depending on what extension the user has dialed. For example, a context might provide one set of commands for what to do if the user dials “123”, and another set of commands for what to do if the user dials “9”, and another set of commands for what to do if the user dials any number beginning with “555”.

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.

Let’s say, for example, that you have a channel “Zap/1” which is a connection to a telephone handset in your building. And let’s say that in the configuration file for Zap channels (zapata.conf), you have defined context=john for Zap channel 1. So when you use that handset to dial a number, Asterisk looks for a context with the name “john” in extensions.conf to find out what it should do. You begin the definition of a context in extensions.conf by putting the name of the context in square brackets on a line by itself, like this:


For each context, you need to define one or more extensions that Asterisk uses to compare against the number dialed. For each extension, you tell Asterisk what to do by listing a set of commands.


An extension can be one of two types: a literal or a pattern.

literal extension can be a number, like 123, and it can also contain the standard symbols * and # that appear on ordinary telephones, so 12#89* is a valid extension. Some telephone keypads have the special DTMF keys labeled ABC and D, and extensions can be defined with these letters too. In fact, the name of an extension can contain any letter or number as well as some punctuation marks. Note that many VOIP telephones are able to “dial” extension “numbers” that may be any arbitrary text string, such as “Office”. It is perfectly permissible to define an extension with the name Officein Asterisk.

Extension names may or may not be case sensitive. They are case sensitive in the sense that when Asterisk is trying to match the extension a user dialed against the extensions defined for a context, the extension must match, including case. So if a user dials extension “OFFICE” using their VOIP telephone, Asterisk does not start executing the commands you have defined for an extension named “Office”. On the other hand, extension names are not case sensitive in the sense that you can not define different extensions (in the one context) that have the same names differing only in case. So you can’t define one set of commands for extension “Office” and another set of commands for extension “OFFICE”.

Predefined Extension Names

Asterisk uses some extension names for special purposes:

  • i : Invalid
  • s : Start
  • h : Hangup
  • t : Timeout
  • T : AbsoluteTimeout
  • a : Asterisk extension
  • o : Operator

See Asterisk standard extensions for details.

Defining Extensions

Unlike a traditional PBX, where extensions are associated with phones, interfaces, menus, and so on, in Asterisk an extension is defined as a list of commands to execute. The commands are generally executed in the order defined by their “priority” tag, but some commands, such as the Dial and GotoIf commands, have the ability to redirect somewhere else, based on some condition.

When an extension is dialed, the command tagged with a priority of 1 is executed, followed by command priority 2, and so on. This goes on until:

  • the call is hung up,
  • a command returns a result code of -1 (indicating failure),
  • a command with the next higher priority doesn’t exist (note: Asterisk does not “skip over” missing priorities), or
  • the call is routed to a new extension.

In the syntax of the extensions.conf file, each execution step in an extension is written in this format:

exten = extension,priority,Command(parameters)

where the equal sign can also be ornamented as an arrow, i.e., “=>”, a form most often seen in many examples.

Ok, so a “context” has a name, such as “john”. And in each context, you can define one or more “extensions”. For each extension, you define a set of commands. So how do you define these extensions and the commands to handle them? You need to edit the extensions.conf file with a text editor. However, there are some tools available to help: GUI tool.

The components of an extension execution step or command line are the following:

    • extension is the label of the extension, and can be either a literal constant string (alphanumeric plus a few special symols allowed) or a dynamically evaluated pattern (see below) to match many possible phone numbers, for example. Every command line that is part of a given extensions has this same label.
    • priority is usually an integer (see note, however). It’s just a sequence number for each command line of an extension. The first executable command of an extensions has the priority “1”, so when Asterisk transfers a call to an extension, it looks for a command with priority 1. If there is not a line with a priority of 1, then the extension does not match the dialed number. After executing the priority 1 command, Asterisk increments the priority to “2” unless the command itself determines the next priority to be executed. If this next priority is not defined in the extension, Asterisk finishes processing for this extension, even if there exists another command with a priority higher than the missing one.

Note: Strings may also be used in place of priority in special situations (see Asterisk standard extensions).

    • command is the name of the command (also called an “application”) to execute. See the Asterisk Commands List.
  • parameters depend on the command. Some commands take no parameters, in which case you can omit the parentheses.


exten => 123,1,Answer

exten => 123,2,Playback(tt-weasels)

exten => 123,3,Voicemail(44)

exten => 123,4,Hangup

This is the definiton of a single extension with name “123”. When a call is made to extension 123, Asterisk answers the call itself, play a sound file called “tt-weasels”, give the user an opportunity to leave a voicemail message for mailbox 44, and then hangup.

Note that Asterisk doesn’t care about the order in which you put the lines in the extensions.conf file. You could mix the lines into a different order, like this following example, and it would make no difference because Asterisk uses the priority of each line to determine order of execution:

exten => 123,4,Hangup

exten => 123,1,Answer

exten => 123,3,Voicemail(44)

exten => 123,2,Playback(tt-weasels)

Other options for defining extensions include an option commonly referred to as the ex-girlfriend logic. This logic matches the dialed extension irrespective of its origin based on the callerid of the person calling it. For example:

exten => 123/100,1,Answer()

exten => 123/100,2,Playback(tt-weasels)

exten => 123/100,3,Voicemail(123)

exten => 123/100,4,Hangup()

This matches extension 123 and perform the following options ONLY if the Caller-ID Number of the calling user is 100. This can also be accomplished with pattern matching, as seen below:

exten => 1234/_256NXXXXXX,1,Answer()

and so on…

This matches only 1234 if the Caller ID Number is something beginning with 256. This is very useful to keep locals from dialing your toll-free number and charging you for the call.

You can even do this:

exten => s,1,Answer

exten => s/9184238080,2,Set(CALLERID(name)=EVIL BASTARD)

exten => s,2,Set(CALLERID(name)=Good Person)

exten => s,3,Dial(SIP/goodperson)

(thanks for pointing that out, Brian 🙂 )

Basically the call comes in, at 2 you fork the people you don’t like out, everybody else stays in the path and at 3 everybody is back in the main path.

Syntax for defining a context: keywords extenincludeignorepat and switch.

One of the banes of this method of storing the extension information is that if you need to insert or delete a priority, you have to manually renumber all numbers after it and all label referrences to it. I’m working on a utility to do this online: give it a try if you like

Since Asterisk 1.2 there is a new way to work around this. Number the first priority and “name” the following priorities “n”. See Asterisk Prioritiesfor further details!

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 rapid dialplan development tool for Asterisk dialplan development, it provides similar interface and approach like Visual Basic provides for rapid application development for Windows platform (if you are more familiar the Windows environment like I am, although there is Visual Dialplan for Linux too).

You may drag, drop and connect building blocks to make Asterisk dialplan. Then you may configure building blocks to fine tune your dialplan.

Here is the same example above created using Visual Dialplan for Asterisk:

Download above example

Download Visual Dialplan for Asterisk

Variables and expressions

There is support for using variables using the ${VARIABLENAME} construct. You can also use expressions with the $[EXPRESSION] construct, where expressions can be regular expressions, comparision, addition, substraction and much more. See Asterisk variables for standard variables and Asterisk readme.variables for an explanations of expressions.

For more information about using global variables and channel variables in extensions.conf, see

New in 1.2 are dialplan functions, see


If 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, 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.

DO NOT USE users.conf as a filename anymore! This is now a “reserved” filename as of Asterisk 1.4! In general, it is a good idea to divide your extensions.conf file up into subcomponents but put those files in a subdirectory (don’t clutter up /etc/asterisk). For example, have a directory /etc/asterisk/exts and use #include <exts/…>

Sample extensions.conf using the #include statement

#include “my-extra-config-file”


exten => s,1,Answer
exten => s,2,Playback(welcome-message)
exten => s,3,Goto(context-in-include-file,s,1) ; go to context defined in included file

Forwarding to another Asterisk



switch => IAX2/user:[key]@server/context

Specifies forwarding to another server. The user and key needs to be defined in the iax.conf file of the server which is called. The context is a context in the called servers extensions.conf.

Controlling extensions.conf from outside

Macro Examples

Using a macro to create extensions


exten => s,1,Dial(${ARG1},20,t)
exten => s,2,Voicemail(u${MACRO_EXTEN})
exten => s,3,Hangup
exten => s,102,Voicemail(b${MACRO_EXTEN})
exten => s,103,Hangup

exten => 6601,1,Macro(oneline,${PHONE1})
exten => 6602,1,Macro(oneline,${PHONE2})

Sip header manipulation examples

These examples may be beneficial when interfacing Asterisk with a Nortel SST or an Acme Packet SBC.

Sending RFC-3323 compliant privacy headers in sip calls


exten => _9.,1,SIPAddHeader(P-Asserted-Identity: <sip:+1${CALLERID(num)}\;user=phone>)

exten => _9.,n,SIPAddHeader(Privacy: user\; header\; session)

exten => _9.,n.SetCallerPres(prohib_not_screened) ; this might not be needed — needs further testing

exten => _9.,n,Set(CALLERID(num)=)

exten => _9.,n,Set(CALLERID(name)=Anonymous)

exten => _9.,n,Dial(SIP/+${EXTEN:1}@sipcarrier)

exten => _9.,n,Hangup()

Sending RFC-3325 compliant privacy headers in sip calls


exten => _9.,1,SIPAddHeader(P-Preferred-Identity: <sip:+1${CALLERID(num)}\;user=phone>)

exten => _9.,n,SIPAddHeader(Privacy: id)

exten => _9.,n.SetCallerPres(prohib_not_screened) ; this might not be needed — needs further testing

exten => _9.,n,Set(CALLERID(num)=)

exten => _9.,n,Set(CALLERID(name)=Anonymous)

exten => _9.,n,Dial(SIP/+${EXTEN:1}@sipcarrier)

exten => _9.,n,Hangup()

Sending Sip Diversion headers (spawned from dialplan as macro) 


exten => s,1,SIPAddHeader(Diversion: <tel:+{ARG1}>\;reason=user=busy\;screen=no\;privacy=off)

Tip: With vim syntax highlighting highlights correct dialplan syntax and may ease dialplan design through these visual aids.

Example files on the net

See also

Intro to Asterisk Dialplan Priorities

Asterisk Priorities are used within a dialplan, in the extensions.conf configuration file..

Priorities are numbered steps in the execution of each command that make up an extension. Each priority represents one specific application. Typically, priority numbers start at 1 and increment consecutively for each line in the context. Priority numbers are not always consecutive, but we will worry about that later. For now, just remember that for each extension, Asterisk runs each priority in numerical order — as opposed to the order in which they appear in the file.


exten => 555,1,Answer

exten => 555,2,Playback(tt-weasels)

exten => 555,3,Voicemail(44)

exten => 555,4,Hangup

This example is a definition of a single extension with the name “555”. When a call is made to extension 555, Asterisk will answer the call itself, play a sound file called “tt-weasels”, give the user an opportunity to leave a voicemail message for mailbox 44, and then hangup.

In the example, “exten =>” tells the dialplan that the next thing it sees will be a command.

“555” are the actual digits received (i.e. what the caller dialed, or the “extension” number dialed).

“1”“2”“3”, and “4” represent the priority, which determines the order in which commands for that extension will be executed.

Note that Asterisk does not care about the order in which you put the lines in the extensions.conf file. You could mix the lines into a different order, like this following example, and it would make no difference because Asterisk uses the priority of each line to determine order of execution:

exten => 555,4,Hangup

exten => 555,1,Answer

exten => 555,3,Voicemail(44)

exten => 555,2,Playback(tt-weasels)

The n Priority (Asterisk 1.2.x and later versions)

Instead of having to manually number (and renumber) priorities within a given extension, you may use “n” to represent the next priority. The “n” automatically increases a priority’s value incrementally. Previously, if you wanted to insert a command between the third and fourth line of a 20-priority extension, you would need to manually renumber each priority after the inserted line.


exten => 555,1,Answer

exten => 555,n,Playback(tt-weasels)

exten => 555,n,Voicemail(44)

exten => 555,n,Hangup

Using “n” priorities, there are two things you can do that make creating extension logic a lot easier.

The first is that you can set labels:

exten => s,n(Start),Answer

As well as making the dialplan more readable, labels can be the target of gotos:

exten => s,n,Goto(Start)

The second feature that makes using priorities easier is that arbitrary increments can be defined:

exten => s,n+2,Dial(…)

Maybe its utility is not so obvious, but in conjunction with labels, it can be pretty handy. In a typical dialplan, Asterisk must often handle the “+101” priority to handle the failure condition of an application, like Dial(). Without the n priority, if you were to change one of the lines within an extension, not only must the Dial() priority change, so must the corresponding +101 priority.

With n priority increments, the following expression is possible:

exten => s,n(MainDial),Dial(…) ; Dial the main numbers for this context

exten => s,MainDial+101,Voicemail(u100)

Now when new dial plan instructions are added before (MainDial) there is no need to update any priorities.

Note that the “+101” priority may also use a label:

exten => s,MainDial+101(MainDialNotAnswered),Voicemail(u100)

The s Priority (Asterisk 1.2.x and later versions)

You can use ‘s’ as a priority where different patterns may match at the same point in the extension and act differently for them. It would be the same as having multiple lines with the same fixed priority number. You cannot use ‘n’ in this case because there would be missing priorities for any pattern matches after the first one.


exten => 16025551212,1,Goto(customername#did|${EXTEN}|1000)

exten => 16025551213,1,Goto(customername#did|${EXTEN}|1000)

exten => _1602555121[4-9],1,Goto(customername#did|${EXTEN}|1000)

exten => _X.,1000,Set(CALLSOURCE=pstn)

exten => _X.,n,SetAccount(customername)

exten => 16025551212,n,Goto(customername#main,s,1)

exten => 16025551213,s,Goto(customername#fax,s,1)

exten => _1602555121[4-9],s,Goto(customername#extensions,${EXTEN:7},1)

What are Contexts and Extensions

Contexts and Extensions

After the [general] and [globals] categories, the remainder of the extensions.conf file is taken up by the definition of the Dialplan. The Dialplan consists of a collection of contexts. Each context consists of a collection of extensions. For an introduction to these topics:.

    • Introducing Contexts and Extensions

The Dialplan consists of a collection of contexts. These context definitions are the most important part of the extensions.conf file and are the most important part of Asterisk configuration.

A context is just a collection of extensions. Here is a diagrammatic representation (i.e. not something you’d type into your extensions.conf file!) of a simple example context:

Context “default”:

Extension Description

101 Mark Spencer

102 Wil Meadows

103 Greg Vance

104 Check voicemail

105 Conference Room

0 Operator

In this example context, which has been given the name “default”, the first three extensions (101 to 103) all would be associated with ringing phones belonging to various employees. The fourth extension (104) would be associated with allowing someone to check their voicemail. The fifth extension (105) would be associated with a conference room. Finally, the “0” extension would be associated with the operator.

Here is another simple example of a context:

Context “mainmenu”:

Extension Description

s Welcome message and instructions

1 Sales

2 Support

3 Accounting

9 Directory


This example context, given the name “mainmenu”, has only single-digit extensions. The “s” extension is the start extension, where the caller begins. This extension would play a message along the lines of “Thank you for calling OurCompany. Press 1 for sales, 2 for support, 3 for accounting, 9 for a company directory, or # to hangup.” Each menu option is, in fact, an extension and could either dial someone’s real extension or could do something like sending the caller to another menu.

Contexts can be used to implement a number of important features including:

    • Security: Permit long distance calls from certain phones only
    • Routing: Route calls based on extension
    • Autoattendant: Greet callers and ask them to enter extensions
    • Multilevel menus: Menus for sales, support, etc.
    • Authentication: Ask for passwords for certain extensions
    • Callback: Reduce long distance charges
    • Privacy: Blacklist annoying callers from contacting you
    • PBX Multihosting: Yes, you can have “virtual hosts” on your PBX
    • Daytime/Nighttime: You can vary behavior after hours
    • Macros: Create scripts for commonly used functions

How Are Contexts Used?

When Asterisk receives a call connection, whether an incoming call from outside, or from an internal extension, that call belongs to a context. Which context the call belongs to depends on what channel the call came in on. When you configured the channels that you have on your Asterisk PBX, one of the things you had to do was to define what context an incoming connection on that channel would be put into, using a definition like:


So the first way contexts are used is to make Asterisk do different things depending on where a call is coming from. You most likely will have at least one context defined for how Asterisk handles an incoming call on your telephone line: it might ring some of your extensions or play an announcement and record a voicemail message. You want Asterisk to handle connections from your internal extensions differently — they will be permitted to dial a different extension, or make an outgoing call — so you define that calls from those different channels go into different contexts.

LAB Part 1 Enable CDR (call detail record) logging

Need a master.csv to enable logging.

nano /etc/asterisk/cdr_custom.conf

uncomment [mappings]

uncomment Master.csv


In asterisk console

cdr show status

localhost*CLI> cdr show status

Call Detail Record (CDR) settings


Logging: Enabled

Mode: Simple

Log unanswered calls: No

Log congestion: No

* Registered Backends




Need to configure the cdr-custom field

cd /var/log/asterisk/


cd cdr-csv/


would see master.csv

cd ..

cd cdr-custom


Using Postfix:

service postfix status

Configure for a g-mail account

If postfix is not installed:

yum -y install postfix mailx cyrus-sasl-plain

edit /etc/postfix/sasl_passwd

smtp.gmail.com email@gmail.com:emailpassword

postmap hash:/etc/postfix/sasl_passwd

edit /etc/postfix/main.cf

smtp_sasl_auth_enable = yes

smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

samtp_sasl_security_options = noanonymous

# Secure channel TLS with exact nexthop name match.

smtp_tls_security_level = secure

smtp_tls_mandatory_protocols = TLSv1

smtp_tls_mandatory_ciphers = high

smtp_tls_secure_cert_match = nexthop

smtp_tls_Cafile = /etc/pki/tls/certs/ca-bundle.crt

relayhost = smtp.gmail.com:587

save file

service postfix restart

mail email@domain

rm /etc/postfix/sasl_passwd


; Find-Me / Follow-Me Configuration File
























number=>8605551212,36 ; change 8605551212 with extension 104 users mobile phone number, 36 is the ring time in seconds




number=>4075551212,36 ; change 4075551212 with extension 106 users mobile phone number, 36 is the ring time in seconds




number=>3055551212,36 ; change 3055551212 with extension 105 users mobile phone number, 36 is the ring time in seconds














serveremail = asterisk VOICEMAIL TO EMAIL


skipms = 3000

maxsilence = 10

maxmessage = 300

review = yes

silencethreshold = 128

maxlogins = 3

emaildateformat = %A, %B %d, %Y at %r

sendvoicemail = yes

exitcontext = vm-operator

operator = yes

fromstring = PBX Voicemail

[zonemessages] TIMEZONES

eastern = America/New_York|’vm-received’ Q ‘digits/at’ IMp

central = America/Chicago|’vm-received’ Q ‘digits/at’ IMp

central24 = America/Chicago|’vm-received’ q ‘digits/at’ H N ‘hours’

military = Zulu|’vm-received’ q ‘digits/at’ H N ‘hours’ ‘phonetic/z_p’

european = Europe/Copenhagen|’vm-received’ a d b ‘digits/at’ HM


100 => 1234,Office Mailbox,office@email.com,,attach=yes|hidefromdir=yes HIDE FROM DIR GENERIC GROUP

108 => 1234,John Doe,johndoe@email.com,,attach=yes

107 => 1234,Jame Doe,janedoe@email.com,,attach=yes

106 => 1234,Steve Smith,stevesmith@email.com,,attach=yes

105 => 1234,Sally Smith,sallysmith@email.com,,attach=yes

104 => 1234,Jeremy Clarkson,clarkson@email.com,,attach=yes

103 => 1234,Richard Hammond,hammond@email.com,,attach=yes

102 => 1234,Pink Floyd,pinkfloyd@email.com,,attach=yes

101 => 1234,Receptionist,receptionist@email.com,,attach=yes


LAB CUSTOMIZING extensions.conf

Breakdown: cat /etc/asterisk/extensions.conf





; #_#_# Phone Number #_#_#

exten => 2242179435,1,Answer ANSWER

exten => 2242179435,n,NoOp(Office-ANI-${EXTEN}) PRINT TO CONSOLE

exten => 2242179435,n,Set(CDR(userfield)=ib_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)}) CUSTOM CDR ENTRY, GET TIME, CALLERID

exten => 2242179435,n,MixMonitor(ib_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)}.wav) CALL RECORDING ON CALL

exten => 2242179435,n,Goto(schedule,${EXTEN},1) SCHEDULE FOR OPEN AND CLOSED HOURS


exten => .,1,Hangup() HANG UP IF INVALID # DIALED


exten => _NXXNXXXXXX,1,NoOp(Time-of-Day-Routing) MATCH FOR 2242179435

exten => _NXXNXXXXXX,n,GotoIfTime(8:58-17:02,mon-fri,*,*?inbound,${EXTEN},1) OPEN HOURS, OPEN DAYS, ?INBOUND=WHERE DO WE GO,${EXTEN=INBOUND DID},1)

exten => _NXXNXXXXXX,n,Goto(inbound-closed,${EXTEN},1) IF IT DOESN’T MATCH GO TO NEXT STEP




exten => _NXXNXXXXXX,n,Set(TIMEOUT(digit)=3) ; max wait in-between digits seconds

exten => _NXXNXXXXXX,n,Set(TIMEOUT(response)=3) ; max wait for digit entry seconds

exten => _NXXNXXXXXX,n,Ringing PLAY RING



exten => _NXXNXXXXXX,n,Wait(3)

exten => _NXXNXXXXXX,n,Background(custom/open-recording) PLAY CUSTOME/OPEN-RECORDING AGAIN

exten => _NXXNXXXXXX,n,Wait(3)

exten => _NXXNXXXXXX,n,Dial(SIP/101,18) Dial extension 101 the receptionist can use (SIP/${EXTEN},18) 18 SECONDS THEN GO TO VOICEMAIL

exten => _NXXNXXXXXX,n,Voicemail(100@default,su) Default voicemail box, and use unavailable message

exten => 0,1,NoOp(Office-Open-Press-Zero)

exten => 0,n,Voicemail(100@default,su)

exten => 2,1,NoOp(Operator-Directory)

exten => 2,n,Directory(default,vm-operator,f) SENDS USER TO COMPANY DIRECTORY

exten => 200,1,NoOp(External-Voicemail-Dial-From-${CALLERID(num)}) UNANNOUNCED OPTION, BACKDOOR TO VOICEMAIL SYSTEM

exten => 200,n,Playback(vm-dialout)

exten => 200,n,Wait(1)

exten => 200,n,VoiceMailMain()


exten => t,1,Playback(option-is-invalid)

exten => t,n,Hangup()


exten => i,n,Playback(option-is-invalid)

exten => i,n,Gotoif($[“${NUMINVALID}” < “4”]?:10) GO TO STEP 10 AFTER 4 INVALID TRIES

exten => i,n,Goto(_NXXNXXXXXX,menu)

exten => i,10,Playback(vm-goodbye) GOODBYE

exten => i,n,Hangup()


exten => _NXXNXXXXXX,1,NoOp(Office-Closed)


exten => _NXXNXXXXXX,n,Set(TIMEOUT(digit)=3)

exten => _NXXNXXXXXX,n,Set(TIMEOUT(response)=3)

exten => _NXXNXXXXXX,n,Ringing

exten => _NXXNXXXXXX,n(menu),Wait(1)

exten => _NXXNXXXXXX,n,Background(custom/closed-recording)

exten => _NXXNXXXXXX,n,Wait(3)

exten => _NXXNXXXXXX,n,Background(custom/closed-recording)

exten => _NXXNXXXXXX,n,Wait(3)

exten => _NXXNXXXXXX,n,Dial(SIP/101,18)

exten => _NXXNXXXXXX,n,Voicemail(100@default,su)

exten => 0,1,NoOp(Office-Open-Press-Zero)

exten => 0,n,Voicemail(100@default,su)

exten => 2,1,NoOp(Operator-Directory)

exten => 2,n,Directory(default,vm-operator,f)

exten => 200,1,NoOp(External-Voicemail-Dial-From-${CALLERID(num)})

exten => 200,n,Playback(vm-dialout)

exten => 200,n,Wait(1)

exten => 200,n,VoiceMailMain()

exten => _1XX,1,Macro(local-followme,${EXTEN})

exten => t,1,Playback(option-is-invalid)

exten => t,n,Hangup()

exten => i,1,Set(NUMINVALID=$[${NUMINVALID}+1]})

exten => i,n,Playback(option-is-invalid)

exten => i,n,Gotoif($[“${NUMINVALID}” < “4”]?:10)

exten => i,n,Goto(_NXXNXXXXXX,menu)

exten => i,10,Playback(vm-goodbye)

exten => i,n,Hangup()


exten => _NXXNXXXXXX,1,Dial(SIP/${EXTEN}@voip-outbound,120,trwW)

exten => _NXXNXXXXXX,n,Hangup()

exten => .,1,Playback(invalid)

exten => .,n,Hangup()


; #_#_#_#_#_#_#_#_# INTERNAL MAIN CONTEXT #_#_#_#_#_#_#_#_#_#

; Extension to Extension Dialing

exten => _1XX,1,Macro(local-followme,${EXTEN})

; Call Pickup

exten => _*971XX,1,SET(GLOBAL(PICKUPMARK)=${EXTEN:2})

exten => _*971XX,n,Pickup(${EXTEN:2}@PICKUPMARK)

; Voicemail Access

exten => 1000,1,VoiceMailMain(${CALLERID(num)}@default)

exten => 2000,1,VoiceMailMain()

; Outbound Dialing

exten => _NXXXXXX,1,Answer

exten => _NXXXXXX,n,Set(CDR(userfield)=ib_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)}) CUSTOM CDR

exten => _NXXXXXX,n,MixMonitor(ob_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)}.wav) RECORD CALL

exten => _NXXXXXX,n,Set(CALLERID(num)=2242179435)

exten => _NXXXXXX,n,Goto(outbound,224${EXTEN},1) HARDCODED AREA CODE

exten => _NXXNXXXXXX,1,Answer

exten => _NXXNXXXXXX,n,Set(CDR(userfield)=ib_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)})

exten => _NXXNXXXXXX,n,MixMonitor(ob_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)}.wav)

exten => _NXXNXXXXXX,n,Set(CALLERID(num)=2242179435)

exten => _NXXNXXXXXX,n,Goto(outbound,${EXTEN},1)

exten => _1NXXNXXXXXX,1,Answer

exten => _1NXXNXXXXXX,n,Set(CDR(userfield)=ib_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)})

exten => _1NXXNXXXXXX,n,MixMonitor(ob_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)}.wav)

exten => _1NXXNXXXXXX,n,Set(CALLERID(num)=2242179435)

exten => _1NXXNXXXXXX,n,Goto(outbound,${EXTEN:1},1)

exten => t,1,Playback(invalid)

exten => t,n,Hangup()

exten => i,1,Playback(invalid)

exten => i,n,Hangup()

exten => .,1,Playback(invalid)

exten => .,n,Hangup()


exten => s,1,GotoIf($[${DB_EXISTS(followme/${ARG1})}=0]?nofollow)

exten => s,n,GotoIf($[${DB_RESULT:0:1}=0]?nofollow:follow)

exten => s,n(follow),Dial(SIP/${ARG1},20)

exten => s,n,Followme(${ARG1},n) ; Removed sa so no name recording

exten => s,n,Goto(s-${DIALSTATUS},1)

exten => s,n(nofollow),Dial(SIP/${ARG1},20)

exten => s,n,Goto(s-${DIALSTATUS},1)

exten => s-NOANSWER,1,Voicemail(${ARG1},u) ; If unavailable, send to voicemail

exten => s-BUSY,1,Voicemail(${ARG1},u) ; I changed b to u. If busy, send to voicemail w/ busy ann

exten => _s-.,1,Goto(s-NOANSWER,1)


exten => _NXXNXXXXXX,1,NoOp(follow-me-activated-${EXTEN})

exten => _NXXNXXXXXX,n,Set(CALLERID(num)=${IF($[ ${LEN(${CALLERID(num)})} = 3]?2242179435:${CALLERID(num)})})


exten => _1NXXNXXXXXX,1,NoOp(follow-me-activated-${EXTEN})

exten => _1NXXNXXXXXX,n,Set(CALLERID(num)=${IF($[ ${LEN(${CALLERID(num)})} = 3]?2242179435:${CALLERID(num)})})

exten => _1NXXNXXXXXX,n,Goto(outbound,${EXTEN:1},1)

exten => _1XX,1,Dial(SIP/${EXTEN},120,t)

exten => _1XX,n,Hangup()


exten => o,1,NoOp(operator-zero-out)

exten => o,n,Goto(vm-zero-menu,s,1)

; Direct Extension Dialing

exten => _1XX,1,Macro(local-followme,${EXTEN})


exten => s,1,NoOp(operator-asterisk-out)

exten => s,n,Set(TIMEOUT(digit)=3)

exten => s,n,Set(TIMEOUT(response)=3)

exten => s,n,Background(custom/vm-operator-recording)

exten => s,n,Wait(3)

exten => s,n,Voicemail(100@default,su)

exten => 0,1,Voicemail(100@default,su)

exten => 1,1,NoOp(Operator-Directory)

exten => 1,n,Directory(default,vm-operator,f)

exten => 2,1,Voicemail(100@default,su)

exten => 3,1,Voicemail(100@default,su)

exten => 4,1,Voicemail(100@default,su)

exten => 5,1,Voicemail(100@default,su)

exten => 6,1,Voicemail(100@default,su)

exten => 7,1,Voicemail(100@default,su)

exten => 8,1,Voicemail(100@default,su)

exten => 9,1,Voicemail(100@default,su)

; Direct Extension Dialing

exten => _1XX,1,Macro(local-followme,${EXTEN})

exten => t,1,Playback(invalid)

exten => t,n,Hangup()

exten => i,1,Playback(invalid)

exten => i,n,Hangup()

exten => .,1,Playback(invalid)

exten => .,n,Hangup()


Creating the custom recording.

Edit /etc/asterisk/extensions.conf

Go to bottom of [mycontext] insert before [voipms-outbound]

insert the following to create the recording:

; Create Recording

exten => 299,1,Answer

exten => 299,n,Wait(2)

exten => 299,n,Record(ast-rec%d.wav)

exten => 299,n,Playback(beep)

exten => 299,Wait(2)

exten => 299,n,Playback(${RECORDED_FILE})

exten => 299,n,Wait(2)

exten => 299,SayAlpha(${RECORDED_FILE})

exten => 299,n,Wait(2)

exten => 299,n,Hangup

recordings live in


mkdir custom

mv wav file to custom/with new name if needed

[root@localhost custom]# pwd


[root@localhost custom]# ls


[root@localhost custom]#

Can also use voicemail box for recordings it stores those files in the following directory


You can then go to your mailbox INBOX and see the wav files and mv msg0002.wav /var/lib/asterisk/sounds/custom/another-custom-recording.wav

Creating the custom SIP/Extensions/Voicemail/Followme

rename the sip.conf to sip.conf_orig.txt

rename the extensions.conf to extensions.conf_orig.txt

rename the voicemail.conf to voicemail.conf_orig.txt

rename the followme.conf to followme.conf_orig.txt

Recreate with the following attached files making changes to needed areas