{"id":20365897,"url":"https://github.com/cycoresystems/node-asterisk-ami","last_synced_at":"2025-04-12T04:51:30.137Z","repository":{"id":148364115,"uuid":"11163443","full_name":"CyCoreSystems/node-asterisk-ami","owner":"CyCoreSystems","description":"Asterisk AMI library for NodeJS","archived":false,"fork":false,"pushed_at":"2014-04-28T20:13:07.000Z","size":244,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-05T17:12:50.337Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CyCoreSystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-03T23:21:32.000Z","updated_at":"2024-10-31T18:13:40.000Z","dependencies_parsed_at":"2023-03-28T06:26:47.026Z","dependency_job_id":null,"html_url":"https://github.com/CyCoreSystems/node-asterisk-ami","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fnode-asterisk-ami","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fnode-asterisk-ami/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fnode-asterisk-ami/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fnode-asterisk-ami/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CyCoreSystems","download_url":"https://codeload.github.com/CyCoreSystems/node-asterisk-ami/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248519473,"owners_count":21117757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T00:20:59.402Z","updated_at":"2025-04-12T04:51:30.104Z","avatar_url":"https://github.com/CyCoreSystems.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"node-asterisk-ami\n=================\n\nAsterisk AMI library for NodeJS\n\nInspired by:\n* [holidayextras/node-asterisk-ami](https://github.com/holidayextras/node-asterisk-ami)\n* [englercj/node-esl](https://github.com/englercj/node-esl)\n\nFeatures\n--------\n\n* AMI-JS parsing:\n   * All AMI messages are parsed and objectified\n   * AMI messages which have duplicate keys will automatically be converted to Arrays\n   * Arrays provided to AMI calls will automatically be converted to multiple keys\n* Two-level callback tracking and queuing:\n   * All Actions are submitted asynchronously to Asterisk\n   * Any callbacks provided treated as \"ACK\" callbacks; they are executed when the associated \"Response\" event is received\n   * Originate actions are always asynchronously called, but there is a 'sync' option which can be passed to only call the callback when the OriginateResponse is received.\n   * Orignate also allows a 'complete' property to be supplied, which will be executed only when the OriginateResponse is received.\n   * AsyncAGI also has two callbacks: for ACK and for completion:\n      * The method callback, if it exists, will be called when Asterisk queues the AGI command.\n      * The `complete` property will be executed when the AGI command has been executed (on the `Exec` SubEvent)\n* Regardless of any special handling above, all AMI messages will be emitted as `message` events on the `Connection` object\n\nBasic Usage\n-----------\n\n```Javascript\nvar AMI = require('node-asterisk-ami');\nvar amiconn = new AMI.Connection({\n   username: 'MyUserName',\n   password: 'MySecretPassword'\n});\namiconn.on('ready',function(){\n   amiconn.originate({\n      Channel: 'SIP/testme',\n      Application: 'AGI',\n      Data: 'agi:async',\n      complete: function(message){\n         if(message.Response == 'Success') {\n            console.log(\"Call is connected\");\n         } else {\n            console.log(\"Call failed: \"+ message.Reason);\n         }\n      }\n   },function(){\n      console.log(\"Originate command received\");\n   });\n});\n```\n\nAMI.Connection `AMI.Connection(options,[callback])`\n-----\n\nAvailable `options`:\n* host: hostname or IP address of Asterisk server (default: 'localhost')\n* port: AMI port of Asterisk server (default: 5038)\n* username:  Asterisk AMI username\n* password:  Asterisk AMI secret\n* debug: (boolean) Increase logging level (default: false)\n* events: (boolean) Listen for AMI events (default: true)\n* reconnectTimeout: Timeout (ms) to reconnect; 0 to disable (default: 5000)\n\nIf provided, the callback will be called when Asterisk reports the connection to be ready\n\n### Methods\n\n#### send `AMI.Connection.send(command)`\n\nLow-level method to send AMI commands directly.  If `command` is a string, no processing will be performed before sending the command to Asterisk.  If `command` is an object, it will be parsed into an AMI-compatable Action before sending.\n\nNote that using `send` directly will bypass all tracking and queuing.  It is up to you to add ActionIDs and CommandIDs as appropriate.\n\n#### action `AMI.Connection.action(action,[args],[cb])`\n\nSend an arbitrary AMI Action to Asterisk.\n\n`action` may be a string or an object.  A string will be used as the value for the `Action` key.  An object is presumed to contain a set of properties which will be converted to key-value pairs for AMI.\n\n`args`, if present, should be an object which will be appended to the `action` object.\n\n`cb`, if present, will be called when Asterisk acknowledges receipt of the Action.\n\nNote that this method will not automatically track Originate and AGI execution.  Please use the `originate` or `agi` methods for that.\n\n#### originate `AMI.Connection.originate(args,[cb])`\n\nSend and track an `Originate` AMI action to Asterisk.\n\nAvailable additional options (include in the `args` object):\n* sync:  (boolean, false) Execute `cb` only on *completion* of the Originate command, rather than acceptance\n* complete: (function) Executed on *completion* of the Originate command\n\n#### agi `AMI.Connection.agi(command,[args],[cb])`\n\nSend and track an AsyncAGI command to Asterisk.\n\n`command` may be a string or an object.  Strings will be used as the value for the `Command` AMI key.\n\n`args`, if present, should be an object which will be appended to the action (not the command; append to `command` any arguments required for that command)\n\n`cb`, if present, will be called when Asterisk acknowledges receipt of the Action.\n\n#### getVar `AMI.Connection.getVar(channel,variable,cb)`\n\nGet the value of the given variable on the given channel.  Calls `cb(err,value)`.\n\n\nEvents\n------\n\nEach of the events are passed with the full, objectified AMI message\n\n* `message`: Emitted on each AMI message\n\n* `response:\u003cActionID\u003e`: Emitted when an AMI response with an associated ActionID is received\n\n* `event:\u003cActionID\u003e`: Emitted when an AMI event with an associated ActionID is received\n\n* `originate:\u003cActionID\u003e`: Emitted when an AMI OriginateReponse event with an associated ActionID is received\n\n* `agi:exec:\u003cCommandID\u003e`: Emitted when an AGI Exec event with an associated CommandID is received\n\n* `agi:start`: Emitted when a new AsyncAGI session is started.  The usual AGI variables will be parsed into an object as the `Env` property of the object passed with this event.\n\n* `agi:end`: Emitted when a new AsyncAGI session is started.\n\nFor more interpreted events, you may also listen on `AGI.Connection.parser` for these additional events:\n* `ami:event` - All AMI Events (message contains an `Event` key)\n* `ami:response` - All AMI Response messages (message contains an `Response` key)\n* `ami:originate` - All AMI Originate Reponse messages (message contains an `OriginateResponse` key)\n* `ami:agi` - All AsyncAGI events\n* `ami:agi:start` - All AsyncAGI events with SubEvent 'Start'\n* `ami:agi:end` - All AsyncAGI events with SubEvent 'End'\n* `ami:agi:command:start` - All AsyncAGI event, SubEvent 'Start' which refer to an AGI Command\n* `ami:agi:command:end` - All AsyncAGI event, SubEvent 'End' which refer to an AGI Command\n* `ami:agi:session:start` - All AsyncAGI event, SubEvent 'Start' which refer to an AGI Session (Env will be parsed to an object as property Env)\n* `ami:agi:session:end` - All AsyncAGI event, SubEvent 'End' which refer to an AGI Session\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycoresystems%2Fnode-asterisk-ami","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcycoresystems%2Fnode-asterisk-ami","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycoresystems%2Fnode-asterisk-ami/lists"}