Upgrade 3CX to v18 and get it hosted free!

Asterisk manager Example: Command

Author image

Execute an Asterisk CLI command in an Asterisk manager session

The Asterisk CLI is accessible through the manager API. All of the CLI commands can be passed through using the “Command subset” feature. For example,
to dump the current dialplan, send the following:

SEND:

ACTION: Command
command: show dialplan

RECEIVE:

Response: Follows
[ Context ‘MeetMe’ created by ‘pbx_config’ ]
‘s’ => 1. Answer() [pbx_config]
2. Wait(1) [pbx_config]
3. MeetMe(|DM) [pbx_config]

[ Context ‘default’ created by ‘pbx_config’ ]
‘h’ => 1. Goto(Hungup|${extension}|1) [pbx_config]
‘_.’ => 1. SetVar(extension=${EXTEN}) [pbx_config]
2. Macro(dial_agi_ver.1.0.0|${EXTEN}|${channel}) [pbx_config]
‘_mysqluid-.’ => 1. Macro(dial_out_ver.1.0.0|${EXTEN}) [pbx_config]

[ Context ‘parkedcalls’ created by ‘res_features’ ]
‘*8’ => 1. Park() [res_features]

–END COMMAND–

Note: This response here has been severely truncated from the actual response I received, but I decided not to give out my customers’ phone numbers if you don’t mind. This is just to give you an idea of what it does. This is not intended to be a good example of a dialplan, please consult the dialplan examples for that.

Back

Hint

Be careful to use just one Return (\r\n) after “Action” and doublereturn (\r\n\r\n) after “Command”.
Example (in PHP):

fputs($socket, “Action: Command\r\n”);
fputs($socket, “Command: show dialplan\r\n\r\n”);

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.