Answer, Playback, and Hangup Applications
Answer, Playback, and Hangup Applications
Answer([delay
])
The Answer() application answers an incoming call. The Answer() application takes a delay (in milliseconds) as its first parameter. Adding a short delay is often useful for ensuring that the remote endpoint has time to begin processing audio before you play a sound prompt. Otherwise, you may not hear the very beginning of the prompt.
When to Answer a Call
If Asterisk is simply going to pass the call off to another device using the Dial() application, you probably don’t want to call the answer the call first. If, on the other hand, you want Asterisk to play sound prompts or gather input from the caller, it’s probably a good idea to call the Answer() application before doing anything else.
The Playback() application loads a sound prompt from disk and plays it to the caller, ignoring any touch tone input from the caller. The first parameter to the dialplan application is the filename of the sound prompt you wish to play, without a file extension. If the channel has not already been answered, Playback() will answer the call before playing back the sound prompt, unless you pass noanswer as the second parameter.
To avoid the first few milliseconds of a prompt from being cut off you can play a second of silence. For example, if the prompt you wanted to play was hello-world which would look like this in the dialplan:
exten => 1234,1,Playback(hello-world) |
You could avoid the first few seconds of the prompt from being cut off by playing the silence/1 file:
exten => 1234,1,Playback(silence/1) exten => 1234,n,Playback(hello-world) |
Alternatively this could all be done on the same line by separating the filenames with an ampersand (&):
exten => 1234,1,Playback(silence/1&hello-world) |
The Hangup() application hangs up the current call. While not strictly necessary due to auto-fallthrough (see the note on Priority numbers above), in general we recommend you add the Hangup() application as the last priority in any extension.
Now let’s put Answer(), Playback(), and Hangup() together to play a sample sound file.
exten => 6000,1,Answer(500) exten => 6000,n,Playback(hello-world) exten => 6000,n,Hangup() |