Sunday, March 6, 2016

Free IVR and voicemail system for MS Lync/SFB Part 2

Welcome Back. In Part 1 we finished installing asterisk so let start configuring everything.

Asterisk Basic files

  • first you need to configure some basic configuration, you have two options to do so:
    • simple one by just run "make samples" but this will enable a lot of features you may don't need to use them
    • just create two essential files called (asterisk.conf, and modules.conf) and put them in "/etc/asterisk" folder (press on file names to see sample of confiugration).
  • run "service asterisk restart" to reset the asterisk service to update configuration.

Asterisk SIP Trunks configuration

  • The sip configurations are located in file called "sip.conf" at "/etc/asterisk" so create the file and open it.
  • first you need to enable SIP/TCP as a transport as Lync/SFB work only with TCP and asterisk by default support UDP, you could do it by write below configuration, 
  • We will need to have two sip trunks one with Lync/SFB and one with the gateway on same file add below lines
host=<hostname of Lync/SFB FE server>
port=<TCP Port of Lync/SFB mediation>

host=<hostname of gateway>
transport=tcp "you could use UDP of gateway if it doesn't support TCP"
port=<port of Gateway>
  • run "service asterisk restart" to reset the asterisk service to update configuration.

Asterisk IVR sound files

  • First you need to import sound files to asterisk these file should be in .WAV format.
  • According to my workflow from part1 we will need these files "Welcome, Main_Ar, Transfer_Ar, Wrong_Ar, Main_En, Transfer_En, Wrong_En)".
  • Sure you could have you own files and also IVR workflow this is just a sample.
  • The files should have below characteristics to work with
    • If you record in a studio, use 8kHz 16 bits, not 8 bits, and phone line is 12 to 13 bits compressed down to 8 in a pseudo-logarithmic way
    • then down-sample your audio to 8000hz and save in Windows PCM wav (16 bit) format
    • When recording find a really quiet place. Background noise is usually the biggest hassle when recording prompts
    • use a reasonable mic; fix it down someplace (don't hand hold it) 
  • Upload these files to "/var/lib/asterisk/sounds/en/"
  • Then we need to convert them to format that asterisk understand (gsm, or sln) so you should run below command for every file."sox /var/lib/asterisk/sounds/en/Welcome.wav -t raw -r 8000 -s -2 -c 1 /var/lib/asterisk/sounds/en/Welcome.sln"

Asterisk IVR configuration

  • you need to create one of the most important files in asterisk which called "extensions.conf" it is also exist in "/etc/asterisk"
  • first you need to define a number that the Gateway will send all incoming call to it in my configuration below it is "299"
  • According to my workflow from part1 i have written below in the file, sure you need to change it if your workflow is different.
; trunk assign to call received from gateway
; answer the received call on 299 number
exten => 299,1,answer()
; play welcome and wait maximum 3 digit
  same => n,Read(extens,Welcome,3,,,5)
; if the caller didn't give any digits go to arabic IVR_AR
  same => n,gotoIf($[${LEN(${extens})} == 0]?IVR_AR,299,Start) 
; if the caller enter 2 then go to english IVR_EN
  same => n,gotoIf($[${extens} == 2]?IVR_EN,299,Start)
; if the user out 3 digit go to direct to call internal extension
  same => n,gotoIf($[$[${LEN(${extens})} = 3]]?IVR_AR,299,Transfer)
; if non of the above run the message again
  same => 299,6,goto(,299,1)

;arabic IVR section

; play main and wait for 3 digits

exten => 299,1(Start),Read(extens,Main_Ar,3,,,2)
;if the user out 3 digit go to direct to call internal extension
  same => n,GotoIf($[$[${LEN(${extens})} = 3]]?:IVR_AR,299,Start)
; this is the section of direct call of internal ext 
; play transfer msg before dial
  same => n(Transfer),Playback(Transfer_Ar) 
; dial internal ext at lync
  same => n,Dial(SIP/${extens}@Lync) 
; if call answered go to end 
  same => n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?stop) 
 ; if user doesn't exist go to wrong ext
  same => n,GotoIF($["${DIALSTATUS}" = "CHANUNAVAIL"]?wrong) 

; if non of above it mean missed call go to voicemail of this extension
  same => n,VoiceMail(${extens}@default) 

; end call
  same => n,Hangup() 
; this is wrong extension section
; play wrong ext msg
  same => n(wrong),Playback(Wrong_Ar)
; return back to start of arabic IVR_AR
  same => n,Goto(,299,Start) 
; end call
  same => n(stop),Hangup() 

;enlgish IVR same like arabic but with english msgs
exten => 299,1(Start),Read(extens,Main_En,3,,,2)
  same => n,GotoIf($[$[${LEN(${extens})} = 3]|$[${extens} == 0]]?:IVR_EN,299,Start)
  same => n(Transfer),Playback(Transfer_En)
  same => n,Dial(SIP/${extens}@Lync_Out)
  same => n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?stop)
  same => n,GotoIF($["${DIALSTATUS}" = "CHANUNAVAIL"]?wrong)
  same => n,VoiceMail(${extens}@default)
  same => n,Hangup()
  same => n(wrong),Playback(Wrong_En)
  same => n,Goto(,299,Start)
  same => n(stop),Hangup

check  Part 1 and Part 3
See you in part 3 

No comments:

Post a Comment