text
stringlengths
0
152
desk phones. We first set our LOCATION variable using the CHANNEL variable, then
determine which extension (agent) is logged into the system and assign that value to
the WHO variable. If this variable is NULL, we reject the outgoing call. If it is not NULL,
then we get the agent information using the HOTDESK_INFO() function and assign it to
several CHANNEL variables.
include => hotdesk_outbound
; put this code right below your [hotdesk] context
[hotdesk_outbound]
exten => _NXXXXXX.,1,NoOp()
same => n,Set(LOCATION=${CUT(CHANNEL,/,2)})
same => n,Set(LOCATION=${CUT(LOCATION,-,1)})
same => n(checkset),Set(VALID_AGENT=${HOTDESK_CHECK_SET(${LOCATION})})
same => n,Noop(VALID_AGENT is ${VALID_AGENT})
same => n,Set(${CALLERID(name)}=${HOTDESK_INFO(cid_name,${VALID_AGENT})})
same => n,Set(${CALLERID(num)}=${HOTDESK_INFO(cid_number,${VALID_AGENT})})
same => n,GotoIf($[${VALID_AGENT} = 0]?notallowed) ; Nobody logged in--calls not allowed
same => n,Dial(${LOCAL}/${EXTEN}) ; See the Outside Connectivity chapter
same => n,Hangup()
same => n(notallowed),Playback(sorry-cant-let-you-do-that2)
same => n,Hangup()
If you are not logged in, the call will fail with a message. If you are logged in, the call
will be passed to the Dial() application (which might also fail if you don’t have a car‐
rier configured, but that’s something covered in earlier chapters, so we’re going to
leave it as this for this section).
There’s one last bit of dialplan required. We have built this complex environment that
lets our agents log in and out, but there isn’t actually any way of calling them!
We’re going to fix that now, by doing four things:
1. We’re going to include the [sets] context in the [hotdesk] context, so that our
agents can use the other parts of our dialplan.
2. We’re going to give our agents mailboxes.
3. We’re going to create a new subroutine that will check the hotdesk for an agent,
and a) ring them if they’re there, or b) fire the call off to voicemail if they’re not.
4. We’re going to build dialplan in the [sets] context so that everyone can call our
agents.
Let’s get the mailboxes out of the way first:
MySQL> insert into `asterisk`.`voicemail`
(mailbox,fullname,context,password)
VALUES
276
|
Chapter 15: Relational Database Integration
('1101','Herb Tarlek','default','110111'),
('1102','Al Bundy','default','110222'),
('1103','Willy Loman','default','110333'),
('1104','Jerry Lundegaard','default','110444'),
('1105','Moira Brown','default','110555');
All the rest of the work is in extensions.conf:
Way down at the bottom, let’s craft a subroutine that’ll handle things for us:
[subDialHotdeskUser]
exten => _[a-zA-Z0-9].,1,Noop(Call Hotdesk)
same => n,Set(HOTDESK_ENDPOINT=${HOTDESK_INFO(endpoint,${EXTEN})}) ; Get assigned device
same => n,GotoIf($["${HOTDESK_ENDPOINT}" = ""]?voicemail) ; if blank, send to voicemail
same => n(ringhotdesk),Dial(PJSIP/${HOTDESK_ENDPOINT},${ARG1})
same => n(voicemail),Voicemail(${EXTEN})
same => n,Hangup()
And somewhere far closer to the top, we’ll add our hotdesk users to the section of
dialplan where our other users live:
exten => 110,1,Dial(${UserA_DeskPhone}&${UserA_SoftPhone}&${UserB_SoftPhone})
exten => 1101,1,GoSub(subDialHotdeskUser,${EXTEN},1(12))
exten => 1102,1,GoSub(subDialHotdeskUser,${EXTEN},1(12))
exten => 1103,1,GoSub(subDialHotdeskUser,${EXTEN},1(12))
exten => 1104,1,GoSub(subDialHotdeskUser,${EXTEN},1(12))
exten => 1105,1,GoSub(subDialHotdeskUser,${EXTEN},1(12))
exten => 200,1,Answer()
same => n,Playback(hello-world)
same => n,Hangup()
And finally, back in our [hotdesk] context, we’re going to allow our agents to use the
rest of the phone system:
[hotdesk]
include => sets
exten => _*99110[1-5],1,Noop(Hotdesk login)