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.

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


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:

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):


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]

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

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:

We have created a lua-script (without teams) version of our standard BLF key. We plan to ship it in some future version but it is fully compatible already with version 2.0 .. it might even work on 1.10 or 1.8 (both untested) but you should disable the options signalling of missed calls and intercom

So this script has teams-presence 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.

All team-skripts

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

  • en/products/comfortel-d-series/developer/keys/templates/examples/teams_integration.txt
  • Last modified: 13.08.2022 04:00
  • by