Update crm database after hangup

Hello all,

I have integrated sugarcrm with elastix 1.6.2. I have created a table in sugarcrm almost same as asterisk cdr table. I would like to update crm table with the call log the same time table cdr does.

By the way I am very new in asterisk. Forgive me if I am wrong. In extensions.conf file I see every calls initiates throug dialparties.agi file and then finally it calls hangup in macro-hangupcall.

In my understanding and test, I found cdr table updated after hangup finishes.I have created a agi file updatecrm.php and this file is suppose to connect crm database table after copying information from cdr table fields.

My little but very important question is where should I add the line of code and how could I write the code to call the AGI to do this job.

Please help.

you would need to override the macro-hangupcall context (or in 2.7 you can splice into it with a new module if you feel adventurous).

In there you would execute your AGI script as part of the hangup process.

I have been trying to follow your suggession. I think as a new developer it’s a bit difficult for me now.

As you noticed in macro-hangupcall the last line is
exten => s,n(theend),Hangup

I would like to catch this hangup in my updatecrm.php file with php function pcntl_signal(SIGHUP, “sig_handler”);

Because asterisk update cdr table just after hangup, I would be able to copy the information from cdr table and will update crm table.

Therefore, I think I need to write the above exten code in updatecrm.php file. To do this I replace the above exten code by

exten => s,n(theend),AGI(updatecrm.php)

Would you please guide me how can I hang up the call in the php file.

Thanking you.