Sunday, March 13, 2016

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

Welcome Back. In Part 1 and Part 2 we finished installing asterisk and configured IVR in this part we will confiugre voicemail and SFB/Lync side.

Install postfix on linux

  • First you need to remove sendmail and install postfix to make it default mail client on the voicemail server.
  • To remove snedmail run "yum remove sendmail".
  • To install postfix run "yum -y install postfix mailx cyrus-sasl-plain" .
  • You need to create a new file with name "/etc/postfix/sasl_passwd" with your mail account smtp server and credentials in the following format:
smtpserver.yourdomain.com    emailaddress@yourdomain.com:emailpassword
  • Then you need to hash your password file by run "postmap hash:/etc/postfix/sasl_passwd"
  • Open the /etc/postfix/main.cf and add following lines.
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
# Secure channel TLS with exact nexthop name match.
smtp_tls_security_level = secure
smtp_tls_mandatory_protocols = TLSv1
smtp_tls_mandatory_ciphers = high
smtp_tls_secure_cert_match = nexthop
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
relayhost = smtpserver.yourdomain.com
  • You could change tls confiugration according to your SMTP server.
  • Some times you will need to change the from email address in the header of sent mail so you need to create two additional files "/etc/postfix/header_checks,canonical" check this URI for more details http://tech.gate.io/postfix-sender-address-rewriting-changing-mails-from-field-in-header-on-relay-server/
  • Then restart the postfix service by "service postfix restart".
  • Test sending mail by run "echo 'Test mail from voicemail system' | mail -s 'test mail' -r 'voicemail system <emailaddress@yourdomain.com>' testemail@hotmail.com".
  • To troubleshoot you could find the logs in "/var/log/maillog"
  • Once you send the mail check your email to see if you received the email and then you can go ahead and remove the text password file by run "rm /etc/postfix/sasl_passwd".

Configure asterisk voicemail

  • first copy the voicemail sample file from sample to asterisk directory by run "cp /usr/src/asterisk*/configs/vociemail.conf.sample /etc/asterisk/voicemail.conf"
  • If you need more details on how to configure the voicemail file just read the sample file comments, but I'll go through basic needs.
  • To change from name check "fromstring="
  • To change the subject check "emailsubject="
  • To change the body check "emailbody="
  • Now we will configure the voicemail boxes by write the following under "[default]" section
user 3 digit extension=> 1234,user display name,user email address
  • repeat this line for every user you need to send him voicemail.

Configure missed call notification

  • Now let's configure the missed call notification open "/etc/asterisk/extensions.conf".
  • write following line at end of "[IVR_EN]" and "[IVR_EN]" sections.
exten => h,1,GotoIf($["${DIALSTATUS}" = "ANSWER"]?:Missed,${extens},1)
  • Write "[Missed]" in the end of the file.
  • Under "[Missed]" section write.
exten => user 3 digit extension,1,System(echo 'You have Missed Incoming Call From: ${CALLERID(num)} <${CALLERID(num)}>  Received at : ${STRFTIME(${EPOCH},,%d-%m-%Y-%H:%M:%S)}' | mail -s 'New Missed Call' -r 'voicemail system <emailaddress@yourdomain.com>'  user email address)
  • Repeat this line for every user you need to send him voicemail.
  • Restart asterisk service.

Configure SIP trunks @ SFB/Lync and @ voice gateway

  • From Lync/SFB side it is similar to create SIP trunk with any gateway it was written a lot in other blog so no need to duplicate it here but to summarize you need to do the following.
    • Create SIP trunk with IVR using port 5060 at both sides.
    • Create SIP trunk with Voice gateway.
    • Route external calls to Voice gateway.
  • About voice gateway it depend upon your gateway, but you need to do the following:
    • Create sip trunk with IVR server using port 5060 for each side using TCP as transport.
    • Create sip trunk with Lync/SFB.
    • Route 299 calls to IVR system.
    • Route DID to Lync/SFB direct.
  • I'll provide in next blogs examples on how to configure most gateways which integrate with Lync/SFB.

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, 
[general]
tcpenable=yes
tcpbindaddr=0.0.0.0
transport=tcp,udp
  • We will need to have two sip trunks one with Lync/SFB and one with the gateway on same file add below lines
[Lync]
disallow=all
host=<hostname of Lync/SFB FE server>
type=peer
insecure=port,invite
transport=tcp
port=<TCP Port of Lync/SFB mediation>
context=Lync-Trunk
dtmfmode=RFC2833
allow=alaw
allow=ulaw

