# Asterisk Project : Answer, Playback, and Hangup Applications

Added by malcolmd , edited by lmadsen on Feb 24, 2011

As its name suggests, 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 endpoing has time to begin processing audio before you play a sound prompt. Otherwise, you may not hear the very beginning of the prompt.

Knowing When to Answer a Call

When you're first learning your way around the Asterisk dialplan, it may be a bit confusing knowing when to use the Answer() application, and when not to.

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)