Send notifications when you insert to MySQL from Asterisk

1

I would like to know how to send a notification after having made an insert in MySQL. We have a system that uses Asterisk to register phone calls from our Call Center. The issue is that using Nodejs and Socketio we want to notify of the insertions as a report to a specific user.

Any ideas?

    
asked by Ricky 26.10.2016 в 17:12
source

3 answers

1

I have done it in the following way, I hope you can adapt it with Nodejs.

You must use:

1- Trigger in MySQL, Trigger is a trigger that is executed every time something happens in a table either by inserting, updating or deleting records, taking advantage of this property of MySQL then you create a trigger so that each time a record in the table that is of interest you also create a record in a new table with the fields you want including date and time, for example the following code creates a trigger that is triggered each time a record is updated in the table employees creating another record in the employees_audit table

DELIMITER $$
CREATE TRIGGER before_employee_update 
BEFORE UPDATE ON employees
FOR EACH ROW 
BEGIN
INSERT INTO employees_audit
SET action = 'update',
 employeeNumber = OLD.employeeNumber,
    lastname = OLD.lastname,
    changedat = NOW(); 
END$$
DELIMITER ;

2- To notify the user that there was an insert you can use Nodej, PHP or some similar language, I recommend something simple like creating an HTML page that is always open to the user and through AJAX update itself, if you do not know AJAX then places a button on the page for the user to refresh manually.

3- If you want something more advanced you can link Nodej (if you allow it) or PHP with Asterisk AGI (Asterisk Gateway Interface) the AGI communicates with other programming languages so that you can use all the telephone potential of Asterisk either by notifying to IP telephones or generating calls, about AGI you will find all the information and examples in link .

Greetings

    
answered by 12.04.2017 в 16:38
1

Hello to get CDR events using nodejs you should effectively use a library of the many that they already provide.

You can check in the following repository I have the use of one of these libraries: link , in this case I use asterisk.io.

The official documentation of the asterisk also indicates how to capture the event with AMI give a revised to the wiki.asterisk.org "Asterisk -  ManagerEvent_CDR "

Other of the libraries I recommend is asterisk-manager, with this you can also capture the Events with nodejs.

    
answered by 12.08.2017 в 20:28
0

1.- nodejs: there is a library in which you connect to ami, and there you can see the flow of the whole call, since it enters, what variables it brings, who answers it, if it is in a queue, everything you can see, there you could launch your notification you need.

[ link

2 .- agi, this is a bit limited, you have to find out at what time you want the notification when the user answers or when it culega, then you launch an agi, as I said user20930

    
answered by 10.08.2017 в 20:15