[Gateway]
disallow=all
host=<hostname of gateway>
type=peer
insecure=port,invite
transport=tcp "you could use UDP of gateway if it doesn't support TCP"
port=<port of Gateway>
context=Gateway-Trunk
dtmfmode=RFC2833
allow=alaw
allow=ulaw
  • 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
 [Gateway-Trunk]
; 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
[IVR_AR] 

; 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
[IVR_EN]
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 

Wednesday, March 2, 2016

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

The problem

I faced a problem a lot when implementing Lync/SFB as IP PBX, it is IVR and attendant systems.
I heard requests from customer like:
  • Why I need MS exchange if I'll only install Lync/SFB.
  • I need to change the language of all prompts not only greeting and so on.
  • I need more options and flexibility in the IVR option (example, inform caller of transferring the call while calling the internal extension)
  • I have google cloud and need to have missed calls and voice mails to be sent to users email
also I faced a lot customers have Exchange online and when we integrate it with Lync/SFB we experience delay till the call answer by exchange auto attendant and I think it is due to the fact that exchange is on internet , we opened  a lot of tickets with MS and apply all possible QoS methods with slightly enhanced but it still noticed by the caller.

We was about to loss or lost a lot of hot opportunities cause of things like this.

The Solution

so what is the solution ??!!.

It is 3rd party IVR and voicemail system which I developed by myself using Asterisk PBX and Postfix on a Linux machine.

The Design

  • As blow image I insert the IVR system in middle of incoming calls between Voice gateway and Lync/SFB system while leaving the outbound call path as it is.
  • All incoming calls pass through IVR first then it answer the call and run the prompts as needed workflow, and waiting to get the caller digits.
  • Then the IVR system transfer the call of Lync/SFB with monitoring the status of the call if didn't answered the IVR contact the mail server and send voicemail and/or missed call notification mail to the called person.

  • I already have basic IVR workflow as below image which I will represent it in this blog

Installation of IVR

First I won't go though Linux installation also you could choose any distribuation of Linux but to use the same commands for asterisk installation, use Centos 6.x.

for Asterisk installation do below:
  • Update Centos
yum update -y
  • Disable firewall
sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -F
iptables -X
/etc/init.d/iptables save

    • Install prerequisites
    yum install -y make wget openssl-devel ncurses-devel newt-devel libxml2-devel kernel-devel gcc gcc-c++ sqlite-devel
    • Download Asterisk Source
    cd /usr/src/
    wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-11-current.tar.gz
    • Extract and Install Asterisk
    tar zxvf asterisk*
    cd /usr/src/asterisk*
    for 32 bit:
    ./configure && make menuselect && make && make install
    for 64 bit:
    ./configure --libdir=/usr/lib64 && make menuselect && make && make install
    • Start asterisk
    service asterisk start
    asterisk -rvvv

    check  Part 2 and Part 3

    Thursday, October 1, 2015

    Lync/SFB Pickup Group

    While we are in middle of Skype for Business deployment for one of our customers he asks us something he used to do in his Legacy PBX.

    He told us that any phone set could pickup the call of another one phone ringing by just pressing his extension with specific prefix, As example if phone extension is 100 and another phone with extension 101 ringing he just press #101 then the call will be transferred to extension 100 and answered by it.

    After some googling and for my own surprise we found that Microsoft Lync/S4B has feature called "Group Call Pickup" that enables Enterprise Voice users to pick up calls that are ringing for another user by dialing a call pickup group number, below are the steps we used to configure it at customer:


    Configure Group Call Pickup number ranges

    The first step is to configure the Group Call Pickup range, It is similar to Call Park range definition, but you should know that you must use Lync Server Management Shell to create, and view Group Call Pickup, Managing Group Call Pickup number ranges are not available in Lync Server Control Panel.

    Our customer has the range of 1xx to 6xx and he used to press 8 before the ringing extension to pickup the call so we defined the range as below command
    "New-CsCallParkOrbit -Identity CallPickUp -NumberRangeStart 8100 -NumberRangeEnd 8699 -CallParkService <service ID of the Application service> -Type GroupPickup"

    To check that it is configured correctly we run "Get-CsCallParkOrbit" and the result was as below:
    Identity           : CallPickUp
    NumberRangeStart   : 8100
    NumberRangeEnd     : 8699
    CallParkServiceId  : ApplicationServer:<pool FQDN>
    CallParkServerFqdn : <pool FQDN>
    Type               : GroupPickup

    To get the service id you could run"Get-CsService -ApplicationServer"

    Assign Group Call Pickup numbers to users

    We use SEFAUtil to assign Call Pickup numbers to each user for more details on how to install it check below this https://technet.microsoft.com/en-us/library/jj945659.aspx

    First we check it with Pilot user with running below command
    "SEFAUtil.exe <pilot user sip uri> /server:<lync pool> /enablegrouppickup:8299"

    To check that it is configured correctly we run "SEFAUtil.exe <pilot user sip uri> /server:<lync pool>

    Then we make a call to 299 and while it ringing from third phone we press 8299 and call transferred to this phone with announcement to the caller that the call is answered by another person which was additional feature customer was happy with it.

    Now we tested it but we need to deploy on all the users so will go to scripting :) we create CSV file with "SIP,Number" as "sip uri, pickup number" and we write below sript

    $pickup=import-csv "C:\SEFAUtil\CallPickup_numbers_full.csv"
    foreach ($pi in $pickup)
    {
    $number=$pi.Number
    C:\SEFAUtil\SEFAUtil.exe $pi.SIP /server:pool01.dur.sa /enablegrouppickup:$number
    }


    And everything is working good now.

    At last i would like to thank my colueage Ahmed Mostafa who helped me on this issue.

    Tuesday, September 29, 2015

    Polycom VVX phones with UCS 5.4.0 Rev.A now support Skype for business Online.

    Polycom released new UCS version 5.4.0 Rev.A in 25-Sept-2015 which include below features.

    Microsoft Office365 and Skype for Business Online

    • The most interesting one is the support of Office365 and S4B online which a lot of customer ask for it.
    • The PIN authentication will not be supported in S4B online.
    • This features also supports the migration of users from the Skype for Business on premise solution to the Office365 online solution.
    • Polycom phones support Skype for Business Online and Exchange Online services only.
    • Exchange Online is not supported on SoundStructure VoIP Interface. Skype for Business and Exchange Online are not supported on VVX 101 and 1500 phones.

    In-band Provisioning

    •  Similar to Snom phones now you can provision the phones from S4B direct without needing to have separate server for provisioning.
    • Administrators can also migrate user information from a Lync on-premises solution to an Office365 online solution.
    • Administrators can switch between Lync or Skype for Business on-premise and Skype for Business Office365 online deployments without interrupting services
    • Below table the list of feature you could configure from S4B.
    • I'll prepare blog for details on how to configure it soon.
    UC Software Parameter
    Skype for Business Parameter
    dialplan.userDial.timeOut
    UserDialTimeoutMS
    feature.btoe.enabled
    EnableBetterTogetherOverEthernet
    feature.exchangeCalendar.enabled1
    EnableExchangeCalendaring
    device.prov.lyncDeviceUpdateEnabled
    EnableDeviceUpdate
    device.prov.lyncDeviceUpdateEnabled.set
    voice.volume.persist.handsfree
    VoiceVolumePersistMode
    voice.volume.persist.headset
    voice.volume.persist.bluetooth.headset
    voice.volume.persist.usbHeadset
    voice.volume.persist.handset
    powerSaving.enable
    EnablePowerSaveMode
    powerSaving.idleTimeout.officeHours
    PowerSaveDuringOfficeHoursTimeoutMS
    powerSaving.idleTimeout.offHours
    PowerSavePostOfficeHoursTimeoutMS
    up.screenCapture.enabled
    AllowScreenCapture
    up.oneTouchVoiceMail
    EnableOneTouchVoicemail
    device.prov.user
    LocalProvisioningServerUser
    device.prov.user.set
    device.prov.serverType
    LocalProvisioningServerType
    device.prov.serverType.set
    device.prov.password
    LocalProvisioningServerpassword
    device.prov.password.set
    device.prov.serverName
    LocalProvisioningServerAddress
    device.prov.serverName.set

    other features


    • When users sign into Skype for Business on their phone, they can choose to set the time zone, time format, and date format before they start using their phone, This feature is disabled by default.
    • Modified the encoding modes on the onscreen keyboard for VVX 500 and 600 phones.
    • Removed the Pin Authentication feature when the phone is operating in a Skype for Business environment where STS-URI is not configured either through DHCP Option 43 or configuration parameters. 
    • Updated the Lync Status menu in the Web Configuration Utility to show status information for all Skype for Business and Office365 features to support debugging and managing Skype for Business and Office365. 
    • Modified some existing parameters and removed the need for a reboot after the parameters are modified. 
    • Added a single installation package for the Polycom Better Together over Ethernet (BToE) application. 
    • Added support to launch the Web Configuration Utility from the Polycom BToE application. 
    • Added support for Office365 wildcard certificates supported on Microsoft domains.
    To get the firmware S4B CAB version check this URI, for normal update check this URI.
    for more information please check below URI: