Skip to content

Microsoft Teams#

Microsoft is providing a beta API for Teams hat which they might change at an time. The scripts we provide here were tested and working in 2020/21. We do NOT commit ourselves at this moment to update these scripts should the API change at some point.

We've created a handfull of scripts to show the presence-state from microsoft's teams on our phones. The installation is quite complex, please follow every step carefully.

Create Client-ID#

To allow the phones to access the Teams-API your admin must once create a client-id in teams. Please follow the steps in this document: create_client_id_in_teams.docx

Refresh-skripts#

We have created these scripts that login in to the Teams-API. They run in the background on your phone and keep refreshing the API-credentials so that your phone and any teams-keys on it have access. Please take these scripts, insert the Client-ID (replace 2 occurrences of [Client-ID] with actual client-id) and provision them onto your phone(s).

Once a phone gets these scripts you now need to provide them the initial login-credentials for the user that is to be using that phone. I.e. this has to be repeated for every phone:

Sign user into Microsoft Azure#

The user (of the phone in question) must open https://azure.microsoft.com/en-us/services/active-directory/ on its machine and browser and sign in using its credentials. Now the browser is authorized to microsoft to create the access-tokens for that user.

Create access-tokens#

On the same browser open the following page. Please replace [Client-ID] with the ID created for your company (see create Client-ID):

https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?client_id=[Client-ID]&response_type=code&redirect_uri=https://login.microsoftonline.com/common/oauth2/nativeclient&scope=offline_access%20presence.read%20user.readBasic.all
Once you hit return you might think nothing has happend because the browser opens a blank page. But the address bar of your browser will have changed slightly and now contains the code that the phone needs to gain access to the API. Copy the entire URL (including all that stuff behind the ?) and send it to the phone by opening the following page on your phone:
https://[IP of the phone]/api/v1/exec/getTeamsCode?[copied URL]

eg: https://192.168.0.200/api/v1/exec/getTeamsCode?https://login.microsoftonline.com/organizations/oauth2/...

The phone should now have access to the teams API and is refreshing every 50 minutes. You can verify that this step was successful by downloading the phones logfile. Everything worked out if you find a line containing Teams Automatic Token Refresh: updating tokens.

Key templates#

Teams email#

All teams-template-keys have an email-parameter to identitfy the person whose presence-state is to be signaled. This is not necessarily the person's normal email (but it could be). To find out look up the person in https://azure.microsoft.com/en-us/services/active-directory/ and find it's User Principal Name -> thats the email you need to monitor its presence using one of these keys:

Teams BLF#

This script is a version of our blf key with teams included. It will replace the standard speed-dial with the new version. You need to create new speeddial-keys via the phone or web UI, existing keys are not changed automatically (before version 2.2). You'll then find a new parameter at the end which asks for the teams email-address.

Teams Monitor#

This presence key only shows the availability of someone as the teams-API reports it. Nothing happens when you press this key. It may be usefull as a stripped-down example of how to access the teams-state from lua-scripts/-keys.

Teams DND#

This key is to be used to monitor the users own presence. Pressing the key does nothing but when the script detects that the user is un-available it automatically sets DND for it in the PBX. When user is available again the DND is disabled again. This script could be enhanced to set call-forwarding to the users cellphone when he is reported to be away.

All team-skripts#

Use this file to conveniently upload/provision all team-scripts at once. Don't forget to insert the client-id though.