VoIP Cookbook: The Extension Pattern

From OnnoWiki
Jump to navigation Jump to search

When Asterisk accepts incoming connection through a channel, Asterisk will see the context defined for such a channel to see what commands that need to be carried out by Asterisk. Context will define a set of commands depending on the extension called by the user. For example, a given context may give a set of commands if a user calls the number "123", and a set of other commands if the user dials "9". We can also create another set of commands if the user calls number beginning with "555”.

If there are incoming connections - such as that coming from phone line outside – it implies that the user has not dialed an extension. In this case, Asterisk will act as a user dialing a particular extension called "s" (originating from the word “Start”). Asterisk will look for the extension "number" s in the definition of context for the channel and look for instructions that needs to be carried out for the "s" extension.

For example, we have a channel "Zap/1", which is connected to a telephone in an office. For example, in the Zap channel configuration (zapata.conf) we have defined context=john for Zap channel 1. Therefore, if we use a handset to dial a number, Asterisk will look for context with the name "john" in extensions.conf to see what has to be done. We can start a context by writing the name in square brackets

[john] 

For each context, we can define one or more extensions that can be used by Asterisk to compare the numbers to be dialed. For each extension, we can tell Asterisk what needs to be done though a set of commands.

See Also