I have created and open-sourced a Crystal-lang shard (library) that supports all Asterisk PBX interfaces: Asterisk REST Interface (ARI), Asterisk Manager Interface (AMI), and all types of Asterisk Gateway Interface (AGI, FastAGI, AsyncAGI). You can find it on GitHub: ctiapps/asterisk.
Why Another Library?
At the time of development, there were no existing Crystal-lang libraries for VoIP, which prompted me to create this one.
In a recent project, we needed to work with both AMI and ARI concurrently, involving significant asynchronous processing. The initial codebase was Ruby-based; however, there was only a single Ruby gem available for ARI, and Ruby’s asynchronous support was not ideal for our needs.
I am a strong proponent of Crystal-lang. Its Ruby-inspired syntax made the transition smooth (though it’s important to note Crystal is not Ruby; only the syntax shares similarities). Crystal-lang is exceptionally fast, exhibiting no lags or delays. It compiles to a tiny binary, allowing for Docker images of around 20MB with all dependencies packed in. Before settling on Crystal, I also considered Elixir. Golang was another possibility, but I preferred to stay within a more familiar syntactic comfort zone after working with Ruby.
What’s Included?
- Support for all key Asterisk interfaces: ARI, AMI, AGI, FastAGI, and AsyncAGI.
- Comprehensive test specs that run against a live Asterisk PBX instance within Docker. These specs also serve as usage examples for the library. More detailed documentation is forthcoming.
- Official documentation.