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.
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
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.
On the same browser open the following page. Please replace [Client-ID] with the ID created for your company (see create Client-ID):
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.
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:
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.
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.
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.