This gem add support to your Ruby or RubyOnRails projects to Asterisk Manager Interface
There was a project with the same name, but it appears to be discontinued so I decided to start a new project
Add to your Gemfile and run the bundle
command to install it.
gem "ruby-asterisk"
Simply run in your terminal
gem install ruby-asterisk
To create a new AMI session, just call the following command
@ami = RubyAsterisk::AMI.new("192.168.1.1",5038)
To log in, provide to the created sessions a valid username and password
@ami.login("mark","mysecret")
Like all commands, it will return a Response command that could be parsed accordingly
To get a list of all channels currently active on your Asterisk installation, use the following command
@ami.core_show_channels
To get a list of all parked calls on your Asterisk PBX, use the following command
@ami.parked_calls
To start a new call use the following command
@ami.originate("SIP/9100","OUTGOING","123456","1","var1=12,var2=99") # CALLER, CONTEXT, CALLEE, PRIORITY, VARIABLE
To execute a cli command use the following code
@ami.command("core show channels")
To get a list of all active conferences use the following command
@ami.meet_me_list
To get the state of an extension use the following command
@ami.extension_state(@exten,@context)
The response object contains all information about all data received from Asterisk. Here follows a list of all object's properties:
- type
- success
- action_id
- message
- data
The data property contains all additional information obtained from Asterisk, like for example the list of active channels after a "core show channels" command.
Questions or problems? Please post them on the issue tracker. You can contribute changes by forking the project and submitting a pull request. You can ensure the tests passing by running bundle
and rake
.
This gem is created by Emiliano Della Casa and is under the MIT License and it is distributed by courtesy of Engim srl.