Hot-Desking (extensions.conf) — Dialplan code
; Hot Desking Feature [hotdesk] ; Hot Desk Login exten => _11XX,1,NoOp() exten => _11XX,n,Set(E=${EXTEN}) exten => _11XX,n,Verbose(1|Hot Desk Extension ${E} is changing status) exten => _11XX,n,Verbose(1|Checking current status of extension ${E}) exten => _11XX,n,Set(${E}_STATUS=${HOTDESK_INFO(status,${E})}) exten => _11XX,n,Set(${E}_PIN=${HOTDESK_INFO(pin,${E})}) exten => _11XX,n,GotoIf($[${ISNULL(${${E}_STATUS})}]?invalid_user) exten => _11XX,n,GotoIf($[${${E}_STATUS} = 1]?logout,1:login,1) exten => login,1,NoOp() exten => login,n,Set(PIN_TRIES=0) exten => login,n,Set(MAX_PIN_TRIES=3) exten => login,n(get_pin),NoOp() exten => login,n,Set(PIN_TRIES=$[${PIN_TRIES} + 1]) exten => login,n,Read(PIN_ENTERED|enter-password|${LEN(${${E}_PIN})}) exten => login,n,GotoIf($[${PIN_ENTERED} = ${${E}_PIN}]?valid_login,1) exten => login,n,Playback(invalid-pin,1) exten => login,n,GotoIf($[${PIN_TRIES} <= ${MAX_PIN_TRIES}]?get_pin:login_fail,1) exten => valid_login,1,NoOp() exten => valid_login,n,Set(LOCATION=${CUT(CHANNEL,/,2)}) exten => valid_login,n,Set(LOCATION=${CUT(LOCATION,-,1)}) exten => valid_login,n,Set(ARRAY(USERS_LOGGED_IN)=${HOTDESK_CHECK_PHONE_LOGINS (${LOCATION})}) exten => valid_login,n,GotoIf($[${USERS_LOGGED_IN} > 0]?logout_login,1) exten => valid_login,n(set_login_status),NoOp() exten => valid_login,n,Set(HOTDESK_STATUS(${E})=1\,${LOCATION}) exten => valid_login,n,GotoIf($[${ODBCROWS} < 1]?error,1) exten => valid_login,n,Playback(agent-loginok) exten => valid_login,n,Hangup() exten => logout_login,1,NoOp() exten => logout_login,n,Set(ROW_COUNTER=0) exten => logout_login,n,While($[${ROW_COUNTER} < ${USERS_LOGGED_IN}]) exten => logout_login,n,Set(WHO=${HOTDESK_LOGGED_IN_USER(${LOCATION},${ROW_COUNTER})}) exten => logout_login,n,Set(HOTDESK_STATUS(${WHO})=0) exten => logout_login,n,Set(ROW_COUNTER=$[${ROW_COUNTER} + 1]) exten => logout_login,n,EndWhile() exten => logout_login,n,Goto(valid_login,set_login_status) exten => logout,1,NoOp() exten => logout,n,Set(HOTDESK_STATUS(${E})=0) exten => logout,n,GotoIf($[${ODBCROWS} < 1]?error,1) exten => logout,n,Playback(silence/1&agent-loggedoff) exten => logout,n,Hangup() exten => login_fail,1,NoOp() exten => login_fail,n,Playback(silence/1&login-fail) exten => login_fail,n,Hangup() exten => error,1,NoOp() exten => error,n,Playback(silence/1&connection-failed) exten => error,n,Hangup() exten => invalid_user,1,NoOp() exten => invalid_user,n,Verbose(1|Hot Desk extension ${E} does not exist) exten => invalid_user,n,Playback(silence/2&invalid) exten => invalid_user,n,Hangup() include => hotdesk_outbound [hotdesk_outbound] exten => _X.,1,NoOp() exten => _X.,n,Set(LOCATION=${CUT(CHANNEL,/,2)}) exten => _X.,n,Set(LOCATION=${CUT(LOCATION,-,1)}) exten => _X.,n,Set(WHO=${HOTDESK_PHONE_STATUS(${LOCATION})}) exten => _X.,n,GotoIf($[${ISNULL(${WHO})}]?no_outgoing,1) exten => _X.,n,Set(${WHO}_CID_NAME=${HOTDESK_INFO(cid_name,${WHO})}) exten => _X.,n,Set(${WHO}_CID_NUMBER=${HOTDESK_INFO(cid_number,${WHO})}) exten => _X.,n,Set(${WHO}_CONTEXT=${HOTDESK_INFO(context,${WHO})}) exten => _X.,n,Goto(${${WHO}_CONTEXT},${EXTEN},1) [international] exten => _011.,1,NoOp() exten => _011.,n,Set(E=${EXTEN}) exten => _011.,n,Goto(outgoing,call,1) exten => i,1,NoOp() exten => i,n,Playback(silence/2&sorry-cant-let-you-do-that2) exten => i,n,Hangup() include => longdistance [longdistance] exten => _1NXXNXXXXXX,1,NoOp() exten => _1NXXNXXXXXX,n,Set(E=${EXTEN}) exten => _1NXXNXXXXXX,n,Goto(outgoing,call,1) exten => _NXXNXXXXXX,1,Goto(1${EXTEN},1) exten => i,1,NoOp() exten => i,n,Playback(silence/2&sorry-cant-let-you-do-that2) exten => i,n,Hangup() include => local [local] exten => _416NXXXXXX,1,NoOp() exten => _416NXXXXXX,n,Set(E=${EXTEN}) exten => _416NXXXXXX,n,Goto(outgoing,call,1) exten => i,1,NoOp() exten => i,n,Playback(silence/2&sorry-cant-let-you-do-that2) exten => i,n,Hangup() [outgoing] exten => call,1,NoOp() exten => call,n,Set(CALLERID(name)=${${WHO}_CID_NAME}) exten => call,n,Set(CALLERID(number)=${${WHO}_CID_NUMBER}) exten => call,n,Dial(SIP/service_provider/${E}) exten => call,n,Playback(silence/2&pls-try-call-later) exten => call,n,Hangup() [hotdesk_phones] exten => _11XX,1,NoOp() exten => _11XX,n,Set(E=${EXTEN}) exten => _11XX,n,Set(LOCATION=${HOTDESK_LOCATION(${E})}) exten => _11XX,n,GotoIf($[${ISNULL(${LOCATION})}]?voicemail,1) exten => _11XX,n,Dial(SIP/${LOCATION},30) exten => _11XX,n,Goto(voicemail,1) exten => voicemail,1,NoOp() exten => voicemail,n,Voicemail(${E}@hotdesk,u) exten => voicemail,n,Hangup()
Hot-Desking (sip.conf), Hot-Desking
(func_odbc.conf), Chapter 5, Dialplan Basics, Chapter 6, More Dialplan Concepts, Read(), CUT,
While(), ISNULL, VoiceMail(),
CALLERID, Dial(), GotoIf()