<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/en/2160/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/Lua+Dialplan+Configuration">Lua Dialplan Configuration</a></h2>
<h4>Page <b>edited</b> by <a href="https://wiki.asterisk.org/wiki/display/~mnicholson">Matthew Nicholson</a>
</h4>
<div id="versionComment">
<b>Comment:</b>
Added the PBX Lua Basics section<br />
</div>
<br/>
<h4>Changes (2)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-changed-lines" >Asterisk supports the ability to write dialplan instructions in the [Lua|http://lua.org] programming language. This method can be used as an alternative to or in combination with [extensions.conf|Dialplan Fundamentals] and/or [AEL|Asterisk Extension Language (AEL)]. PBX lua allows users to use the full power of lua to develop telephony applications using Asterisk. <span class="diff-added-words"style="background-color: #dfd;">Lua dialplan configuration is done in the {{extensions.lua}} file.</span> <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;"> <br>h2. PBX Lua Basics <br> <br>The {{extensions.lua}} file is used to configure PBX lua and is a lua script (as opposed to being a standard asterisk configuration file). Any thing that is proper lua code is allowed in this file. Asterisk expects to find a global table named '{{extensions}}' when the file is loaded. This table can be generated however you wish. The simplest way is to define all of the extensions in line, but for more complex dialplans alternative methods may be necessary. <br> <br>{code:title=extensions.lua} <br>extensions = { <br> default = { <br> ["100"] = function(context, extension) <br> app.playback("please-hold") <br> app.dial("SIP/100", 60) <br> end; <br> <br> ["101"] = function(c, e) <br> app.dial("SIP/101", 60) <br> end; <br>} <br>{code} <br> <br>The {{extensions.lua}} file can be reloaded by reloading the pbx_lua module. <br>{code} <br>*CLI> module reload pbx_lua <br>{code} <br> <br>If there are errors in the file, the errors will be reported and the existing extensions.lua file will remain in use. Channels that existed before the reload command was issued will also continue to use the existing extensions.lua file. <br> <br>Runtime errors are logged and the channel on which the error occurred is hung up. <br></td></tr>
</table>
</div> <h4>Full Content</h4>
<div class="notificationGreySide">
<p>Asterisk supports the ability to write dialplan instructions in the <a href="http://lua.org" class="external-link" rel="nofollow">Lua</a> programming language. This method can be used as an alternative to or in combination with <a href="/wiki/display/AST/Dialplan+Fundamentals" title="Dialplan Fundamentals">extensions.conf</a> and/or <a href="/wiki/display/AST/Asterisk+Extension+Language+%28AEL%29" title="Asterisk Extension Language (AEL)">AEL</a>. PBX lua allows users to use the full power of lua to develop telephony applications using Asterisk. Lua dialplan configuration is done in the <tt>extensions.lua</tt> file.</p>
<h2><a name="LuaDialplanConfiguration-PBXLuaBasics"></a>PBX Lua Basics</h2>
<p>The <tt>extensions.lua</tt> file is used to configure PBX lua and is a lua script (as opposed to being a standard asterisk configuration file). Any thing that is proper lua code is allowed in this file. Asterisk expects to find a global table named '<tt>extensions</tt>' when the file is loaded. This table can be generated however you wish. The simplest way is to define all of the extensions in line, but for more complex dialplans alternative methods may be necessary.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>extensions.lua</b></div><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">extensions = {
default = {
["100"] = function(context, extension)
app.playback("please-hold")
app.dial("SIP/100", 60)
end;
["101"] = function(c, e)
app.dial("SIP/101", 60)
end;
}</pre>
</div></div>
<p>The <tt>extensions.lua</tt> file can be reloaded by reloading the pbx_lua module.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">*CLI> module reload pbx_lua</pre>
</div></div>
<p>If there are errors in the file, the errors will be reported and the existing extensions.lua file will remain in use. Channels that existed before the reload command was issued will also continue to use the existing extensions.lua file.</p>
<p>Runtime errors are logged and the channel on which the error occurred is hung up.</p>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;" class="grey">
<a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
<span style="padding: 0px 5px;">|</span>
<a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
<a href="https://wiki.asterisk.org/wiki/display/AST/Lua+Dialplan+Configuration">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=16548006&revisedVersion=4&originalVersion=3">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/Lua+Dialplan+Configuration?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>