AMI (Asterisk Management Interface) is used for third party applications to work properly with Asterisk (FreePBX). Applications can retrieve updated information about system events via AMI and send some commands to Asterisk.
To use AMI on Asterisk and FreePBX, you need to define a user and password. You can create this in two ways:
- By editing the /etc/asterisk/manager.conf file
- By creating a user with Asterisk Manager in FreePBX.
Let’s examine both methods in more detail.
Creating an AMI User on Asterisk:
- Connect to the Asterisk server via SSH.
- Open the /etc/asterisk/manager.conf file with an editor.
- Enter the AMI settings in the [general] section:
[general] enabled = yes port = 5038 bindaddr = 0.0.0.0 displayconnects = no
- Create a new user under the [general] section:
[amiuser] secret = 123456 deny = 0.0.0.0/0.0.0.0 permit = 192.168.0.0/255.255.255.0 read = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate,message write = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate,message writetimeout = 5000
Note: In this example, the username is amiuser and the password is 123456. It only accepts requests from the 192.168.0.0/24 network, but all access is read and write.
- Save and close the file.
- Reinstall the Asterisk Manager module:
asterisk -rx "manager reload"
Creating AMI User on FreePBX:
- Click Settings in the top navigation bar and then Asterisk Manager Users:
2. Click the Add Manager button to add a new user.
3. Here you can see the settings window for a new user. Complete the relevant fields here:
- Manager Name: Enter the AMI Username (no spaces).
- Manager Secret: Enter the password for the AMI User.
- Deny: Here you can specify the IP address and subnet mask that you want to restrict connection with AMI. You can use the “&” symbol to specify multiple networks, eg 192.168.1.0/255.255.255.0&192.168.2.0/255.255.255.0
- Permit: Specify the network or unique IP address to which you allow AMI connection.
- Write Timeout: Enter the timeout period for the execution of the AMI command.
- Set access permissions using the Permissions tab.
5. Click the Submit button at the bottom right to save the settings and then click Apply Config appears at the top left to complete the process.