Asterisk Answer Application: Answering Ringing Channels in the Dialplan
Learn how Asterisk Answer() changes a ringing channel to answered, and how to use it before Playback() and Hangup() in a simple dialplan.
What Answer() Does
Answer() is an Asterisk dialplan application that answers the current channel. When an inbound call enters the dialplan while it is still ringing, Answer() transitions that channel into an answered state.
A channel is a call leg or communications path handled by Asterisk. Answer() operates on the channel currently executing the dialplan; it does not answer every channel in the system.
Answering establishes the call for subsequent call-handling applications. After the channel is answered, the dialplan can provide media, play an announcement, collect input, connect the caller to another destination, or apply other established-call treatment.
Ringing and Answered Channel States
A channel in the ringing state represents a call whose destination has not yet accepted the call. A channel can enter the dialplan in this state because inbound call routing may select an extension before a person or application has answered it.
An answered state indicates that the call has been accepted and is ready for established-call processing. The signaling event that communicates this change is called answer supervision.
Answer supervision can matter in several ways:
- It tells the originating network or endpoint that the call was answered.
- It commonly determines when billable call time begins, depending on the provider and signaling technology.
- It affects when normal two-way or application-provided media should be treated as part of an established call.
- It gives later dialplan applications a predictable call state to work with.
Before answering, some technologies may support early media, such as progress tones or announcements. That behavior is different from answering the call. For an introductory dialplan pattern, explicitly answer the channel before presenting the main audio treatment.
Dialplan Structure: Extension, Priority, and Application
A dialplan is Asterisk's call-routing and call-processing logic. It is commonly organized into contexts and extensions. An extension is a dialable destination with an ordered list of priorities. A priority determines the execution order of an application.
An application is written on a priority line. In the following pattern, the first line answers the current channel:
[example-context]
exten => 999,1,Answer()
same => n,Playback(this-call-may-be-monitored-or-recorded)
same => n,Hangup()The context name is illustrative. It must be connected to the inbound route used by your deployment. The extension number, 999, is the destination the caller dials.
999is the extension.1is the first priority.Answer()is the application executed at that priority.same => ncontinues in the same extension at the next priority.
Recommended Application Order
A clear introductory sequence for a one-way announcement is:
- Answer the current channel.
- Provide media or other call treatment.
- Terminate the channel when the treatment is complete.
In dialplan form, that sequence is Answer(), then Playback(), then Hangup(). Explicit Answer() is a useful predictable pattern when an extension immediately presents audio. The exact need for explicit answering can depend on the application and call scenario, so application-specific behavior should be checked when designing more advanced flows.
| Application | Primary role | Position in flow |
|---|---|---|
| Answer() | Answers the current ringing channel | First |
| Playback() | Plays a recorded prompt or announcement | After answering |
| Hangup() | Disconnects the current channel | After the final treatment |
Interaction with Playback()
Playback() delivers a recorded prompt or announcement to the channel. In the example, the prompt gives an informational notice that the call may be monitored or recorded.
The value passed to Playback() is a sound identifier, not an arbitrary sentence. Asterisk uses that identifier to locate an installed sound prompt in a supported format. The actual recording must be available in the sound resources installed and configured for the system.
Putting Answer() before Playback() makes the call state explicit: the channel is answered before the announcement is delivered. This is especially useful for a simple announcement extension where the caller should experience an established call followed by recorded media.
Interaction with Hangup()
Hangup() ends the current call channel. For a one-way announcement, it normally follows Playback() as the final action.
Without Hangup(), the dialplan may continue to later priorities or other included logic, depending on the surrounding configuration. Adding Hangup() makes the intended lifecycle clear and prevents the announcement extension from accidentally continuing into another call treatment.
Simple Answer Application Call Flow
Suppose a caller dials extension 999 to hear an advisory message. The call progresses as follows:
- The inbound route sends the call to
example-context, extension 999. The channel is still ringing. - Priority 1 runs Answer(). Asterisk answers the current channel and sends answer supervision.
- The next priority runs Playback(). The caller hears the installed monitoring or recording notice.
- The final priority runs Hangup(). Asterisk disconnects the channel.
| Dialplan stage | Application | Channel state | Result for the caller |
|---|---|---|---|
| Incoming call | Extension selection | Ringing | The caller reaches extension 999, but the call has not yet been answered. |
| Answer | Answer() | Answered | The call is accepted and established-call processing can begin. |
| Playback | Playback(this-call-may-be-monitored-or-recorded) | Answered | The caller hears the informational recording notice. |
| Hangup | Hangup() | Disconnected | The announcement extension ends the call. |
The caller's experience is therefore: incoming ringing call, answer, announcement playback, and disconnect.
Complete Minimal Example
[example-context]
exten => 999,1,Answer()
same => n,Playback(this-call-may-be-monitored-or-recorded)
same => n,Hangup()The first priority answers the channel. The second plays the selected installed sound prompt. The third disconnects the caller after the announcement finishes.
Troubleshooting
The caller hears no expected announcement
Possible causes include an extension that does not reach the Playback() priority, an unavailable or incorrectly named sound prompt, or a call handled in an unintended dialplan context.
- Verify the extension and priority sequence.
- Confirm that the sound resource exists in a supported Asterisk sound format.
- Review dialplan and call logs to confirm that execution reaches Playback().
Media handling is inconsistent
The dialplan may omit Answer(), place it after media-related treatment, or rely on behavior that differs between applications or channel technologies.
- Place Answer() before the introductory Playback() step.
- Test the complete flow with the actual endpoint and trunk configuration.
- Check whether the application being used has special answer or early-media behavior.
The call continues after the announcement
Hangup() may be missing, or later priorities may continue processing the channel.
- Add or verify Hangup() after the final announcement.
- Inspect subsequent priorities and included dialplan contexts.
Important Terms
- Answer(): An application that answers the current ringing channel.
- Channel: A call leg or communications path handled by Asterisk.
- Ringing state: A state in which the destination has not yet answered.
- Answered state: A state indicating that the call has been accepted for established-call processing.
- Answer supervision: Signaling that indicates a call has been answered.
- Playback(): An application that plays an audio prompt or sound file to a channel.
- Hangup(): An application that disconnects the current channel.
Related Dialplan Concepts
For the surrounding concepts, see What Is A Dialplan, Contexts, Extensions, and Priorities. Related application behavior is covered in The Playback Application, The Hangup Application, The Background Application, and The Dial Application.