How to detetct inboud abandoned calls in a queue - asterisk

I want to detect incoming calls in a queue, abandoned before being answered by a member of the queue.
The queue_log file makes mention of these ones, so one approach would be to use this. But I'd like to handle this situation within my dialplan, with a command that issues a notification to a discord salon when such calls are detected.
I've tried to use the h extension :
exten = h,1,NoOp("hangup ! cause : ${HANGUPCAUSE}")
same = n,GotoIf($[ ${HANGUPCAUSE} != 16 ]?done)
same = n,system(/myTools/discord-notification "Missed call from ${CALLERID(num)}.")
same = n(done),NoOp()
It works, but it does not differentiate answered calls from not answered / abandoned calls (they both issue a 16 hangup cause).
I've also tried to add a hangup handler using hangup_handler_push but it does not make any difference.
How can I detect such calls within the asterisk diaplan ?

You have use queue_log(probably queue_log in mysql) or check QUEUESTATUS variable after end of call in top level of dialplan.

Besides QUEUESTATUS , Asterisk Queue app sets another channel variable upon completition when a call is abandoned : ${ABANDONED}.
I had to do it manually using this method :
Setting a shared channel variable abandoned to true before executing Queue app, then changing its value to false when the call is answered via Queue GoSub parameter.
And then you can catch its final value via h extension.
exten => _X!,1,Set(SHARED(ABANDONSTATUS,${CHANNEL(LINKEDID)})=true)
exten => _X!,n,Queue(${EXTEN},,,,,,,cust-Queue-GoSub)
exten => _X!,n,Set(SHARED(ABANDONSTATUS,${CHANNEL(LINKEDID)})=false)
exten => _X!,n,HangUp()
exten => h,1,NoOp(Abandoned : ${SHARED(ABANDONSTATUS,${CHANNEL(LINKEDID)})})
[cust-Queue-GoSub]
exten => s,1,Set(SHARED(ABANDONSTATUS,${CHANNEL(LINKEDID)})=false)
exten => s,n,Return()

Related

What is the Asterisk Dial() Option to Call Subroutine on "Ringing" Status Received from Called Party?

