Tải bản đầy đủ
1  Monitoring and Barging into Live Calls

1  Monitoring and Barging into Live Calls

Tải bản đầy đủ

Discussion
The default DTMF keys for controlling ChanSpy() are as follows:
#
Cycles through the volume level
*
Stop listening to the current channel and find another one to listen to
There are a lot more options for ChanSpy() and ways to use it in your dialplan. With
some creativity, ChanSpy() can be used in many situations it wasn’t necessarily designed
for (see Recipe 3.4). Not only can ChanSpy() be used to listen to the conversation between channels, but you can also speak to a single channel where only one person can
hear you, referred to as whispering.
Whispering to a channel is commonplace in situations where a manager of a call center
is training an employee, and needs to listen to an agent during the call. To enable
whispering to channels that are being spied on, use the w option:
[CallCenterTraining]
exten => 500,1,Verbose(2,Listening to live agents with whisper)
same => n,ChanSpy(,bw)

Of course, we’re going to be looking for some finer grain control for who we’re listening
to. Perhaps we have several groups of people (multiple campaigns, different products,
etc.) we want to separate and listen to. One of these groups could simply be the training
group. New agents are all placed into the training group which makes it easy to scan
and listen to calls while providing help where necessary. To do this, we need to associate
channels with a spygroup using the SPYGROUP channel variable. By setting the channel
variable for a particular channel, ChanSpy() can then be directed to listen only to channels in a particular spygroup.
As we show in Recipe 3.7, we need to make sure the SPYGROUP channel variable is set
on the channel we want to spy on and whisper to. In order to do this, we need to use
the U() option of Dial(), which will execute a subroutine which sets the channel variable
on the called channel verses the calling channel. While setting the SPYGROUP channel
variable on the calling channel would still get us the ability to listen to calls like we
want, the whispering would be performed to the wrong channel (i.e., the customer
would be listening to the manager speak, not the agent):
[InboundCallsToAgents]
exten => 100,1,Goto(start,1)
exten => start,1,Verbose(2,Placing a call to an agent)
same => n,Dial(SIP/0000FFFF0001,15,U(subSetSpyGroup^training))
same => n,Hangup()
[subSetSpyGroup]
exten => s,1,Verbose(2,Setting spygroup)

40 | Chapter 3: Audio Manipulation

same => n,Set(SPYGROUP=${ARG1})
same => n,Return()

We can make sure the channel variable SPYGROUP was set on the correct channel by using
the core show channel CLI command at the Asterisk console. In our example, the device
0000FFFF0004 placed a call to 0000FFFF0001 using the dialplan we just wrote. By checking
the channel variables set on the call, we can verify our dialplan is working correctly:
*CLI> core show channels
Channel
Location
State
SIP/0000FFFF0004-000 start@InboundCalls:2 Up
SIP/0000FFFF0001-000 s@app_dial_gosub_vir Up
2 active channels
1 active call
2 calls processed

