How to Make a Call from Asterisk: The Complete Guide (CLI, Call Files, AMI)

How to Make a Call from Asterisk

Table of Contents

In the world of VoIP administration, one of the most fundamental yet misunderstood concepts is how to generate a call from Asterisk directly.

Usually, a phone system waits for a user to pick up a handset and dial. But what if you need the server to initiate the call? Whether you are testing a new route, building an automated wake-up service, or integrating a “Click-to-Call” button in your CRM, you need to understand the art of Call Origination.

In this guide, we will explore the three standard methods to generate an asterisk phone call without lifting a physical receiver: the Command Line Interface (CLI), Automated Call Files, and the Asterisk Manager Interface (AMI).

Note: While these manual methods offer granular control, they introduce significant operational overhead and ‘Technical Debt’ for growing businesses. HAPBX (High Availability PBX) eliminates this complexity by wrapping the Asterisk engine in a professional, managed cloud chassis, ensuring your call origination is always stable, secure, and ready for enterprise-scale integration.

Understanding How to Originate a Call from Asterisk

Before typing commands, it is crucial to understand the terminology. In the Asterisk ecosystem, you don’t just “dial” from the server; you originate a call.

Origination works by bridging two channels.

  1. Leg A (The Source): Asterisk dials this channel first (e.g., your desk phone or a softphone).
  2. Leg B (The Destination): Once Leg A answers, Asterisk dials this channel (e.g., the customer’s external number) and connects the two.

This logic powers everything from simple test calls to complex predictive dialers. Below are the three ways to execute this.

Method 1: Initiating a Call from the Asterisk CLI (Command Line)

The quickest way to execute a call from Asterisk  for testing or debugging is via the Asterisk Command Line Interface (CLI). This method is manual and temporary—perfect for troubleshooting one-way audio or verifying that your SIP trunk is working.

Prerequisites

  • Root access to the Linux server (ensure you have completed your Asterisk PBX software download and installation).
  • A registered endpoint (preferably PJSIP, as chan_sip is deprecated in 2025).

The Command Syntax

To originate a call, log in to the Asterisk console (asterisk -rvvv) and use the following syntax (code Bash):

   channel originate <Tech/Resource> extension <Ext>@<Context>

  • Tech/Resource: The device you want to ring first (e.g., PJSIP/100).
  • Extension/Context: Where to send the call once the first device answers.

Practical Example (PJSIP)

Let’s say you are sitting at extension 100 and you want to test a call to an external number 555-1234 located in the from-internal context.

Run this command in the CLI (code Bash):

   channel originate PJSIP/100 extension 5551234@from-internal

What happens next?

  1. Your phone (Extension 100) will ring immediately.
  2. When you pick up, Asterisk will immediately dial 555-1234 using your outbound routing rules.
  3. The two parties are bridged.

Pro Tip: If you want to play a sound file instead of connecting to another number (useful for testing audio quality), use the application parameter (code Bash):

   channel originate PJSIP/100 application Playback demo-congrats

 

Method 2: Using Asterisk Call Files (Automated Dialing)

The CLI is great for humans, but what if you want a script to initiate a call from Asterisk automatically? This is where Asterisk call files come in.

A call file is a simple text file that contains instructions on who to call and what to do. Asterisk constantly monitors a specific directory on your Linux server (/var/spool/asterisk/outgoing/). The moment a file appears there, Asterisk reads it, deletes it, and processes the call.

Step 1: Create the Call File

Create a file named callback.call in a temporary directory (e.g., /tmp).

File Content (/tmp/callback.call): (code Ini)

   Channel: PJSIP/100

Context: from-internal

Extension: 8005551234

Priority: 1

CallerID: “Auto Dialer” <5550000>

MaxRetries: 2

RetryTime: 60

WaitTime: 30

Step 2: Move the File to the Spool Directory

Crucial Warning: You must never create or edit a file directly in the spool directory. Asterisk might try to read the file before you finish writing it, causing a crash or failed call.

Always create it elsewhere, then move (mv) it. The move command is an atomic operation in Linux, ensuring Asterisk sees the complete file at once. (code Bash)

 

   # Set the correct permissions (Asterisk user must own it)

chown asterisk:asterisk /tmp/callback.call

chmod 660 /tmp/callback.call

 

# Move the file to trigger the call

mv /tmp/callback.call /var/spool/asterisk/outgoing/

 

As soon as you hit enter on the mv command, the call will begin. This method is incredibly reliable for simple tasks like wake-up calls, appointment reminders, or emergency alerts.

Method 3: AMI Originate (Asterisk Manager Interface)

For developers building sophisticated software—like a CRM that dials a customer when you click a phone number—Call Files are too slow. You need a real-time socket connection. This is the Asterisk Manager Interface (AMI).

AMI allows external software to connect to port 5038 via TCP and issue commands.

The Setup

