Hotdesk solution of 10 lines of code

I have been playing around with the idea of making a hot desk solution as simple as possible and I ended up with 10 lines of Asterisk script and it is working :slight_smile:

You can add global variables that start with PHONE to represent every registered sip phone and then the number, as much as needed without the need of adding code. You just dial 1111 and enter the number of the line that you want to receive on that particular phone. You can link as many phone numbers to a phone as you like/need.

You have to record a voice prompt that sounds something like:" Please enter the number that you want to receive the calls from on this phone". I hope it will be useful to someone.

Happy coding
/EdW

You can use this Asterisk lines to actually make the recording after you add a “hot desk” directory to /var/lib/asterisk/sounds/
exten => 773,1, PlayBack(hotdesk/instructie)
exten => 773,n, Wait(5)
exten => 773,n, Record(hotdesk/instructie.gsm)
; Voer het telefoonnummer in van de lijn die je op deze telefoon wilt binnen krijgen.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; auteur: Erik de Wild
; mail erik@wildsound.nl
; date: 07-11-2016
; the Netherlands
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; license:
; GPL3. You are free to use it as long as you grand the credits to the auteur. If you copy
; the script please copy this heather (from auteur to [globals]) with it and don’t
; charge money for the script as it is (it is also free for others). If you need adjustments or extras
; or something completely new feel free to contact me.
;
; Happy coding
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[globals]
PHONE5556 => 5556
PHONE5557 => 5557
PHONE5558 => 5558
PHONE5559 => 5559
PHONE1111 => 1111
; etc. etc.

[test]
exten => _XXXX,1,Answer()
exten => _XXXX,n, Set(NUMBER_TO_CALL=${EXTEN}) ; the underscore between NUMBER and To
; doesn’t show on the screen while it is
; really there.
exten => _XXXX,n,Goto(hotdesking,s,1)

[hotdesking]

exten => s,1(begin), NoOp(start hotdesking routine)
exten => s,n, GotoIf($[ “${NUMBER_TO_CALL}” : “1111”]?1111,1)
exten => s,n, Dial(SIP/${PHONE${NUMBER_TO_CALL}})
exten => s,n, Hangup()

exten => 1111,1, Read(HOTDESK_LOGIN,hotdesk/instructie,4)
exten => 1111,n, Set(HOTDESK_LOGIN=PHONE${HOTDESK_LOGIN})
exten => 1111,n, Set(GLOBAL(${HOTDESK_LOGIN})=${CALLERID(num)})
exten => 1111,n, HangUp()

[quote=“lesouvage, post:1, topic:68665”]
[test]
exten => _XXXX,1,Gosub(hotdesking,${EXTEN},1)

[hotdesking]

exten => _XXXX,1(begin), NoOp(start hotdesking routine)
exten => _XXXX,n, Dial(SIP/${PHONE${EXTEN}})
exten => _XXXX,n, Return()

exten => 1111,1, Read(HOTDESK_LOGIN,hotdesk/instructie,4)
exten => 1111,n, Set(HOTDESK_LOGIN=PHONE${HOTDESK_LOGIN})
exten => 1111,n, Set(GLOBAL(${HOTDESK_LOGIN})=${CALLERID(num)})
exten => 1111,n, Return()
[/quote]

I think I saved you a line or two :slight_smile:

1 Like

I think you have to add two Answer() lines this way to make it work (but I haven’t tested it)

For CDR reasons I only answer when I want the CDR marked answered, Therefor when I’m dialing a device I never answer before the dial.

You can process dialplan without answering just fine for the _XXXX extension, Now the 1111 extension may need an answer but I believe the Read application will answer for you to play back media.

Thanks for your respons. Using Answer() seems to be just a habit for me. As far as I knew that was needed to make it all work. The point of the script is that it shows why I like Asterisk that much. With just a couple of lines solutions can be build that used to cost lots of money or couldn’t be build at all.

1 Like

In the original post I forgot to translate the voice prompt when using the hot desk service. This is the same part with an English text.