Giter VIP home page Giter VIP logo

ami's Introduction

Build Status StyleCI

Enniel\Ami

Easy control via asterisk manager interface (AMI).

Installation and configuration

To install as a composer package to be used with Laravel 5, simply run:

composer require "enniel/ami"

Once it's installed, you can register the service provider in config/app.php in the providers array:

'providers' => [
  \Enniel\Ami\Providers\AmiServiceProvider::class,
]

Then publish assets with php artisan vendor:publish. This will add the file config/ami.php.

Usage

Connection options

You are can specify connection parameters for each command.

Option Description
--host Asterisk AMI server host
--port Asterisk AMI server port
--username Asterisk AMI server username
--secret Asterisk AMI server secret

Listen ami events

php artisan ami:listen
Artisan::call('ami:listen');

If would you like to see event log in the console use monitor option

php artisan ami:listen --monitor

Send ami action

php artisan ami:action <action> --arguments=<key>:<value> --arguments=<key>:<value> ...
Artisan::call('ami:action', [
    'action'      => <action>,
    '--arguments' => [
        <key> => <value>
        ...
    ]
]);

Send sms messages using chan dongle

php artisan ami:dongle:sms <phone> <message> <device?>
Artisan::call('ami:dongle:sms', [
    'phone'   => <phone>,
    'message' => <message>,
    'device'  => <device?>,
]);

For sending long messages use pdu mode.

php artisan ami:dongle:sms <phone> <message> <device?> --pdu
Artisan::call('ami:dongle:sms', [
    'phone'   => <phone>,
    'message' => <message>,
    'device'  => <device?>,
    '--pdu'   => true,
]);

Argument device is not required.

Send ussd commands using chan dongle

php artisan ami:dongle:ussd <device> <ussd>
Artisan::call('ami:dongle:ussd', [
    'device' => <device>,
    'ussd'   => <ussd>,
]);

Send ami commands

This command started cli interface for ami. Command attribute is optional.

php artisan ami:cli [command]

Close cli interface after sending command.

php artisan ami:cli [command] --autoclose
Artisan::call('ami:cli', [
    'command'     => [command],
    '--autoclose' => true,
]);

Without Laravel

php ./vendor/bin/ami ami:listen --host=127.0.0.1 --port=5038 --username=username --secret=secret --monitor

ami's People

Contributors

enniel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ami's Issues

Ami Action Stops ami:listen

When the ami:listen command is running it stops if an ami action is run.

I have found the line $this->stop that follows the response inside the Client method in AmiAction.php

If I comment this line out my ami:listen command keeps running as I need it to. Is there any detrimental effect to doing this please? Is this a bug?

Many thanks

event listen

hi , thank for the package
i have some problems with how to display all events from a controller to my view
when i'm trying i get a Maximum execution time of 30 seconds exceeded error
PS: Sorry for my english

Base events

Add base events: started, closed and etc.

usage examples

Hi, do you have any snippets on how to send action thru this?

Logging

Add logging in the file, if command started not in the console.

composer require "enniel/ami" gives errors

I'm trying to install this pakage on a Laravel 5.6 and i'm encountering some warnings and errors :

  • A lot of "Ambiguous class resolution" warnings
  • the following error :

[ErrorException] file_get_contents(/var/www/totem.fftp/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/vendor/jackkum/phppdu/PDU.php): failed to open stream: No such file or directory

Thank in advance

Events

Hello. How use EventListener for ami.config file?

'events' => [
    'AGIExec' => [
    ],
    'AgentConnect' => [
    ],
    'AgentComplete' => [
    ],
    'Agentlogin' => [
    ],

I tried

    'Agentlogin' => [
            App\Listeners\Test::class
    ],

But not worked

Get response from commands

Hi @enniel, I don't know if I'm doing something wrong or is just an issue.

I'm running the next code:

$algo = Artisan::call('ami:action', [
    'action' => 'ConfbridgeList',
    '--arguments' => [
        'ActionID' => '1',
        'Conference' => $extension
    ]
]);

dd($algo);

If the conference exist $algo equals 0 and if the conference don't exist the program never reach the dd($algo) statement.

Running the command version in the CLI I get the response succes if the conference exists, but when the conference don't exist I get nothing returned :(.

P.D: Sorry for my english, trying to improve ๐Ÿ‘

Laravel 6 support

have you planned to update this package for Laravel 6 compatibility ?

Sugestion!

Awesome work! Congrats!

Add examples like this in docs, it could save a lot of time!

Make a call to "SIP/1001" and send it to context "your-context"

php artisan ami:action Originate --arguments=Channel:SIP/1001 --arguments=Context:your-context --arguments=Exten:s --arguments=Priority:1 --arguments=CallerID:01010101 --arguments=Async:true

Tested on Asterisk 13.1 - Ubuntu 16.04 and works great!

Tks a lot!

Bug In Artisan::call('ami:action')

hi i congratulate you for the ami package

But I found a little bug in it when i use Send ami action with this code it dont send action to asterisk

Artisan::call('ami:action', [
'action' => action,
'--arguments' => [
key => value
...
]
]);

but with this one it send as expected , mind the colon between key and the value

Artisan::call('ami:action', [
'action' => action,
'--arguments' => [
key : value
...
]
]);

Timeout on answer

Thanks to author it is one of good solution I have seen.

During usage we faced to issue with time out.

We using from cli and it is working fine, but during usage from Laraverl controller we faced to timeout on response. We seen our request in Asterisk side (enabled debug in manager,conf)

  == Manager 'komil' logged on from 10.154.30.20
<-- Examining AMI event: -->
Event: SuccessfulAuth
Privilege: security,all
SequenceNumber: 68
File: manager.c
Line: 1854
Func: manager_default_msg_cb
EventTV: 2019-03-20T22:45:31.819+0000
Severity: Informational
Service: AMI
EventVersion: 1
AccountID: komil
SessionID: 0x7f203c000960
LocalAddress: IPV4/TCP/0.0.0.0/5038
RemoteAddress: IPV4/TCP/10.154.30.20/51804
UsingPassword: 0
SessionTV: 2019-03-20T22:45:31.819+0000

Our code on controller:


$result = Artisan::call('ami:cli', [
    		'command'      => 'queue show',
    		'--autoclose' => true,
                                            ]);
        return response()->json($result); 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.