First, ensure you have a user configured in /etc/asterisk/manager.conf (code Ini):

   [admin]

secret = secure_password

deny = 0.0.0.0/0.0.0.0

permit = 127.0.0.1/255.255.255.0

read = all

write = all

Sending the Action

You can test this using telnet or netcat. Once connected, send the following packet to generate a call (code Yaml):

   Action: Originate

Channel: PJSIP/101

Exten: 18005551234

Context: from-internal

Priority: 1

CallerID: “Sales Team” <101>

Async: true

 

*Async: true: This tells Asterisk not to wait for the call to finish before accepting new commands. This is essential for high-volume applications.

The reliance on persistent TCP connections makes AMI fragile in unstable network environments. If your connection drops, your CRM integration fails. HAPBX resolves this by replacing legacy AMI with robust, stateless REST APIs, allowing your developers to trigger calls via standard Webhooks that are more resilient and easier to maintain than raw socket programming.

Why Did I Receive a Call from “Asterisk”?

We often see searches for call from asterisk coming not from developers, but from confused phone users asking: “Why is my Caller ID showing ‘Asterisk’?”

If you received a call with the name “Asterisk,” it usually means the person calling you is using a default, unconfigured PBX system. By default, the callerid string in many configuration files is set to “asterisk”.

Is it Spam?

Often, yes. Scammers frequently spin up cheap cloud servers, install the software, and forget to change the Caller ID configuration. However, it can also be a legitimate small business that simply hasn’t configured their outbound routes correctly.

How to Fix This (For Admins):
To ensure your calls look professional, always define a valid Caller ID in your pjsip.conf endpoint or your trunk settings (code Ini):

   callerid=”My Business Name” <2125551234>

Troubleshooting Failed Calls (Common Errors)

Even for experienced engineers, originating calls can fail. Here are the most common reasons why your attempt to make a call from Asterisk might fail to connect.

1. “No such channel”

  • Cause: You are trying to dial a legacy SIP channel (e.g., SIP/100) on a system running modern PJSIP.
  • Fix: Check pjsip show endpoints in the CLI and ensure you use the correct technology prefix (PJSIP/100).

2. “Permission Denied” (Call Files)

  • Cause: You moved the file to /var/spool/asterisk/outgoing/, but it was owned by the root user. The asterisk user cannot read or delete it, so the file sits there ignored.
  • Fix: Always run chown asterisk:asterisk filename before moving the file.

3. “Extension not found in context”

  • Cause: Your CLI command or AMI packet specified a context (e.g., from-internal) that doesn’t contain the extension you are trying to dial.
  • Fix: Verify your dialplan logic in extensions.conf to ensure the target extension exists in the specified context.

The Easy Way: HAPBX Click-to-Call & API

The troubleshooting steps above highlight why self-hosting can be a full-time job. In contrast, HAPBX is engineered to be ‘error-proof.’ 

Our Dedicated Instances handle permissions, context validation, and channel drivers automatically, so your IT team spends zero time debugging Linux errors and 100% of their time focused on business growth.

Why should you switch to HAPBX?

  1. No Linux Scripting Required

HAPBX provides a ready-to-use REST API. Instead of managing raw TCP sockets with AMI, developers can trigger calls using standard Webhooks. This makes integrating “Click-to-Call” into Salesforce, Zoho, or your custom web app instant and error-free.

  1. Visual Dialing

For non-technical users, HAPBX offers a visual dashboard. You don’t need the command line to test a call; you simply click the phone icon next to a contact’s name, and the system connects you instantly.

  1. High Availability (Zero Failed Calls)

When you use a self-hosted Asterisk server to originate calls, a server crash means your automated dialer stops. HAPBX runs on a Global Cluster Infrastructure with Dedicated Instances. Even if a hardware node fails, your automated calls and API requests continue to process without interruption.

  1. Security Built-In

Opening port 5038 for AMI is a major security risk if not firewalled correctly. HAPBX secures your instance behind a Private IP and enterprise-grade firewall, ensuring that only authorized applications can trigger calls.

Conclusion

Generating a call from Asterisk is a core skill for any VoIP administrator.

  • Use the CLI when you need to troubleshoot a connection quickly.
  • Use Call Files for simple, fire-and-forget automation tasks like wake-up calls.
  • Use AMI if you are a developer building a custom integration.

However, if your goal is to run a business rather than manage a server, the complexity of these methods can become a liability.

HAPBX offers the perfect balance: the raw power of the Asterisk engine combined with the ease of modern cloud APIs and the reliability of High Availability.

Stop fighting the command line.

Stop fighting the Command Line and risking your business continuity on manual scripts. HAPBX offers the ultimate evolution of Asterisk: a high-performance, dedicated cloud environment that guarantees Zero Failed Calls through Global Cluster technology. Secure your communication future with HAPBX, start your free trial today! 

0
Would love your thoughts, please comment.x
()
x