Adding Additional Functionality

Asterisk has the ability to ring multiple phones for the same call. Using the Dial() application we simply add an ampersand (&) between the two or more channels we wish to ring. In our following example we are going to show how the Dial() application can ring multiple interfaces at the same time. This would allow you to answer the incoming channel at either one of the ringing interfaces.

Adding another FXS port


			[incoming]
			exten => s,1,Answer() ; Answer the line
			exten => s,2,Playback(welcome) ; Play back the 'welcome' sound file
			exten => s,3,Dial(Zap/2&Zap/3) ; Dial both channels Zap/2 and Zap/3
			

We are using the 's' extension in our example which as we know allows these commands to be executed automatically. Our first priority will answer the line, the second priority will playback the welcome message. The Dial() application uses an ampersand (&) to build a list of channels (Zap/2 and Zap/3 respectively) which ring concurrently during an incoming call.

Creating Voice Menus

With Asterisk we have the ability to very simply develop custom IVR systems. IVR is an acronym for "Interactive Voice Response" which can be defined as an automated call handling system where a user interacts with a computer controlled voice system using either human recorded or TTS (text-to-speech) prompts which are interacted with through a touch tone phone.

You would recognize this as any system where an auto-attendent attempted to route your call to an appropriate department by asking you to "Press 1 for Sales, Press 2 for Parts or Press 0 to speak with an Operator".

Accepting User Input With The Background() Application

The Background() application allows us to play a pre-recorded file to a user while allowing us to accept input from the user before the file has finished playing. This is different from the Playback() application which will not accept input from the user until the entire file has finished playing. What Background() allows us to do is build a list of options into a single file, which we will call a "menu", to give a user calling our system multiple options. When a user hears the option they wish to use, they can press the appropriate button on their touch tone phone and they will be directed to that extension immediately.

Adding a Voice Menu

Now that we understand what an IVR is and how the Background() application differs from that of Playback() , we can use them in our following example to demonstrate their use within Asterisk.


			[incoming]
			exten => s,1,Answer() ; Answer the line
			exten => s,2,Playback(welcome) ; Play back the 'welcome' sound file
			exten => s,3,Background(menu) ; Play 'menu' file and accept input from caller
			exten => 1,1,Dial(Zap/2) ; Dial channels Zap/2 if the user dials 1
			exten => 2,1,Dial(Zap/3) ; Dial channels Zap/3 if the user dials 2
			

After we Answer() the channel, we Playback() the 'welcome' sound file which will not accept any input from the user - they are forced to listen to the entire file. After the 'welcome' message finishes we execute the Background() application to play out 'menu' file. While this is being played to the user, Asterisk will wait for input and will execute any applications which match the extension numbers being dialed. In the above example, if either 1 or 2 are pressed by the user, they will be redirected to either channel Zap/2 or Zap/3 respectfully.

Handling Calls Between Internal Users

[Explain that we're going to add a second context, and use it for calling between internal extensions.]

So far we have limited ourselves to a single context for incoming calls. It is probably fair to assume that most installations will have more than one extension, and that we would want to call between them. For this we can create a new context called [internal]. This context will contain the extension numbers and what channel to associate with that number. The following example demonstrates that we can associate different extension numbers to the same channel name in different contexts. We assume that these extensions are configured to have access to the [internal] extension in their own configuration file.


			[incoming]
			exten => s,1,Answer() ; Answer the line
			exten => s,2,Playback(welcome) ; Play back the 'welcome' sound file
			exten => s,3,Background(menu) ; Play 'menu' file and accept input from caller
			exten => 1,1,Dial(Zap/2) ; Dial channels Zap/2 if the user dials 1
			exten => 2,1,Dial(Zap/3) ; Dial channels Zap/3 if the user dials 2

			[internal]
			exten => 1001,1,Dial(Zap/2) ; Dialing extension 1001 calls channel Zap/2
			exten => 1002,1,Dial(Zap/3) ; Dialing extension 1002 calls channel Zap/3
			

The above example shows that incoming calls to the [incoming] context can dial Zap/2 by selecting the option "1" from our menu. However we would like to standardize the internal extensions with 4 digit numbers. As we can see, any extension with access to the [internal] context can access the Zap/2 and Zap/3 channels via extension 1001 and 1002 respectfully.