numminorihsf / ami-io Goto Github PK
View Code? Open in Web Editor NEWUse node.js or io.js to manage Asterisk through AMI
License: MIT License
Use node.js or io.js to manage Asterisk through AMI
License: MIT License
Code:
client.on('connected', function(){
client.logger.info('Connected');
client.send(new AmiIo.Action.Queues(), function(err, data){
if (err){
//in current time - may be without error. need test
//err === null if ami response match(/success/i), else response will pass as error
}
client.logger.info('response:', err, data);
});
});
Console:
Send: { variables: {}, id: 2, ActionID: 2, Action: 'Queues' }
Data: QUEUE1 has 0 calls (max unlimited) in 'ringall' strategy (2s holdtime, 4s talktime), W:0, C:2, A:3, SL:100.0% within 60s
Members:
111 (Local/222@from-internal/n from Local/111@from-internal/n) with penalty 2 (ringinuse disabled) (realtime) (paused) (Not in use) has taken no calls yet
222 (Local/111@from-internal/n from Local/222@from-internal/n) with penalty 3 (ringinuse disabled) (realtime) (Not in use) has taken 2 calls (last was 14 secs ago)
No Callers
QUEUE2 has 0 calls (max unlimited) in 'ringall' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s
No Members
No Callers
Message:QUEUE1 has 0 calls (max unlimited) in 'ringall' strategy (2s holdtime, 4s talktime), W:0, C:2, A:3, SL:100.0% within 60s
Members:
111 (Local/222@from-internal/n from Local/111@from-internal/n) with penalty 2 (ringinuse disabled) (realtime) (paused) (Not in use) has taken no calls yet
222 (Local/111@from-internal/n from Local/222@from-internal/n) with penalty 3 (ringinuse disabled) (realtime) (Not in use) has taken 2 calls (last was 14 secs ago)
No Callers
Unexpected:
<< QUEUE1 has 0 calls (max unlimited) in 'ringall' strategy (2s holdtime, 4s talktime), W:0, C:2, A:3, SL:100.0% within 60s
Members:
111 (Local/222@from-internal/n from Local/111@from-internal/n) with penalty 2 (ringinuse disabled) (realtime) (paused) (Not in use) has taken no calls yet
222 (Local/111@from-internal/n from Local/222@from-internal/n) with penalty 3 (ringinuse disabled) (realtime) (Not in use) has taken 2 calls (last was 14 secs ago)
No Callers >>
Message: QUEUE2 has 0 calls (max unlimited) in 'ringall' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s
No Members
No Callers
Unexpected:
<< QUEUE2 has 0 calls (max unlimited) in 'ringall' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s
No Members
No Callers >>
When I make action, after the conclusion of the action and after many seconds, I aways receive a message error from ami-io.
Error: ERRTIMEDOUT at Client.<anonymous> (/home/ipcom/movidesk/node_modules/ami-io/lib/index.js:300:82) at listOnTimeout (internal/timers.js:554:17) at processTimers (internal/timers.js:497:7)
Why this error happens?
Result message from ami-io
{
"variables":{},
"event":"Bridge",
"privilege":"call,all",
"timestamp":1469112499000,
"bridgestate":"Unlink",
"bridgetype":"core",
"channel1":"SIP/with-TSE-LIM2-0000a194",
"channel2":"Local/5842@from-queue-0000af99;1",
"uniqueid1":"1469111531.131272",
"uniqueid2":"1469111552.131275",
"callerid1":"4959810606",
"callerid2":"5836",
"chanvariable(sip/with_tse_lim2_0000a194)":"CDR(dst)=5899",
"chanvariable(local/5842@from_queue_0000af99;1)":"CDR(dst)=5842"
}
Incomming event from server
"incomingData":[
"Event: Bridge",
"Privilege: call,all",
"Timestamp: 1469112499.321389",
"Bridgestate: Unlink",
"Bridgetype: core",
"Channel1: SIP/with-TSE-LIM2-0000a194",
"Channel2: Local/5842@from-queue-0000af99;1",
"Uniqueid1: 1469111531.131272",
"Uniqueid2: 1469111552.131275",
"CallerID1: 4959810606",
"CallerID2: 5836",
"ChanVariable(SIP/with-TSE-LIM2-0000a194): CDR(linkedid)=1469111531.131272",
"ChanVariable(SIP/with-TSE-LIM2-0000a194): CDR(dst)=5899",
"ChanVariable(Local/5842@from-queue-0000af99;1): CDR(linkedid)=1469111531.131272",
"ChanVariable(Local/5842@from-queue-0000af99;1): CDR(dst)=5842"]
In this case REAL message from ami-io must have view:
"variables":{},
"event":"Bridge",
"privilege":"call,all",
"timestamp":1469112499000,
"bridgestate":"Unlink",
"bridgetype":"core",
"channel1":"SIP/with-TSE-LIM2-0000a194",
"channel2":"Local/5842@from-queue-0000af99;1",
"uniqueid1":"1469111531.131272",
"uniqueid2":"1469111552.131275",
"callerid1":"4959810606",
"callerid2":"5836",
"chanvariable(sip/with_tse_lim2_0000a194)": [
"CDR(linkedid)=1469111531.131272",
"CDR(dst)=5899"
],
"chanvariable(local/5842@from_queue_0000af99;1)": [
"CDR(linkedid)=1469111531.131272",
"CDR(dst)=5842"
],
this type of variaables using in different asterisk event and must be parsed everywhere.
Also see this stackoverflow question: I've already succeeded in overloading the auth function, how can I overload the Login action (or create a new one), and in general create new Actions and Events?
I do not want to fork the original package for a few lines of code changes.
throws error on event === undefined
Description:
Context: Currently, the ami
library supports a variety of Asterisk events through the Manager interface. However, with recent updates to Asterisk to newer versions, new events have been introduced, especially related to the PJSIP protocol.
Proposal: This issue aims to add support for the new Asterisk events, with a special focus on events related to PJSIP. Some of the events we would like to include are:
PJSIPShowRegistrationsInbound
PJSIPShowRegistrationsOutbound
PJSIPShowEndpoints
PJSIPShowEndpointStatus
Proposed Steps:
ami
library to recognize and process the new events properly.Notes: This is a significant contribution that will benefit users of the ami
library, enabling them to leverage the latest features of Asterisk. We appreciate in advance the community and project maintainers' review and feedback.
6.2.0
to 6.2.1
.π¨ View failing branch.
This version is covered by your current version range and after updating it in your project the build failed.
mocha is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 11 commits.
ef6c820
Release v6.2.1
9524978
updated CHANGELOG for v6.2.1 [ci skip]
dfdb8b3
Update yargs to v13.3.0 (#3986)
18ad1c1
treat '--require esm' as Node option (#3983)
fcffd5a
Update yargs-unparser to v1.6.0 (#3984)
ad4860e
Remove extraGlobals() (#3970)
b269ad0
Clarify effect of .skip() (#3947)
1e6cf3b
Add Matomo to website (#3765)
91b3a54
fix style on mochajs.org (#3886)
0e9d8ad
tty.getWindowSize is not a function inside a "worker_threads" worker (#3955)
48da42e
Remove jsdoc index.html placeholder from eleventy file structure and fix broken link in jsdoc tutorial (#3966)
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
Hi I'm trying to turn off the logger. I tried ami.useLogger but this doesn't seem to work.
Please if you can give me any advice on this it would be much appreciated, I would like to do all the logging myself, right now everything just gets printed to the console and I can't see anything because it's too busy.
Thanks.
hi. i have a question. can i use this package in vuejs?
Hello! You setted encoding for socket object to 'ascii'. But I need to set it to 'utf8'. How can I do it?
Line 108 in 26cd6f9
Hi,
I'm trying to use this library in my Angular 7 project.
Unfortunately I've a compiling error:
ERROR in ./node_modules/ami-io/index.js
Module not found: Error: Can't resolve 'fs' in 'C:\Users\Daniele\Documents\workspaceAngularJS\optix\node_modules\ami-io'
Is there a way to make it work with Angular?
Thanks
Hi,
I have this code:
const AmiIo = require("ami-io"),
SilentLogger = new AmiIo.SilentLogger(), //use SilentLogger if you just want remove logs
amiio = AmiIo.createClient({port:PORT, host:SERVER, login:USER, password:PASSWD,logger: SilentLogger});
const action = new amiio.Action.Originate();
action.Channel = 'sip/123';
action.Context = 'default';
action.Exten = '456';
action.Priority = 1;
action.Async = true;
action.WaitEvent = true;
amiio.send(action, function(err, data){
if (err){
//err will be event like OriginateResponse if (#response !== 'Success')
}
else {
//data is event like OriginateResponse if (#response === 'Success')
}
});
On phpStorm I'm getting "unresolved type Originate". If I look into amiio.Action symbols it founds 2 declarations:
On node console I see this :
TypeError: Cannot read property 'Originate' of undefined
any help?
Hi,
First of all I would like to thank you for your contribution.
I'm trying to use Originate action with multiple Variables but only the last Variable has been sent to asterisk. Please find below a sample.
var action = new AmiIo.Action.Originate();
action.MaxRetries = 2;
action.RetryTime = 60;
action.WaitTime = 30;
action.Priority = 1;
action.CallerID = 'Test <9000>';
action.Channel = 'local/9001@test/n';
action.Context = 'Autodial';
action.Exten = '9001';
action.Variable = 'Hostname="test hostname"';
action.Variable = 'Description="test description"';
action.Async = true;
action.WaitEvent = true;
Note the result only has the last Variable;
Send: Originate {
variables: {},
id: 2,
ActionID: 2,
Action: 'Originate',
MaxRetries: 2,
RetryTime: 60,
WaitTime: 30,
Priority: 1,
CallerID: 'Vicci <9000>',
Channel: 'local/9001@test/n',
Context: 'Autodial',
Exten: '9001',
Variable: 'Description="test description"',
Async: true,
WaitEvent: true }
Could you please verify?
Thanks,
Orlando
Hi,
I want to print log info only when some events happen like this:
if ( event.event === 'Hangup') {
console.log("Hangup");
amiio.logger.info('event:', event);
}
But is printing everything all the time... any help?
Having a problem where I tried to send a MuteAudio action to the AMI but fails with:
TypeError: amiio.Action.Muteaudio is not a constructor
The line that fails:
var action = new amiio.Action.MuteAudio();
Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.