<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/2042/1/7/_/styles/combined.css?spaceKey=AST&forWysiwyg=true" type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://wiki.asterisk.org/wiki/display/AST/Creating+Dialplan+Extensions">Creating Dialplan Extensions</a></h2>
<h4>Page <b>edited</b> by <a href="https://wiki.asterisk.org/wiki/display/~lmadsen">Leif Madsen</a>
</h4>
<div id="versionComment">
<b>Comment:</b>
Fixing formatting.<br />
</div>
<br/>
<h4>Changes (8)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-unchanged" >The last things we need to do to enable Alice and Bob to call each other is to configure a couple of extensions in the dialplan. <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{info}What is an Extension? <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">{info}h5. What is an Extension? <br></td></tr>
<tr><td class="diff-unchanged" >When dealing with Asterisk, the term extension does not represent a physical device such as a phone. An extension is simply a set of actions in the dialplan which may or may not write a physical device. In addition to writing a phone, an extensions might be used for such things auto-attendant menus and conference bridges. In this guide we will be careful to use the words phone or device when referring to the physical phone, and extension when referencing the set of instructions in the Asterisk dialplan.{info} <br>Let's take a quick look at the dialplan, and then add two extensions. <br> <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Open *extensions.conf*, and take a quick look at the file. Near the top of the file, you'll see some general-purpose sections named *\[docs:general\]* and *\[docs:globals\]*. Any sections in the dialplan beneath those two sections is known as a *context*. The sample *extensions.conf* file has a number of other contexts, with names like *\[docs:demo\]* and *\[docs:default\]*. <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">Open *extensions.conf*, and take a quick look at the file. Near the top of the file, you'll see some general-purpose sections named \[general\] and \[globals\]. Any sections in the dialplan beneath those two sections is known as a *context*. The sample *extensions.conf* file has a number of other contexts, with names like \[demo\] and \[default\]. <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-changed-lines" >We'll cover contexts more in <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">[Section 215. Dialplan Fundamentals|~mdavenport:215. Dialplan</span> <span class="diff-added-words"style="background-color: #dfd;">[Dialplan</span> Fundamentals], but for now you should know that each phone or outside connection in Asterisk points at a single context. If the dialed extension does not exist in the specified context, Asterisk will reject the call. <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-changed-lines" >Go to the bottom of your *extensions.conf* file, and add a new context named <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">*\[docs:users\]*.</span> <span class="diff-added-words"style="background-color: #dfd;">\[users\].</span> <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">*Naming Your Dialplan Contexts* <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">h5. Naming Your Dialplan Contexts <br></td></tr>
<tr><td class="diff-unchanged" > <br>There's nothing special about the name *users* for this context. It could have been named *strawberry_milkshake*, and it would have behaved exactly the same way. It is considered best practice, however, to name your contexts for the types of extensions that are contained in that context. Since this context contains extensions for the users of our PBX system, we'll call our context *users*. <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
</table>
</div> <h4>Full Content</h4>
<div class="notificationGreySide">
<p>The last things we need to do to enable Alice and Bob to call each other is to configure a couple of extensions in the dialplan.</p>
<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><h5><a name="CreatingDialplanExtensions-WhatisanExtension%3F"></a>What is an Extension?</h5>
<p>When dealing with Asterisk, the term extension does not represent a physical device such as a phone. An extension is simply a set of actions in the dialplan which may or may not write a physical device. In addition to writing a phone, an extensions might be used for such things auto-attendant menus and conference bridges. In this guide we will be careful to use the words phone or device when referring to the physical phone, and extension when referencing the set of instructions in the Asterisk dialplan.</p></td></tr></table></div>
<p>Let's take a quick look at the dialplan, and then add two extensions.</p>
<p>Open <b>extensions.conf</b>, and take a quick look at the file. Near the top of the file, you'll see some general-purpose sections named [general] and [globals]. Any sections in the dialplan beneath those two sections is known as a <b>context</b>. The sample <b>extensions.conf</b> file has a number of other contexts, with names like [demo] and [default].</p>
<p>We'll cover contexts more in <a href="/wiki/display/AST/Dialplan+Fundamentals" title="Dialplan Fundamentals">Dialplan Fundamentals</a>, but for now you should know that each phone or outside connection in Asterisk points at a single context. If the dialed extension does not exist in the specified context, Asterisk will reject the call.</p>
<p>Go to the bottom of your <b>extensions.conf</b> file, and add a new context named [users].</p>
<h5><a name="CreatingDialplanExtensions-NamingYourDialplanContexts"></a>Naming Your Dialplan Contexts</h5>
<p>There's nothing special about the name <b>users</b> for this context. It could have been named <b>strawberry_milkshake</b>, and it would have behaved exactly the same way. It is considered best practice, however, to name your contexts for the types of extensions that are contained in that context. Since this context contains extensions for the users of our PBX system, we'll call our context <b>users</b>.</p>
<p>Underneath that context name, we'll create an extesion numbered <b>6001</b> which attempts to ring Alice's phone for twenty seconds, and an extension <b>6002</b> which attempts to rings Bob's phone for twenty seconds.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: Confluence; brush: javascript; gutter: false"><![CDATA[[users]
exten=>6001,1,Dial(SIP/demo-alice,20)
exten=>6002,1,Dial(SIP/demo-bob,20)]]></script>
</div></div>
<p>After adding that section to <b>extensions.conf</b>, go to the Asterisk command-line interface and tell Asterisk to reload the dialplan by typing the command <b>dialplan reload</b>. You can verify that Asterisk successfully read the configuration file by typing <b>dialplan show users</b> at the CLI.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>server*CLI> dialplan show users
[ Context 'users' created by 'pbx_config' ]
'6001' => 1. Dial(SIP/demo-alice,20) [pbx_config]
'6002' => 1. Dial(SIP/demo-bob,20) [pbx_config]
-= 2 extensions (2 priorities) in 1 context. =-
</pre>
</div></div>
<p>Now we're ready to make a test call!</p>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;">
<a href="https://wiki.asterisk.org/wiki/users/viewnotifications.action" class="grey">Change Notification Preferences</a>
</div>
<a href="https://wiki.asterisk.org/wiki/display/AST/Creating+Dialplan+Extensions">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=4817416&revisedVersion=7&originalVersion=6">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/Creating+Dialplan+Extensions?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>