2 var util = require('util');
3 var Process = require('./process');
5 module.exports = function(ami) {
7 console.log('Autodialer Starting...');
8 var proc = new Process();
10 proc.getProcesses(function(res, err) {
16 // console.log(res.Contacts);
17 // if (util.isArray(res.Contacts))
19 // var contact = res.Contacts;
20 // console.log(contact);
24 // var contacts = res.Contacts;
25 // if (contacts.length)
27 // contacts.forEach(function(contact) {
28 // console.log(contact);
39 // var _ = require('lodash');
41 // var agents = ['SIP/massimiliano.bungaro', 'SIP/daniele.cinti'];
44 // var contacts = ['600', '600', '600'];
48 // function coreshow() {
50 // if (contacts.length > 0) {
52 // action: 'CoreShowChannels'
53 // }, function(err, res) {
63 // function peerstatus() {
65 // if (contacts.length > 0) {
67 // action: 'SIPpeerstatus'
68 // }, function(err, res) {
77 // module.exports = function(asterisk_manager) {
79 // ami = asterisk_manager;
83 // ami.on('peerstatus', function(evt) {
84 // if (evt.peerstatus == 'Reachable') {
85 // peers.push(evt.peer);
89 // ami.on('coreshowchannel', function(evt) {
90 // channels.push(evt.channel.split('-')[0]);
93 // ami.on('sippeerstatuscomplete', function(evt) {
97 // ami.on('coreshowchannelscomplete', function(evt) {
98 // console.log('Agents registered ', peers);
99 // console.log('Agents in call ', channels);
102 // var agent = _.find(agents, function(agent) {
103 // return !_.includes(channels, agent);
107 // if (_.includes(peers, agent)) {
109 // action: 'originate',
111 // exten: contacts.pop(),
115 // }, function(err, res) {