Get Started with Asterisk
What Can You Do With Asterisk?
Asterisk makes it easy to build communications applications. It started out as the core of an office phone system (PBX) and today powers hundreds of thousands of phone systems around the world. But phone systems are just the beginning. Today, Asterisk powers many communications applications including automatic call distributor, conference bridge, voicemail, unified messaging and more.
Asterisk is an application development framework. To build applications with Asterisk you should have basic understand of Linux/Unix system administration, be familiar with the fundamentals of VoIP and/or legacy telephony, and be comfortable with the basics of script programming.
1. Learning the Basics of Asterisk
Like any development framework, Asterisk has a learning curve. The following training courses and documentation will give you the understanding required to start building communication applications:
- Introductory Video: Watch Say Hello To Asterisk for a 40 minute overview of Asterisk's capabilities, architecture and ecosystem.
- Video Training: Digium offers a 6 hour online video training course called Asterisk Essentials that walks users through the process, step-by-step.
- Instructor Led Training: Digium offers live, instructor led training classes through a global network of training centers. Asterisk Fast Start covers the initial process of installing and configuring an Asterisk system. Asterisk Advanced goes into detail on advanced implementations and techniques.
- Recommended Reading: Digium recommends Asterisk: The Definitive Guide published by O’Reilly. Written by leaders of the Asterisk project, the book covers every aspect of the application. Available in print from Amazon and other booksellers or as a free online book from the Asterisk Documentation Project.
2. Download And Install Asterisk
To get started, you will need to install Asterisk on a Linux server. Asterisk 1.8 will receive full maintenance and support through Asterisk 10 is the latest release with the broadest feature set. A detailed description of Asterisk release timeline for support and maintenance is available on the wiki.
3. Configure Connections
An Asterisk server is not complete until it has phones and/or phone service setup. Asterisk can connect using VoIP technologies, legacy telephony technologies or a combination of the two.
- VoIP Connections & Phones - The Asterisk server connects to your LAN using the computer’s Ethernet connection. It uses VoIP protocols like SIP to communicate with IP phones, VoIP phone service providers and other VoIP servers. To establish VoIP connections, you will need to edit the configuration for the VoIP protocols you wish to use. Asterisk includes support SIP and several other protocols.
- IP phones are telephones that communicate over the LAN and/or WAN using VoIP protocols. When Asterisk is configured as a phone system (PBX or ACD), IP phones register with and communicate through the Asterisk server.
- VoIP service providers bridge VoIP systems to the legacy PSTN. They play the role traditionally handled by "the phone company" in the world of legacy communications. Asterisk communicates with VoIP service providers over the Internet or private TCP/IP networks.
- PSTN Connections & Phones - Connections to legacy telephony services and phones can be done using an interface card or a stand-alone gateway.
- Telephony interface cards are PCI or PCI-Express devices that are installed in card slots on the host computer's motherboard. External jacks on the cards connect phone lines or phones directly to the Asterisk system. Interface cards are commonly used when the Asterisk server is running on a real (non-virtual) server with available card slots. The interface card translates the signaling and media from the legacy format into Asterisk’s native format. Within Asterisk, interface cards are managed using the Digium/Asterisk Hardware Device interface (DAHDi).
- IP media gateways (aka VoIP gateways) are stand-alone devices that translate legacy PSTN signaling and media into network packets which are delivered to Asterisk using VoIP protocols (most commonly SIP). To use a VoIP gateway with Asterisk, first follow the manufacturer's instructions to connect the device with the legacy analog or digital circuits. Then configure it to communicate with Asterisk using the appropriate VoIP protocol.
4. Write Your Application Code
Asterisk includes a number of programming interfaces that allow developers and integrators to control how Asterisk handles call and messages. These interfaces include the Dialplan scripting language, the Asterisk Gateway Interface (AGI), the Asterisk Manager Interface (AMI) and the core C API. Most developers start out using the Dialplan. Complex applications frequently make use of multiple interfaces.
The Asterisk Dialplan is a built-in scripting language that tells Asterisk how to route and process calls. It contains contains hundreds of applications and functions that control call flow, media input and output, messaging and call-related data. The Dialplan language is similar in structure to the BASIC programming language.
Asterisk Gateway Interface (AGI)
The Asterisk Gateway Interface or AGI is a simple bridge protocol that allows developers to create Asterisk applications in virtually any programming language. It exposes a set of functions that can be accessed via either the standard input/output mechanism (aka "stdio") or over a TCP/IP socket.
Asterisk Manager Interface (AMI)
The Asterisk Manager Interface or AMI is an asynchronous socket-based global command and control interface, commonly used for monitoring and management. Where Dialplan and AGI handle individual channels (calls), AMI applications can monitor and manage all the active channels on the system. It can also dynamically allocate new channels for outbound calls.
Core C API
Asterisk itself is written in the C programming language. It is composed of a small base application and a large number of extension modules. C developers can extend Asterisk and add new core functionality by creating new modules. Module interfaces are defined for IO channels, Dialplan applications, Dialplan functions, media codecs, file IO formats and other key resources.
Detailed coverage of Asterisk programming interfaces is available in the previously mentioned Asterisk: The Definitive Guide published by O’Reilly.