<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/2041/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/Handling+Special+Extensions">Handling Special 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>
Update dialplan to use the A:TDG method.<br />
</div>
<br/>
<h4>Changes (10)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >Let's add a few more lines to our *\[docs:demo-menu\]* context, to handle invalid entries and timeouts. Modify your *\[docs:demo-menu\]* context so that it matches the one below: <br>{code:lang=javascript}[demo-menu] <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">exten=>s,1,Answer(500) <br>exten=>s,n(loop),Background(press-1&or&press-2) <br>exten=>s,n,WaitExten() <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">exten => s,1,Answer(500) <br> same => n(loop),Background(press-1&or&press-2) <br> same => n,WaitExten() <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;">exten=>1,1,Playback(you-entered) <br>exten=>1,n,SayNumber(1) <br>exten=>1,n,Goto(s,loop) <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">exten => 1,1,Playback(you-entered) <br> same => n,SayNumber(1) <br> same => n,Goto(s,loop) <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;">exten=>2,1,Playback(you-entered) <br>exten=>2,n,SayNumber(2) <br>exten=>2,n,Goto(s,loop) <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">exten => 2,1,Playback(you-entered) <br> same => n,SayNumber(2) <br> same => n,Goto(s,loop) <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;">exten=>i,1,Playback(option-is-invalid) <br>exten=>i,n,Goto(s,loop) <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">exten => i,1,Playback(option-is-invalid) <br> same => n,Goto(s,loop) <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;">exten=>t,1,Playback(are-you-still-there) <br>exten=>t,n,Goto(s,loop){code} <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">exten => t,1,Playback(are-you-still-there) <br> same => n,Goto(s,loop){code} <br></td></tr>
<tr><td class="diff-unchanged" >Now dial your auto-attendant menu again (by dialing extension *6598*), and try entering an invalid option (such as *3*) at the auto-attendant menu. If you watch the Asterisk command-line interface while you dial and your verbosity level is three or higher, you should see something similar to the following: <br>{noformat}-- Executing [6598@users:1] Goto("SIP/demo-alice-00000008", "demo-menu,s,1") in new stack <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
</table>
</div> <h4>Full Content</h4>
<div class="notificationGreySide">
<p>We have the basics of an auto-attendant created, but now let's make it a bit more robust. We need to be able to handle special situations, such as when the caller enters an invalid extension, or doesn't enter an extension at all. Asterisk has a set of special extensions for dealing with situations like there. They all are named with a single letter, so we recommend you don't create any other extensions named with a single letter. The most common special extensions include:</p>
<h4><a name="HandlingSpecialExtensions-i%3Atheinvalidentryextension"></a>i: the invalid entry extension</h4>
<p>If Asterisk can't find an extension in the current context that matches the digits dialed during the <b>Background()</b> or <b>WaitExten()</b> applications, it will send the call to the <b>i</b> extension. You can then handle the call however you see fit.</p>
<h4><a name="HandlingSpecialExtensions-t%3Athereponsetimeoutextension"></a>t: the reponse timeout extension</h4>
<p>When the caller waits too long before entering a response to the <b>Background()</b> or <b>WaitExten()</b> applications, and there are no more priorities in the current extension, the call is sent to the t extension.</p>
<h4><a name="HandlingSpecialExtensions-s%3Athestartextension"></a>s: the start extension</h4>
<p>When an analog call comes into Asterisk, the call is sent to the <b>s</b> extension. The s extension is also used in macros.</p>
<p>Please note that the <b>s</b> extension is <b>not</b> a catch-all extension. It's simply the location that analog calls and macros begin. In our example above, it simply makes a convenient extension to use that can't be easily dialed from the <b>Background()</b> and <b>WaitExten()</b> applications.</p>
<h4><a name="HandlingSpecialExtensions-h%3Athehangupextension"></a>h: the hangup extension</h4>
<p>When a call is hung up, Asterisk executes the <b>h</b> extension in the current context. This is typically used for some sort of clean-up after a call has been completed.</p>
<h4><a name="HandlingSpecialExtensions-o%3Atheoperatorextension"></a>o: the operator extension</h4>
<p>If a caller presses the zero key on their phone keypad while recording a voice mail message, and the <b>o</b> extension exists, the caller will be redirected to the o extension. This is typically used so that the caller can press zero to reach an operator.</p>
<h4><a name="HandlingSpecialExtensions-a%3Atheassistantextension"></a>a: the assistant extension</h4>
<p>This extension is similar to the <b>o</b> extension, only it gets triggered when the caller presses the asterisk (*) key while recording a voice mail message. This is typically used to reach an assistant.</p>
<hr />
<p>Let's add a few more lines to our <b>[docs:demo-menu]</b> context, to handle invalid entries and timeouts. Modify your <b>[docs:demo-menu]</b> context so that it matches the one below:</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[[demo-menu]
exten => s,1,Answer(500)
same => n(loop),Background(press-1&or&press-2)
same => n,WaitExten()
exten => 1,1,Playback(you-entered)
same => n,SayNumber(1)
same => n,Goto(s,loop)
exten => 2,1,Playback(you-entered)
same => n,SayNumber(2)
same => n,Goto(s,loop)
exten => i,1,Playback(option-is-invalid)
same => n,Goto(s,loop)
exten => t,1,Playback(are-you-still-there)
same => n,Goto(s,loop)]]></script>
</div></div>
<p>Now dial your auto-attendant menu again (by dialing extension <b>6598</b>), and try entering an invalid option (such as <b>3</b>) at the auto-attendant menu. If you watch the Asterisk command-line interface while you dial and your verbosity level is three or higher, you should see something similar to the following:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>-- Executing [6598@users:1] Goto("SIP/demo-alice-00000008", "demo-menu,s,1") in new stack
-- Goto (demo-menu,s,1)
-- Executing [s@demo-menu:1] Answer("SIP/demo-alice-00000008", "500") in new stack
-- Executing [s@demo-menu:2] BackGround("SIP/demo-alice-00000008", "press-1&or&press-2") in new stack
-- <SIP/demo-alice-00000008> Playing 'press-1.gsm' (language 'en')
-- <SIP/demo-alice-00000008> Playing 'or.gsm' (language 'en')
-- <SIP/demo-alice-00000008> Playing 'press-2.gsm' (language 'en')
-- Invalid extension '3' in context 'demo-menu' on SIP/demo-alice-00000008
-- Executing [i@demo-menu:1] Playback("SIP/demo-alice-00000008", "option-is-invalid") in new stack
-- <SIP/demo-alice-00000008> Playing 'option-is-invalid.gsm' (language 'en')
-- Executing [i@demo-menu:2] Goto("SIP/demo-alice-00000008", "s,loop") in new stack
-- Goto (demo-menu,s,2)
-- Executing [s@demo-menu:2] BackGround("SIP/demo-alice-00000008", "press-1&or&press-2") in new stack
-- <SIP/demo-alice-00000008> Playing 'press-1.gsm' (language 'en')
-- <SIP/demo-alice-00000008> Playing 'or.gsm' (language 'en')
-- <SIP/demo-alice-00000008> Playing 'press-2.gsm' (language 'en')</pre>
</div></div>
<p>If you don't enter anything at the auto-attendant menu and instead wait approximately ten seconds, you should hear (and see) Asterisk go to the <b>t</b> extension as well.</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/Handling+Special+Extensions">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=4817377&revisedVersion=11&originalVersion=10">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/Handling+Special+Extensions?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>