The Goto application
Another one of the applications that will make your dialplan more dynamic is the Goto application. This application enables you to jump to a particular priority, extension, or context. The application accepts up to three parameters:
- if you specify just a single parameter, Asterisk will jump to the specified priority within the current extension.
- if you specify two parameters, Asterisk will treat the first parameter as an extension within the current context to jump to, and the second parameter as the priority within that extension.
- if you specify three parameters, Asterisk will treat them as the context, extension, and priority (respectively) to jump to.
Here is a simple example. First we will create a new context in our dialplan with the extension we will jump to:
[NewContext] exten => 555,1,Playback(you-have-reached-a-test-number)
Now, we will call the Goto application inside our old context (local). Add the following code to the end of the local context:
exten => 555,1,Goto(NewContext,555,1)
Now, when a device enters the local context and dials 555, the call will be passed to the extension 555 in the NewContext context and the sound you-have-reached-a-test-number will be played.