Application(Data)
Dial(SIP/0000FFFF0001,15,U(sub
AppDial((Outgoing Line))

Having verified the direction of the call (0000FFFF0004 used the Dial() application which
is connected to 0000FFFF0001), lets look at the channel variables set for the call:
*CLI> core show channel SIP/0000FFFF0004- TAB
...[snip]...
BRIDGEPVTCALLID=209ee58508fb319a0a2f615030316c28@172.16.0.161:5060
BRIDGEPEER=SIP/0000FFFF0001-00000001
DIALEDPEERNUMBER=0000FFFF0001
DIALEDPEERNAME=SIP/0000FFFF0001-00000001
DIALSTATUS=ANSWER
...[snip]...

We’ve snipped out a lot of text, but what we’re looking for is to make sure the calling
channel doesn’t have the SPYGROUP set for it as we’re expecting it to be enabled on the
channel being called (the agent). Using the same technique we can verify that:
*CLI> core show channel SIP/0000FFFF0001- TAB
...[snip]...
BRIDGEPVTCALLID=ODIxNTAyNGUyNWViZmM5NGIyOGY1ZTVjYTQ1N2ExNTI.
BRIDGEPEER=SIP/0000FFFF0004-00000000
GOSUB_RETVAL=
SPYGROUP=training
...[snip]...

Having verified our channel variable has been set on the correct channel, lets create the
dialplan that will allow our manager to listen and whisper to the channels in the training
group:
[CallCenterTraining]
exten => 500,1,Verbose(2,Listening to live agents)
same => n,ChanSpy(SIP,bwg(training))

With minor modifications to our existing ChanSpy() code, we can now listen to only
channels in the training group (option g(training)) and whisper to them (option w).
This same technique could be applied to only listening to specified extensions or callers
by placing only a single channel into the spygroup.
Some additional options which you may find useful include (to see all available options,
use core show application ChanSpy from the Asterisk CLI):
3.1 Monitoring and Barging into Live Calls | 41

d
Override the standard DTMF actions and instead use DTMF to switch between
the following modes:
4
Spy mode
5
Whisper mode
6
Barge mode
E
Exit when the spied on channel is disconnected.
q
Quiet. Don’t play a beep or speak the channel being spied on prior to listening.
S
Stop when there are no more channels to spy on.

See Also
Recipe 3.4, Recipe 1.4, Recipe 1.5, Recipe 1.6, Recipe 3.7

3.2 Growing Your Company With PITCH_SHIFT()
Problem
You want to appear as a larger company to the outside world by manipulating the pitch
of audio when dialing certain extensions.

Solution
exten => 100,1,Verbose(2,${CALLERID(all)} is calling reception)
same => n,Set(CALLERID(name)=RCP:${CALLERID(name)})
same => n,Set(PITCH_SHIFT(tx)=high)
same => n,Dial(SIP/0000FFFF0001,30)
same => n,Voicemail(reception@company,u)
same => n,Hangup()
exten => 200,1,Verbose(2,${CALLERID(all)} is calling sales)
same => n,Set(CALLERID(name)=SLS:${CALLERID(name)})
same => n,Set(PITCH_SHIFT(tx)=low)
same => n,Dial(SIP/0000FFFF0001,30)
same => n,Voicemail(sales@company,u)
same => n,Hangup()

42 | Chapter 3: Audio Manipulation

Discussion
Using PITCH_SHIFT() you can modify the transmitted and/or received audio pitch either
up or down. By changing the pitch of audio, you can sound like different people of the
company. In our example we’ve used the transmission modifier (tx) of PITCH_SHIFT()
to raise the pitch of the transmitted voice when extension 100 is dialed. Similarly we’ve
modified the transmitted pitch to be lower when dialing extension 200. In order to
know which department is being called, we’ve modified the callerID name by prepending either RCP for reception or SLS for sales.
For both extensions we’ve dialed the same device within the company. However, depending on which extension was dialed, we’ve configured separate voicemail boxes.
When setting up the voicemail greetings, you’ll need to modify the transmitted audio
using PITCH_SHIFT() prior to calling VoicemailMain() so that your voice sounds the same
across answered calls and the voicemail greeting.
PITCH_SHIFT() contains several shorthands for modifying pitch:

highest
Pitch is raised one full octave.
higher
Pitch is raised higher.
high
Pitch is raised.
low
Pitch is lowered.
lower
Pitch is lowered more.
lowest
Pitch is lowered one full octave.
In addition to the shorthands, you can pass the floating point number between 0.1 and
4.0. A value of 1.0 has no effect on the pitch. A number lower than 1.0 lowers the pitch
and number greater than 1.0 will raise the pitch. This can provide some fine grained
tuning of the pitch so that you don’t sound like a robot or Mickey Mouse (which simply
has the effect of being funny, and also makes you difficult to understand).
Testing can be done either by dialing another extension at your desk, or making use of
the Record() application and then listening to the audio recorded. With some fine tuning you can grow your company without hiring additional employees!

3.2 Growing Your Company With PITCH_SHIFT() | 43