Finding uniqueid of call channel - asterisk

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

Related

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.

How to get list of ongoing calls in Asterisk Java?

I was wondering, how can one get the list of ongoing calls in Asterisk when using Asterisk-Java?
It is needed when e.g. restarting ManagerAPI and I would like to display all the calls, which are currently running on Asterisk.
Previously it was done by observing properties on Channels created in Asterisk (I think it was 'linkedChannel' property), but this is now (Asterisk 13) not possible - linkedChannel is not updated when call is created.
You should issue via AMI COMMAND action with "core show channels concise" and collect output.

How manual dial in vicidial is implemented with asterisk?

I logged in using agc (agent) panel in vicidial and just to test manual dial, I just executed following MySql query fron cmd.
UPDATE vicidial_live_agents set external_dial='12122351880!!YES!NO!YES!!1478530720!!!!!!' where user='1001';
After this , i got a a call on my softphone (already configured).
I am unable to understand one thing, How can an explicit entry to the vicidial_live_agents table of mysql, make a call ?
You shouldn't be messing with the database for calls.
If you configured everything correctly, you should recieve a call as soon as you log-in which will send you to a conference, you should hear a voice confirming it (you are the only one in this conference), all future calls will be connected to that conference, you should keep that call at all times and not control anything in the softphone.
If you need to make a manual calls you can either set the "Manual Dial Override" option in the campaign to "ALLOW ALL", which will enable a link in the agent screen labeled "Manual Dial" or you can use the agent_api with the external_dial function.
What you have found is the raw method that the Agent API uses to implement a manual dial call. For more information on how the Agent API works, and for all of the options you can use with the "external_dial" function, take a look at the Agent API documentation:
http://vicidial.org/docs/AGENT_API.txt

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.

What is mean by Action => 'ping' using send_action in Asterisk Manager Interface script?

I have started to read about Asterisk::AMI module.
In that module if we want to send the action to the AMI server,we need to use the Action with action name using send_action method.
In that module they mentioned about Action => 'Ping' within send_action method.
Here what is the use of Action => 'Ping'.Can anyone explain me about it.
send_action({ Action => 'Ping',
CALLBACK => \&method,
});
Thanks in advance.
The Asterisk Manager Interface (AMI) allows a client program to connect to an Asterisk instance and issue commands or read events over a TCP/IP stream
Action: A packet sent by the connected client to Asterisk, requesting a particular Action be performed. There are a finite (but extendable) set of actions available to the client, determined by the modules presently loaded in the Asterisk engine. Only one action may be outstanding at a time
Action => Ping
gives Keep alive packet to be sent from the client to Astersik
Action: Ping
Synopsis: Keepalive command
Privilege: <none>
Description: A 'Ping' action will elicit a 'Pong' response. Used to keep the
manager connection open.
Variables: NONE
You can get basic help for any Asterisk AMI command from within the Asterisk CLI
interface by typing
manager show command yourCommand
You can see an entire list of supported commands by typing
manager show commands
BTW the shell command to get to the Asterisk CLI is
asterisk -r
I think this is a just a keep alive. Asterisk Manager Interface is known for being a little unreliable. Astmanproxy is a good way to fix that.

Resources