Separate inventory, identity and action
Begin with the question being answered: which channels were visible at one observation time, whether one exact channel still exists, which call or bridge it belongs to, or whether an authorized operation reached the intended leg. Those are different evidence.
CHANNELS() supplies a space-delimited list of known channel names and can filter that list with a POSIX.2 regular expression. CHANNEL_EXISTS(name_or_uid) returns whether one channel name or unique ID exists at that instant. Neither result proves the channel will remain present, is the intended leg, is bridged, carries media or will accept a later operation.
Keep names, Uniqueid and Linkedid distinct
A channel name identifies a live channel object and includes driver-specific material. The built-in CHANNEL variable exposes the current channel name, while UNIQUEID identifies the current channel. Linkedid is a call-correlation value shared across related legs; it is not a substitute for the unique identity of the one leg an operation will target.
Record the exact name, Uniqueid, Linkedid, creation or observation time and current application together. A familiar endpoint label or matching Linkedid can still describe the wrong leg.
Treat CHANNELS output as an ephemeral snapshot
Capture the full unfiltered list first when authorized, then apply the narrowest anchored expression needed for classification. Preserve the expression and timestamp. Because calls create, rename, optimize and destroy channels while the list is being read, a result is a point-in-time inventory rather than a transaction or lock.
Do not split a channel name on punctuation and infer identity from fragments. Use the whole returned token and correlate it with the same-time CLI, AMI or event evidence.
Account for Local-channel optimization and renames
Local channels begin as paired legs and, by default, can optimize out after the destination answers. The documented optimization removes the Local channel and its channel-specific information from the path; /n deliberately retains it when the dialplan requires that behavior.
A Local name that disappears can therefore be expected lifecycle evidence rather than a failed call. Prove the surviving endpoint channel, bridge membership and correlated identifiers before deciding that a leg was lost.
Revalidate immediately before an authorized operation
Discovery and action are separated by time. Recheck the exact name or unique ID, call correlation, state and application immediately before a redirect, requested hangup or other authorized control operation. Broad expressions, endpoint labels and an old inventory are unsafe selectors for destructive work.
The CLI documentation says a requested hangup takes effect when the driver next reads or writes; acknowledgement is therefore not proof that the channel has already gone. Observe the resulting lifecycle separately.
Use correlated snapshots and events for diagnosis
AMI CoreShowChannels returns currently defined channels as an event list associated with the request ActionID. Preserve the ActionID, every channel event and the completion boundary. Compare that bounded response with lifecycle events and the CLI from the same node and time window.
For an authorized staging call, capture successive snapshots before creation, during ringing, after answer, after Local optimization and after hangup. No PBX, module, dialplan, channel, bridge, manager session, packet, media stream or live call was inspected or tested; this guide is documentation-derived.
Resolve a channel immediately before Getvar or Setvar
The AMI variable diagnostic checks live channel name, Uniqueid and Linkedid before interpreting a blank result.
Correlate endpoint active-channel counts at one boundary
The AMI endpoint inventory guide keeps a timestamped ActiveChannels count separate from channel identity and lifetime evidence.
Revalidate channel identity before PJSIPHangup
The AMI PJSIPHangup guide uses channel name and Uniqueid together before a destructive action.
Bind signalling control to live channel identity
The AMI DTMF, MF and hook-flash guide records Channel, Uniqueid, Linkedid, bridge membership and direction before control input.
Attach lifetime limits to an exact Uniqueid
The AMI AbsoluteTimeout guide binds the channel name, Uniqueid, Linkedid, creation time and bridge membership before setting a timer.
Bind stream muting to the current Uniqueid
The AMI MuteAudio guide rejects caller ID, endpoint labels and stale channel names as control targets.
Bind playback control to the current channel lifetime
The AMI ControlPlayback guide requires a fresh Channel and Uniqueid plus the current playback application.
Bind a legacy monitor session to one channel lifetime
The legacy Monitor guide treats rename, pause, resume and stop as channel-scoped transitions rather than call-wide controls.
Bind a Hangup request to one current Uniqueid
The AMI Hangup guide rejects caller labels and stale channel names as termination targets.
Bind in-call text to one current channel lifetime
The AMI SendText guide requires the exact Channel and Uniqueid rather than a caller or endpoint label.
Resolve the exact live leg before AOCMessage
The AMI AOCMessage guide rejects Linkedid and caller ID as exact action targets.
Sources & applicability
Primary references for the technical details above. Operational examples and planning checklists are VoIP.info editorial guidance.
- Asterisk CHANNEL_EXISTS dialplan function ↗
- Asterisk CHANNELS dialplan function ↗
- Asterisk CHANNEL dialplan function ↗
- Asterisk CLI channel creation and manipulation ↗
- Asterisk Local channel optimization ↗
- Asterisk AMI CoreShowChannels action ↗
- Asterisk AMI CoreShowChannel event ↗
- Asterisk func_channel implementation ↗
- Asterisk 23 AMI Getvar action ↗
- Asterisk 23 AMI Setvar action ↗
- Asterisk 23 AMI VarSet event ↗
- Asterisk channel-variable setting and substitution ↗
- Asterisk channel-variable inheritance ↗
- Asterisk global-variable basics ↗
- Asterisk 23 SHARED dialplan function ↗
- Asterisk external-protocol dialplan-function safeguards ↗
- Asterisk AMI event filtering ↗
- Asterisk 23 PJSIPShowEndpoints action ↗
- Asterisk 23 PJSIPShowEndpoint action ↗
- Asterisk 23 EndpointList event ↗
- Asterisk 23 EndpointListComplete event ↗
- Asterisk 23 EndpointDetail event ↗
- Asterisk 23 EndpointDetailComplete event ↗
- Asterisk PJSIP configuration sections and relationships ↗
- Asterisk 23 res_pjsip configuration reference ↗
- Asterisk AMI v2 specification ↗
- ↗
- ↗
- ↗
- ↗
- ↗
- ↗
- ↗
- ↗
- Asterisk 23 PlayDTMF action ↗
- Asterisk 23 PlayMF action ↗
- Asterisk 23 SendFlash action ↗
- Asterisk 22 PlayDTMF action ↗
- Asterisk 22 PlayMF action ↗
- Asterisk 22 SendFlash action ↗
- Asterisk 23 DTMFBegin event ↗
- Asterisk 23 AbsoluteTimeout action ↗
- Asterisk 22 AbsoluteTimeout action ↗
- Certified Asterisk 22.8 AbsoluteTimeout action ↗
- Asterisk 23 TIMEOUT dialplan function ↗
- Asterisk special dialplan extensions ↗
- Asterisk 23 MuteAudio action ↗
- Asterisk 22 MuteAudio action ↗
- Certified Asterisk 22.8 MuteAudio action ↗
- Asterisk 23 MUTEAUDIO dialplan function ↗
- Asterisk 23 MixMonitorMute action ↗
- Asterisk 23 ConfbridgeMute action ↗
- Asterisk Manager TCP/IP API ↗
- Asterisk 23 ControlPlayback AMI action ↗
- Asterisk 22 ControlPlayback AMI action ↗
- Certified Asterisk 22.8 ControlPlayback AMI action ↗
- Asterisk 23 ControlPlayback dialplan application ↗
- Asterisk 22 ControlPlayback dialplan application ↗
- Asterisk 23 CONTROL STREAM FILE AGI command ↗
- Certified Asterisk 22.8 Playback application ↗
- Asterisk 20 Monitor AMI action ↗
- Asterisk 20 ChangeMonitor AMI action ↗
- Asterisk 20 PauseMonitor AMI action ↗
- Asterisk 20 UnpauseMonitor AMI action ↗
- Asterisk 20 StopMonitor AMI action ↗
- Asterisk 20 Monitor dialplan application ↗
- Asterisk 21 removals ↗
- Asterisk 23 MixMonitor AMI action ↗
- Asterisk 23 StopMixMonitor AMI action ↗
- Asterisk 22 Hangup AMI action ↗
- Certified Asterisk 22.8 Hangup AMI action ↗
- Asterisk 22 HANGUPCAUSE dialplan function ↗
- Asterisk 23 SendText AMI action ↗
- Asterisk 22 SendText AMI action ↗
- Certified Asterisk 22.8 SendText AMI action ↗
- Asterisk 23 SendText dialplan application ↗
- Asterisk 23 ReceiveText dialplan application ↗
- Asterisk 23 MessageSend AMI action ↗
- Asterisk 23 MessageSend dialplan application ↗
- Asterisk 23 AOCMessage AMI action ↗
- Asterisk 22 AOCMessage AMI action ↗
- Certified Asterisk 22.8 AOCMessage AMI action ↗
- Asterisk 23 AOC-S AMI event ↗
- Asterisk 23 AOC-D AMI event ↗
- Asterisk 23 AOC-E AMI event ↗
- Asterisk 22 AOC-S AMI event ↗
- Asterisk 22 AOC-D AMI event ↗
- Asterisk 22 AOC-E AMI event ↗
Examples require adaptation to your topology. No live PBX or hardware testing is claimed.