How exactly does the a2billing softswitch generate call records? - asterisk

I just installed Asterisk 11 and a2billing 2.01. I followed instructions for the a2billing installation and everything was OK. It works.
But... There are no call traces being recorded into the a2billing database!!!
As I understand it, it uses the "cc_call" table for call recording - but this table is empty!
I need all calls recorded, not only answered. I'm making calls via AGI using their PHP scripts. The following is my dial plan:
;For standard inbound call
[a2billing]
exten => _X.,1,NoOp(A2Billing Start)
exten => _X.,n,Agi(/usr/share/a2billing/AGI/a2billing.php,1)
exten => h,1,Hangup
This starts the IVR which tells me my account balance (how much money I have left), and then asks me to choose a number to dial.
I have a trunk for the call, created as has been recommended. After the call my balance is decreased; i.e., the call has been charged. But I cannot see any call records inserted into the database.
My questions are: How exactly does a2billing generate CDR's? What do I need to do to have the calls recorded?

As mentioned by arheops, A2billing store CDRs in it's own Mysql Database, within a table called cc_call, the table is very similar to the Asterisk CDR table but contains extra fields to store the buy/sell rates, cost of calls and relation to the rate/callplan tables.
When you send a call to the AGI, A2Billing will try first to authenticate the users, if it succeed then the outbound call will be saved.

A2Billing create cdrs via by agi script. You can got it in cc_call table.
For record calls you have change agi-confX and set key for recording(in config section of web)

Related

Multiple CDR records Asterisk 13

Running Asterisk 13.12.1, FreePBX 13.0.192.19.
We had to install new server and since we previously used much older asterisk, there were some fixes applied. We DIDN'T update previous, but we made clean install, just copied dialplans, sip config etc.
The problem is that we are now having multiple CDR records per call. We previously had NOCDR lines for local contexts, and we tried I have tried to change those to exten => _X!,1,Set(CDR_PROP(disable)=1) but that didn't work at all.
Here is the example:
[main context]
exten => remote-mon-1,1,Dial(SIP/lokal300&SIP/lokal301&Local/06xxxxxx#shift-remote-1&Local/06xxxxxx#shift-remote-2&Local/06xxxxxx#shift-remote-3&Local/06xxxxxx#shift-remote-4&Local/06xxxxxx#shift-remote-5&Local/06xxxxxx#shift-remote-6,,m(remote)M(whoanswered,remote))
[shift-remote-1]
exten => _X!,1,Set(CDR_PROP(disable)=1)
exten => _X!,n,Dial(SIP/gsm10/${EXTEN},540)
Basically what the above does is calling two local phones (300 and 301) as well as multiple (6) remote mobile phones via gsm gateway.
1) So CDR PROP is completely ignored (I think someone said how its not working with Local context but I need confirmation). How can I fix it?
2) Any other ideas how to avoid creating multiple CDR record for each call?
Thank you!
Update: As this was flagged as a duplicate of Asterisk 13.4 cdr engine is creating 2 records per call , I need to explain that In that question the solution is applying unofficial patch, which is not something we want to do. I was looking for official approved way on why CDR_PROP is not working correctly. Furthermore (I just checked) the link to patch in that post is not working, as site is unreachable. One more reason to not flag this as duplicate.
1) use NoCDR, not forget add '/n' to local channels
pro-sip*CLI> core show application NOCDR
-= Info about application 'NoCDR' =-
[Synopsis]
Tell Asterisk to not maintain a CDR for this channel.
[Description]
This application will tell Asterisk not to maintain a CDR for the current
channel. This does *NOT* mean that information is not tracked; rather, if the
channel is hung up no CDRs will be created for that channel.
If a subsequent call to ResetCDR occurs, all non-finalized CDRs created for the
channel will be enabled.
NOTE: This application is deprecated. Please use the CDR_PROP function to
disable CDRs on a channel.
[Syntax]
NoCDR()
[Arguments]
Not available
[See Also]
ResetCDR(), CDR_PROP
2) Read /etc/asterisk/cdr.conf params.

Asterisk HANGUPCAUSE always 0 when caller hangs up Queue

