Asterisk - Pre-emption calls - asterisk

I would like to have pre-emption calls in Asterisk. With this I mean that if user A has priority/access-level 1 and wants to talk to user B, how could it preempt the call that user B is already having with user C which has only priority/access-level 2?
Does anyone know if this is supported by Asterisk or how this could be implemented?
Any idea would be very welcome.

No, it not supported by asterisk.
But yes, it can be implemented using dialplan+some script magic. Complexity is high and require expert or guru skill.
Short plan is following:
check if B is in call (need use DEVICE_STATE or GROUP functions)
check if B in call with lower priority caller( ASTDB or REALTIME or fastagi script)
wisper both(or only B) party that now have priority call. For that need read about asterisk auto-dialout and wisper.
wait till B press confirmation key(features.conf)
transfer both B&C to new extension, bridge A&B, play hold for C.
deal with restore C connection if needed.

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.

asterisk queue_log late COMPLETEAGENT

I am trying to write a wallboard for my asterisk server. This wallboard will process the queue_log file in /var/log/asterisk.
Here is a scenario in question:
1) A customer calls out call center. Let his number be 44556677889900 and our number 8881234567890.
2) The customer enters the queue 210.
3) Agent 1 takes the call.
4) Agent 1 decides that the call should go to another queue. And transfers it to queue 209
5) Agent 2 takes the call.
6) Agent 2 terminates the call after talking with the customer. (When Agent 2 is talking on the phone Agent 1 is idle and available for a new call.
7) Normally Agent 1 ended his call at 4th step, but the log with COMPLETEAGENT appears just now, even the agent is available since 4th step
Here is the output in the queue_log:
1550582529|1550582516.26480|210|NONE|DID|8881234567890 * 1. step*
1550582529|1550582516.26480|210|NONE|ENTERQUEUE||44556677889900|1 * 2. step*
1550582531|1550582516.26480|210|Test Agent 1|CONNECT|2|1550582529.26493|2 3. step
1550582536|1550582536.26498|209|NONE|DID| ** 4. step**
1550582536|1550582536.26498|209|NONE|ENTERQUEUE||9991|1 4. step
1550582539|1550582536.26498|209|Test Agent 2|CONNECT|3|1550582536.26499|2 5. step
1550582543|1550582536.26498|209|Test Agent 2|COMPLETECALLER|3|4|1 6. step
1550582549|1550582516.26480|210|Test 1|COMPLETEAGENT|2|18|1 7. step
As mentioned in the 7th step, Agent 1 if available for new calls after he transfers the call to queue 209. (In fact if a new call comes, the system send the call to Agent 1). However the log "COMPTELEAGENT" appears only when the customer disconnects.
This makes my wallboard think that Agent 1 is busy even he is not. And worse if he received a new call before Agent 2 finishes, everything gets more complicated.
Questions:
1) How it is possible to make the system send the COMPLETEAGENT at step 4 ?
2) Why is ATTENDEDTRANSFER log missing ? (Not related to this problem directly but can also be connected)
Asterisk Version: 13.22.0
Freepbx 14.0.5.25
Thank you in advance.
1) System should not send COMPLEATEAGENT at 4, becuase thoose event should be sent AFTER END of call.
That event is created by QUEUE, not by AGENT. From queue's point of view call not yet finished.
If you want it be finished, do transfer of LEGA, not queue's LEG.
2)Transfer subsystem not related to queue subsystem and SHOULD NOT be related in any realible PBX. You can write your own if you want.
Side notes
no point parse queue_log, much simpler setup queue_log in mysql or other db and read it.
you can write your own queue system using Async AGI.
you can add as many logs as you want by using dialplan CEL or UserEvents.

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

Adding callers to conference using asterisk agiphp

agiphp guru of stack flow
My question is
I'm developing an application where a junk of work is about making conference call.I want to write Agi preferably PHP based where user A holds DID using SIP trunk which is connected to asterisk server need to make conference call(outgoing) like calling B,C,D....n and puting them in conference.If there is any example please share or give ur valuable feedback to implement it. I'm currently using asterisk 1.8
but meet me and confbridge is not much of use for me as well as auto dial out.I need something like for example user A with exten 1234 calling user B with exten 5678 and both are in a call now user A or B need to call to user c with exten 1111 and try to call him and put all user A,B,C in one conference
Please read this pages
http://www.voip-info.org/wiki/view/Asterisk+auto-dial+out
http://www.voip-info.org/wiki/view/Asterisk+cmd+MeetMe
But note, dialout can have very tricky issues, so not recommended do dialout application if you are not expert.
For more info consider check opensource diallers like vicidial.

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