Asterisk - Call monitoring for queues - asterisk

I have set up basic call monitoring for individual extensions in my Asterisk setup. This is what I have done for recording individual calls:
[macro-automon]
exten => s,1,Set(MONITOR_FILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)})
same => n,MixMonitor(${MONITOR_FILENAME}.wav,b)
[LocalSets]
exten => 101,1,noop(dialing 101)
same => n,Macro(automon)
same => n,Dial(${EXT_TESTONE},20,m) ; Replace 0000FFFF0001 with your device name
same => n,Playback(vm-nobodyavail) ; Play "no one's available"
same => n,Hangup()
This works and a call which is picked up by extension 101 is saved under /var/spool/asterisk/monitor
Now, I have setup a couple of test queues called sales and support, like so:
[Queues]
exten => 7001,1,Verbose(2,${CALLERID(all)} entering the support queue)
same => n,Queue(support)
same => n,Hangup()
exten => 7002,1,Verbose(2,${CALLERID(all)} entering the sales queue)
same => n,Queue(sales)
same => n,Hangup()
I have also added the user called 0000FFFF0001 under the sales queue. Thus, when I dial 7002, it rings at ext.101 and the call can be picked up. However, the call monitoring doesn't take place.
How could I enable monitoring for calls which come to 101 via the queue?

Call queue have own monitoring flags.
However you always can do it via local channel. Instead of do queue do
Dial(Local/s#toqueuesales/n)
and put in extensions.conf
[toqueuesales]
exten => s,1,Answer
exten => s,2,Queue(sales)
That way it have work anyway(but will show 2 channels and 2 cdrs)

You can also add local channels to the Queue instead of extensions. Technically when the queue is ringing your agent, it's ringing SIP/101 (or whatever the agent extension is). If you added Local/101#LocalSets as an agent in your queue config, the dialplan you provided would work. You'd need to tweak the default log in/out macros, but this is the easiest way to get your dialplan to work.
See the docs for a comprehensive guide to adding queue members.

Related

Asterisk how check if a number is busy before dialing it

As a beginner that just installed his first asterix server I came across a small issue. i want to check if a number that i dial is busy or not before actually dialing it.
So for example I would call 0904 => number busy => redirect to 0905
However I don't want it to dial 0904 first if its busy but just instantly redirect it to 0905 instead.
I have a very basic setup with just 3 users. 2 of them are in a queue "support" one of them is in the queue "admin"
I have seen and read a little about checking if a channel is available but i didn't fully understand that and I'm not sure if it could be done easier.
Here is my simple dialplan, if i call *12 my simple python script will just execute the Dial command to the 0904.
exten => *12,1,Answer()
same => n,set(PHONE_EXTEN=0904)
same => n,AGI(test-agi.py,${PHONE_EXTEN})
same => n,Hangup()
There is no way know if external number is busy.
If number is your extension, you can count calls using GROUP/GROUP_COUNT or you can check extensions states and hints, like described in docs
https://wiki.asterisk.org/wiki/display/AST/Extension+State+and+Hints
https://wiki.asterisk.org/wiki/display/AST/Device+State

Recording Normal Calls and Conference calls in Asterisk

Set up Asterisk 13.1 on Ubuntu 16.04,Calls are Working fine as well as conference calls.However I have two Question regarding the recording of calls in asterisk.
This is the extensions.conf.
[default]
exten => 1000,1,MixMonitor(${CALLERID(num)}-${STRFTIME(|EST5EDT|%m%d%Y-%H%M%S)}.gsm)
same => n,Dial(SIP/1000)
exten => 1001,1,MixMonitor(${CALLERID(num)}-${STRFTIME(|EST5EDT|%m%d%Y-%H%M%S)}.gsm)
same => n,Dial(SIP/1001)
exten => 100,1,Answer()
exten => 100,n,Authenticate(234)
same => n,MixMonitor(${CALLERID(num)}-${STRFTIME(|EST5EDT|%m%d%Y-%H%M%S)}.gsm)
same => n,ConfBridge(1234)
And this is confbridge.conf
conf => 1234
[1234]
record_conference = yes
1)Is it necessary to define MixMonitor for every call(As I have done above for user 1000 and 1001) ,or is there a possibility where you can define it once and all calls in your asterisk server get recorded.
2)When the Conference call is recorded ,suppose if there are two users in the conf room,there are two audio files generated instead of one,What changes do I make so theres is only one recorded audio file of the full conference?
In asterisk it is nessesary do any action you want DO.
In your case you can use mixmonitor command in every dialplan, use pattern to do that command for large list, use external macro or gosub function and call it for calls you want be recorded.
For conference you can start enother call with mixmon(third call) using Originate or you can use internal recording.
For ANY record you can have Monitor(two files for each side of call) or mixmonitor(same, but 1st party in left channel, 2nd party in right channel, so file is single).
So if you have 2 files, you just have non-mixed variant. Consult conference room options for mixed version.