Using Asterisk 11, with an inbound route configured to call Queue app, every time the caller hangs up the HANGUPCAUSE variable is 0, it works and returns the NORMAL_CLEARING code only when the assigned queue member hangs up or if not using queues. Example code:
[from-trunk]
exten => s,1,Answer()
same => n,Queue(queue-1,rkt,,,30)
exten => h,1,Verbose(Hangup cause is ${HANGUPCAUSE})
How to obtain a valid HANGUPCAUSE from calls answered with queues?
Asterisk HANGUP_CAUSE will show you only value of last Dial command and only for SOME channel types.
Queue generate 100500 of NEW calls and bridge it together to make functionality you want.
You can check cause in queue's branches(in each one can be DIFFERENT), using agents in Local/ channels.
You can use Queue app variables:
This application sets the following channel variables upon completion:
${QUEUESTATUS}: The status of the call as a text string.
TIMEOUT
FULL
JOINEMPTY
LEAVEEMPTY
JOINUNAVAIL
LEAVEUNAVAIL
CONTINUE
${ABANDONED}: If the call was not answered by an agent this variable will be
TRUE.
You also can use queue_log or CDRs.

execute command after asterisk confbridge recording is finished

I'm trying to find answer how to make Asterisk execute some command (my script) after confbridge's recording is finished
There is the next info in confbridge.conf:
record_conference=yes
Records the conference call starting when the first user enters the
room, and ending when the last user exits the room.
It records file well but I want it sending wav file via email.
Could anybody help me?
My config now looks like this (if it's necessary):
exten => 333,1,ConfBridge(100010,100010_bridge_profile,100010_user_profile)
Dialplan scripting is limited to events relating to each call channel. To get event info for other parts of asterisk (such as the ConfBridge application) you should hook into the Asterisk Manager Interface (AMI).
There are many libraries already created to make working with the AMI easier. (That site may be outdated. Refer to the official Asterisk Wiki whenever possible.)
The AMI event you're interested in is "ConfBridgeEnd". Docs here.
You can use h-extension after confbridge, in which you have check if confbridge still active(last user).
If yes, run your script via System call.

Collect Asterisk cdr records by http post

I'm using Asterisk and want to collect cdr records. I searched for a while, and found that there are already modules which we can use to collect cdr records into CSV files or MySQL.
I'm wondering that whether there is already a module which let me collect cdr records by http post. So that when a call finished, Asterisk will post cdr records to a predefined URL.
Thanks in advanced.
I don't know such a module, but you could execute an Application on Hangup.
You could use the function ${CURL(url[,post-data])}:
exten => h,n,Set(result=${CURL(http://SERVER/cdr.php?\
cdranswer=${CDR(answer)}&exten=${EXTEN}&cidnum=${CALLERID(num)})})
exten => h,n,Noop(${result})
Another Approach is to execute a Script on Hangup:
exten => h,n,System('php -f /opt/scripts/cdr.php \
${CallerID(num)} ${EXTEN} "${CDR(answer)}" ${EPOCH}');
Maybe you could also use ${CDR(billsec)}.
Another option would be to use a CRON job to run a Ruby or PHP script every few minutes to extract and HTTP POST all of the CDRs since the last time the script was run. I've done that for a customer and it works reasonably well.
That said, what I've found is that if I need to have CDRs accessible "off machine", the easiest way to do it over the long haul is set up MySQL replication; write the CDRs to the PBX machine, read them from the replicated copy on the reports machine. It's a bit more set-up intensive at the beginning, but makes everything else a heck of a lot easier later on.

Initiate an outgoing call with Asterisk

I have a database where one entry is structured like so:
number_to_call date file_to_play
Using asterisk, I need to do the following:
1. Check the database daily.
2. If date matches that of today's, then initiate call on number.
3. Once phone has been picked up, play file_to_play.
Some general pointers on how I even begin to do this would be great.
Most of the applications that I have written so far have worked on incoming calls. I have the following questions:
1. How do I write a "daemon" that will check the database? Asterisk should have both user and group privileges for it to execute properly. How do I do this?
2. Can I initiate an outgoing call from outside of the asterisk dialplan?
The calls are being made to a PSTN/mobile number.
You can Write any script Which can check DB on daily basis and once it maches the date range you can initiate a call using .call files.
Please study asterisk auto-dial out from voip-info.org - I think you can understand better then.
You can run your script for same user as asterisk runs there is also one more method to initiate call from linux which we can call Originate CLI command which can also refer to http://voip-info.org/.
In general it is not a great idea to write your own dialer, unless your volume is very very low. Where I work, we started rolling our own but at the end went with a commercial solution that handled most of the logic. There are a number of commercial and free solutions out there, so don't reinvent the wheel.
See my answer to https://stackoverflow.com/questions/11666755/outbound-dialer-using-asterisk/14589901#14589901 for why it is not a good idea to roll your own.

Resources