I need to execute AGI scripts when following events occur:
An incoming call (it is simple just call AGI() function).
When a call is "Ringing" (I cannot figure it out!). <-- Problem, how to do this?
When a call is "Answered" (I do it using U(answer^${CALLID}) option in Dial()).
When a call hangs up (I do it using h special extension).
My dialplan looks like this:
[from_origin]
exten => _X.,1,NoOp(${CALLER_USERNAME} from ${CHANNEL(pjsip,remote_addr)})
same => n,AGI(agi://127.0.0.1/incoming)
same => n,Dial(${DIALSTR},45,U(answer^${CALLID}))
exten => h,1,AGI(agi://127.0.0.1/hangup,${CDR(uniqueid)})
[answer]
exten => s,1,Set(theCallID=${ARG1})
same => n,AGI(agi://127.0.0.1/answered)
same => n,Return()
Look, I have called 3 fast-agi scripts: incoming, answered and hangup. Now I need to call similar script like ringing when the called party is "ringing". How to achieve this ?
Ringing status is status of the channel(chan_pjsip.so) and it not sent outside channel code.
So no, you can't get it in Dial app. Because it can't be get for some channels types and Dial still should work for those types.
For some channels you can get it via AMI in event listening loop in NewState event. But there are no garantee it will be exactly at same time when you got ringing sip message.
https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+ManagerEvent_Newstate

Asterisk - Make a call inside a conference with ringtone

I'm trying to make a call inside a running conference and hear the ringtone.
*Note: the conference is already running I have only the admin inside.
I already tried different approaches to make the call without success
1) Originate:
channel originate SIP/000000000#provider application ConfBridge ConferenceName
This works, makes the call and when its answered it joins the conference, but no ringtone
2) ConfBridge Menu, dialplan_exec
[default_menu]
type=menu
1=dialplan_exec(addcaller,000000000,1)
[addcaller]
exten => _XXXXXXXXXX,1,Originate(SIP/${EXTEN}#provider,app,ConfBridge,ConferenceName)
This works, makes the call I have ringtone, but when answer, no audio inside conference
3) Options 2 + a macro to join call after answer
same => n,Dial(SIP/${EXTEN}#provider,,M(joinconf))
[macro-joinconf]
exten => s,1,NoOp()
same => n,ConfBridge(ConferenceName)
same => n,Hangup()
This works, I can hear the ringtone and then I can see the user inside the conference but again, no audio!
4) All versions with variants
I have tryied all sort of variants using
same => n,Answer()
same => n,Progress()
same => n,Wait(1)
cause maybe was the channel not answered, but I'm stuck.
the final goal is a simple
conference with the power of calling and hanging other phones.
No matter if I need to use:
AMI with multiple commands
channelredirect
chanspy
meetme
AGI
whatever just need to make it work
Do originate into Local channel, in dialplan use Ringing(r param in dial command) or moh with ringing sound

Playback file in Call Waiting on Asterisk

Please help in the problem that I encountered recently.
When implementing the function of informing the caller "User talking on the first line Please wait or call back later." With the function "Call Waiting" in the Asterisk I use this macro:
extensions_custom.conf
[from-internal-custom]
exten => _XXX,1,Macro(check-number,${EXTEN})
include => macro-check-number
[macro-check-number]
exten => s,1,NoOp(Enter in macro-check-number)
exten => s,n,Set(devst=${DEVICE_STATE(SIP/${ARG1})})
exten => s,n,ExecIf($["${devst}" = "INUSE"]?Playback(ml))
exten => s,n,NoOp(Exit from macro-check-number)
ml - filename for playback
And this feature works!
But the macro works for the entire Asterisk, this queue calls, group calls - and that is the problem.
I have an idea - a group of calls and queue calls to assign numbers four-digit extensions, for example: 2222 - but are not you should not be, it is a false solution to the problem, because of which in the future could be a problem!
Maybe somebody faced a similar problem?
You don't need to include section in the from-internal-custom context
as extensions_custom.conf file is included in the dial plan.
You need to change the pattern of extension:
[from-internal-custom]
exten => _99XXX,1,Macro(check-number,${EXTEN:2})
[macro-check-number]
exten => s,1,NoOp(Enter in macro-check-number)
exten => s,n,Set(devst=${DEVICE_STATE(SIP/${ARG1})})
exten => s,n,ExecIf($["${devst}" = "INUSE"]?Playback(ml))
exten => s,n,NoOp(Exit from macro-check-number)
You have analyze environment of call based on your dialplan.
For examples of such dialplan you can see recoring macro in freepbx project. However simplest way is just use different context for ringgroup/queues and direct diallling.
The problem was solved in the circuit.
Since we serve telephony server with no more than 250 members - it was decided to create a four-digit number for the groups and queues.

Not able to connect incoming caller to th dialed calee in meetme function in asterisk

My code is simple A calls to B the they both entered into meetme conference
[from-pstn]
exten=> _X.,n,Answer()
same => n,dial(DAHDI/g0/0${9xxxxxxxxx},20,mM(MYCONFO))
[macro-MYCONFO]
exten => s,n,Meetme(1234,sdrM)
But when A calls to B only B enters the conference and A is not able to enter conference , A only hears musiconhold
yes i have read meetme and n way dialout
Can anybody help me with that
I think for this you should use option G from DIAL command:
http://www.voip-info.org/wiki/view/Asterisk+cmd+Dial
G(context^exten^pri): If the call is answered, transfer both parties to the specified context and extension. The calling party is transferred to priority x, and the called party to priority x+1. This allows the dialplan to distinguish between the calling and called legs of the call (new in v1.2). You cannot use any options that would affect the post-answer state if this option is used.
So dialplan should be:
[from-pstn]
exten=> _X.,n,Answer()
same => n,dial(DAHDI/g0/0${9xxxxxxxxx},20,mG(MYCONFO,s,1))
[MYCONFO]
exten => s,1,Meetme(1234,sdrM)
exten => s,2,Meetme(1234,sdr)
You code is incorrect.
Please read again documentation about in-call-macro. It have alot of limits
Try use goto.
If not work, try use transfer from external application with UserEvent
ps. yes, it work as described in n-way-howto too.

Changing the caller number in an incoming call in asterisk

I am using asterisk.I have DID in which 4 numbers are mapped(stored in my database) so when user calls to that DID number the call is forwarded to the any one number mapped on that did.
My problem is that when user calls to DID the one of the four executive receive calls from the DID number not with user number .This is my part of dialplan code the call is routed from another context(not given below) to the direct context
[direct]
exten => start,1,noop(######START######)
same => n,mysql(Query resultid ${connid} SELECT number from database);;;DDDDDD
same => n,MYSQL(Fetch fetchid ${resultid} number )
same => n,mysql(clear ${resultid})
same => n,set(__NUMBER=${number})
same => n,dial(DAHDI/g0/0${NUMBER},20,mM(ANSWEREDED))
[macro-ANSWEREDED]
exten => s,1,noop(CALL_ANSWERED)
exten => s,n,Mixmonitor(/recordings/record.wav)
How can i change the number that flashes on executive number(number mapped on DID) to the caller number?
Thanks in advance.
1) Every asterisk book have example. Doing asterisk coding without reading book - not so nice idea
2) callerid can be set like this
same => n,set(__NUMBER=${number})
same => n,set(CALLERID(num)=123445678)
same => n,dial(DAHDI/g0/0${NUMBER},20,mM(ANSWEREDED))
3) If you use pstn dahdi connection(FXO card), that will not work. If you use digital connection, it can work if provider support that.
4) Use of app_mysql is depricated. Use func_odbc or realtime.
5) Use of mixmonitor inside on-call macro is extremly bad practice. Use mixmonitor with 'b' option before call out.

Resources