execute command after asterisk confbridge recording is finished - asterisk

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.

Related

Finding uniqueid of call channel

I use Asterisk 16.5 and sip trunk.
If known sip channel can i find uniqueid of call?
Note: I want do it with Asterisk AMI actions and events.
Action: Command
Command: core show channels concise
give you a list of :
Channel:Context:Exten:Priority:Stats:Application:Data:CallerID:Accountcode:Amaflags:Duration:Bridged
You have to pick the correct channel with the "Channel" field and make a
Action: Command
Command: core show channel YOUR_CHANNEL
If you expect do events, correct way is use event. I.e collect NewChannel events and build map(for example, in memcached).
https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+ManagerEvent_Newchannel
Running too many commands sometimes result problem with ami connection.
As an example of such code you can check FOP opensource or FOP2 project(no source now). https://www.fop2.com/about.php

Asterisk 11 Who Hanged Up?

I do have an Asterisk 11 PBX and I'm developing an Windows Service application using the github AsterNET.AMI Library to connect my PBX. Till here everything is working fine, I can send commands and read incoming event messages.
But now I need to develop a feature on my software based over one information that I thought it could be easy to retrieve. The information I'm looking for is - who hanged up?
I googled for it a lot and I could find a few answers, most of them talking about setup the G option on CDR but also some considerations about this approach. Still like this I couldn't grab any valuable information for my scenario.
Maybe if I tell you about my working scenario you could help me. Lets go, I'm going to bullet split this:
I do have a caller calling from a cellphone and this calling are incoming to my internal PBX extension
My PSTN trunk is a E1/R2 directly to my PBX
No matter if caller or callee hangs up always I do have "normal clearing" message for hangup_cause
I know I'm receiving from my service provider the information about the releasing device, because if I use my Siemens 3800 Hipath over CSTA I can retrieve this information.
So the gold question is: How can I retrieve who is the releasing device on this situation?
You can try a combination of g and F options in the Dial application. The g option allows dialplan execution when the called party hangs up, while the F option allows you to continue execution to a context,extension,priority of your choice if the caller hangs up.
So, you can understand which party is hanging up by the dialplan being executed after the call ended.
Find here more info on these options: https://www.voip-info.org/asterisk-cmd-dial/
The only way I could find after read Asterisk doc almost entirely was reading HangupRequest event messages.
As I'm using AsterNet.AMI library to connect and manage my Asterisk, so I change the source code a little bit to have an event handler do read HangupRequest event.
HangupRequest event writes the messages like the following one:
Event: HangupRequest
Privilege: call,all
Channel: SIP/8103-000001be
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: 8103
CallerIDName: Agent 8103
ConnectedLineNum: 51999887766
ConnectedLineName: 51999887766
Language: en
AccountCode:
Context: from-internal
Exten: 8100
Priority: 1
Uniqueid: 1569618521.446
Linkedid: 1569618519.445
So accordly to HangupRequest Event Asterisk documentation I could notice the channel in the message is the channel related to the releasing device, also CallerIDNum and CallerIDName are related to.
This feature is not implemented right now on the github library, but I'm going to push over there and ask them to include on next release.
Yet I don't know where to read this information on FreePBX Admin.

Out Bound Dialing Asterisk

I have a calling application developed in PHP with AGI on Asterisk framework, below is the basic flow of application.
We receive a call from user at our Asterisk ss7 server and forward the same call to another user from our server.
I want to know the status of call forward to another user. Status means what happen with call between both users e.g. Hangup, Busy, Not Answered etc.
Not much detail on how you are placing the call or anything else but if you are performing a Dial() and want to know at the end of the call the result try ${DIALSTATUS}.
This will contain something like 'ANSWER', 'NOANSWER' or 'BUSY'. For the full list and more info check out http://www.voip-info.org/wiki/view/Asterisk+variable+DIALSTATUS
you can use CDR feature or use a diaplan to get the dialed status
http://www.voip-info.org/wiki/view/Asterisk+variable+DIALSTATUS
http://www.voip-info.org/wiki/view/Asterisk+cdr+mysql

How exactly does the a2billing softswitch generate call records?

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)

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