Asterisk run script on Phone Answer and Outgoing Call

I'm trying to make my Asterisk run a script whenever a certain phone (Sip Phone) answers or makes an outgoing call and when it ends that call. The purpose of that is to automatically mute my TV when a call is done with the phone in the same room.
I've tried using the System command but that doesn't get information about the phone that answered. As I am having multiple phones ringing, I can not distinguish if it was indeed the phone next to the TV or a completely different phone. Same problem I am having for outgoing calls.
Is there a different approach to this? I also tried using the AMI but I haven't found a way to get the status of a specific peer (Offline, Online, In Call, lagged).
Lets say you have ext sip/111
Support extension
[from-internal-very-special]
exten => 111,1,UserEvent(TVRingStarted)
same => n,Set(CHANNEL(hangup_handler_push)=from-internal-very-special,ends,1)
same => n,Dial(SIP/111,,U(from-internal-very-special,answer,1))
exten =>answer,1,UserEvent(TVRingAnswer)
same => n,Set(GOSUB_RESULT=);we accept call
same => n,Return;continue
exten => ends,1,Noop(end of call)
same => n,UserEvent(TVRingEnds)
same => n,Return;
After that call extension as Local/111#from-internal-very-special/n instead of SIP/111
You will have user events you can parse via AMI. Or you can replace that by System calls as you wish.

Asterisk Call Transfer to Playback then resume back call

Here is my scenario i want to achieve, I have do outbound call to a number, after conversation i need to transfer the call to play a message for callee. After the message end, the call will route back to caller continue conversation.
How am i going to achieve this. using method MeetMe? or others?
Dialplan should be something like this:
[default]
exten => _10XX,1,Dial(SIP/${EXTEN})
After the conversation if the user transfer the call to "Music" extensions: (from sip client i guess):
[Music]
exten => _X.,n,Playback(your_play_file)
exten => _X.,n,Dial(SIP/${EXTEN})
better if you can manipulate using AGI to get/set the user was talking to the caller.
alternate:
you can use Call Parking for this.

Execute commands while waiting MeetMe() to add caller to conference or Timeout is up

How to execute Playback() or Background() command in asterisk while waiting for MeetMe()
response or Timeout
what I'm trying to do is to Playback() sound file randomly every 40 sec till MeetMe() add caller to queue
or Timeout get done (Note: Timeout is 3 minutes)
exten => s,n(live),Set(TIMEOUT(absolute)=180)
exten => s,n,MeetMe(130989,wmqdT1)
exten => s,n,Set(promptnum=${PathPrompts}/${RAND(38,42)})
exten => s,n,Background(${promptnum})
;Timeout
exten => T,1(timeout),Playback(${PathPrompts}/30)
exten => T,n,Playback(${PathPrompts}/31)
exten => T,n,Playback(${PathPrompts}/38)
exten => T,n,Playback(${PathPrompts}/60)
exten => T,n,Playback(${PathPrompts}/55)
You can use hold music and M(holdclass) flag
M[(class)]: Enable music on hold when the conference has a single
caller. Optionally, specify a musiconhold class to use. If one is not
provided, it will use the channel's currently set music class, or 'de
fault'.
So just create long gile with your prompts and silense.
Other option is spy channel and playback on it(require expert level)
For timout you can use this option:
w[(secs)]: Wait until the marked user enters the conference.
After that use marked user flag on entry next user
A: Set marked mode.
Use ConfBridge instead of MeetMe
http://lists.digium.com/pipermail/asterisk-users/2009-May/231433.html

Resources