Updating Slack status to reflect Zoiper5 call state using Slack API.

Github page – https://github.com/james-reed/zoiper-slack-status

I wanted a simple way of having my Slack status automatically update when I take a phone call using Zoiper. The majority of VoIP handsets or softphones support the opening of a URL during a certain event such as picking up or ending a call – which can be leveraged for various uses as you can imagine. Zoiper supports this method, but also has ability to execute files/applications on such events. In this particular project, when a phone call is answered Zoiper will launch set-status-in-call.pyw and pass the incoming caller ID using {number} which is one of a few supported Zoiper variables.

Full list of Zoiper variables here

If an incoming call from 0212345678 is answered, then the Slack status will change to Currently in a call with 0212345678 with the telephone_reciever emoji set.

Once the call is hung up, Zoiper will launch set-status-clear.pyw on that particular event which then clears the Slack status out.

The use of the .pyw extension will make the code execute in the background instead of popping up a command window or similar – as you’ll see if running this on Windows.

Setup

  1. You’ll want to install Python on your device. This has been tested using Python v3.6.x but should be fine with ~v2 if you’re using that.
  2. You will need the Python “requests” module which can be installed with pip install requests
  3. You will need your Slack API token. At the time of writing it’s possible to grab this by logging into the Slack via your web browser and then using the developer tools in your web browser to perform inspections when making a change such as updating your status. You should be able to comb through and grab your API token – further information on doing this is outside of the scope of this documentation. Once you have your API token, replace the YOUR_SLACK_TOKEN_GOES_HERE variable with your actual token.
  4. Setup your Zoiper client as per the following screenshots. In Zoiper5 you can add Event Rules under Settings > Features > Automation > Edit Open URL Rule

Create a rule for when the call state changes to Answered and point it to set-status-in-call.pyw {number}

Create a rule for when the call state changes to Hang Up and point it to set-status-clear.pyw {number}

Set Slack status phone BLF with Zoiper5 – without API access.

I’m sharing in this post an older and not really ideal at all method to automatically change your Slack status when taking a call using Zoiper5. The ideal way to achieve this is to have some integration between your PBX and Slack so that user statuses can be changed based on the extension BLF status. The other ideal way would be to use the Slack API. If you find yourself in a situation where you don’t have permissions to work in either of these realms – this is a janky but working solution!

In this guide we’re using a Windows OS environment, and AutoHotKey.

For this I’m just placing these files on the desktop but you can put them anywhere you’d like, just make sure inside the “slack-set*” scripts you update the Include path for “TrayIcon.ahk” to the location you’ve placed that file.

Download “TrayIcon.ahk”

Download “slack-set-in-call.ahk”

Download “slack-set-call-finished.ahk”

Inside Zoiper5 (you will need a licensed copy to do this)

Create two rules as below –

Go to Settings > Automation > Event Rules > Add Rule

OnCall status change
Call State changes toAnswered
And call direction isBoth Incoming and Outgoing
Do action Open/Execute Application
Open URL/RUNC:\Users\james\Desktop\slack-set-in-call.ahk

On – Call status change
Call State changes toHangup
And call direction isBoth Incoming and Outgoing
Do actionOpen/Execute Application
Open URL/RUNC:\Users\james\Desktop\slack-set-in-call.ahk

Your Slack status will now automatically change when you take a call and when you hangup that call. This all happens very quickly but obviously due to how this method works, if you focus onto a different app the moment this script runs then it’ll mess up. All this method does is bring the Slack window into focus and slam in a “/status” command. I always have my Slack window open on one of my monitors and haven’t had any issues myself using this crude method.

FreeNAS CPU core and disk temperature check script

This is a nice simple script to display CPU core and disk temperatures on a FreeNAS server. Tested with FreeNAS 9.10.2-U1


Create a file with the following content – Mine is just called “temps_check_script.sh” as an example.

# Write some general information
echo System Temperatures - `date`
uptime | awk '{ print "\nSystem Load:",$10,$11,$12,"\n" }'

# Write CPU temperatures
echo "CPU Temperature:"
sysctl -a | egrep -E "cpu\.[0-9]+\.temp"

# Write HDD temperatures and status
echo "HDD Temperature:"
for i in $(sysctl -n kern.disks | awk '{for (i=NF; i!=0 ; i--) if(match($i, '/da/')) print $i }' ) ; do
echo $i: `smartctl -a -n standby /dev/$i | awk '/Temperature_Celsius/{DevTemp=$10;} /Serial Number:/{DevSerNum=$3}; /Device Model:/{DevVendor=$3; DevName=$4} END {printf "%s C - %s %s
(%s)", DevTemp,DevVendor,DevName,DevSerNum }'`;
done


Run it with ./temps_check_script.sh – The output looks like this:

System Temperatures - Wed Jun 21 07:53:16 AEST 2017

System Load: 0.17

CPU Temperature:
dev.cpu.3.temperature: 40.0C
dev.cpu.2.temperature: 44.0C
dev.cpu.1.temperature: 40.0C
dev.cpu.0.temperature: 42.0C

HDD Temperature:
ada0: 27 C - Hitachi HDS5C3020ALA632 (SERIALNUMBERGOESHERE)
ada1: 27 C - Hitachi HDS5C3020ALA632 (SERIALNUMBERGOESHERE)
ada2: 27 C - Hitachi HDS5C3020ALA632 (SERIALNUMBERGOESHERE)
ada3: 28 C - Hitachi HDS5C3020ALA632 (SERIALNUMBERGOESHERE)
ada4: 28 C - Hitachi HDS5C3020ALA632 (SERIALNUMBERGOESHERE)
ada5: 27 C - Hitachi HDS5C3020ALA632 (SERIALNUMBERGOESHERE)
da0: 32 C - TOSHIBA MD04ACA400 (SERIALNUMBERGOESHERE)
da1: 31 C - TOSHIBA MD04ACA400 (SERIALNUMBERGOESHERE)
da2: 29 C - TOSHIBA MD04ACA400 (SERIALNUMBERGOESHERE)
da3: 30 C - TOSHIBA MD04ACA400 (SERIALNUMBERGOESHERE)
da4: 31 C - TOSHIBA MD04ACA400 (SERIALNUMBERGOESHERE)
da5: 30 C - TOSHIBA MD04ACA400 (SERIALNUMBERGOESHERE)