I would like to create a app which will be informed when a user gets a call in MS Teams. I mean I want to subscribe something on event of incoming call and then do something based on information of incoming call. Is this possible? So far I do not see any events in SDK.
-
Currently we don't support this functionality. We are supporting calling and online meeting bot. [Here](https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/calls-and-meetings/calls-meetings-bots-overview) is the documentation for the same. – Arun-MSFT Mar 05 '19 at 11:33
-
Hi Arun, do you think I can do something similar with Bots? Can you please list steps of the logic? – Sergey Aslanov Mar 06 '19 at 06:56
-
We have example where bot can initiate call behalf of user. I already shared the doc above in that example please check incident bot example where you can find bot initiate the call behalf of user. – Arun-MSFT Mar 11 '19 at 22:18
-
@SergeyAslanov Did you find a way to achieve this in the meantime? It's pretty clear that the provided samples aren't what you (and me) are searching for, since you don't want to call a bot, you want to do some business logic, when the current user is called. Technically it has nothing to do with a bot. I'm very interested, if you have found a solution. – Frébo Jul 30 '19 at 09:40
-
@Frebo, I decided to give up this undertaking since Teams and Phone System APIs aren't rich enough at his point to accomplish this straightforwardly. May be in the future I will return to this task – Sergey Aslanov Jul 31 '19 at 12:19
-
3Don't give up, please insist. I'm doing the same. There are thousands of companies moved to Teams and the real users have urgent and very important problems. MS had promised GA of the Graph Calling API at the end of Q3 . We should insist so MS to provide the basic functionality till then. @Frebo – stefan2410 Jul 31 '19 at 17:02
-
2@Arun-MSFT Any update on this use case ? – Vipulw Aug 17 '20 at 09:12
-
@Sergey Aslanov How real time are you wanting the event, i.e. what is your requirement? Is it to handle calls in real time as in a CTI (telephone integration) scenario. E.g. someone calls, you application could pop a screen with the caller ID populated etc? – Jonny Sep 03 '20 at 10:13
-
@SergeyAslanov I have the same problem, did you solve this? – userSteve Jan 05 '21 at 15:09
-
I'm also looking for a solution to get notified when a call is starting. Did you guys find a way to do it? – Kasun Koswattha Mar 01 '21 at 17:03
-
2This is a question I'm interested in as well. As @Johnny pointed out, I would like to display additional information about an incoming call, probably in a separate window. But there seems no Graph API endpoint to handle that, except the subscription for call records (which is way too slow) – Atmocreations Mar 24 '22 at 08:34
2 Answers
There seems to now be a feature that may suit this.
Call records to provide usage and diagnostic information about the calls and online meetings that occur within your organization when using Microsoft Teams or Skype for Business.
...
Using webhooks and the MS Graph Subscription API, you can receive a continuous feed of call records as they are created.

- 29,788
- 18
- 89
- 130
-
This was something helpful. But couldn't figure out how we create a webhook so that when there is a call in teams my service should know the details. If you can help me somewhere with it ? – Vipulw Aug 14 '20 at 06:13
-
Webhooks sound like a reasonable lead to finding a solution apart from there could be up to a 5 minute delay to you receiving a notification of change. This could be problematical if you are expecting to react to an incoming call in real time? – Jonny Sep 03 '20 at 10:10
-
As I am searching for something like that, too. Here is what I already found: Here is a voting at Microsoft about such a feature: https://microsoftteams.uservoice.com/forums/555103-public/suggestions/38534776-full-teams-client-api-including-call-control Maybe this is possible via graph api? https://learn.microsoft.com/en-us/graph/api/resources/teams-api-overview?view=graph-rest-1.0 And here is an example: https://github.com/microsoftgraph/csharp-teams-sample-graph – Markus Mar 02 '21 at 09:28
-
I had not revisited the question however I think this is now possible via the new subscription API https://learn.microsoft.com/en-us/graph/api/subscription-post-subscriptions?view=graph-rest-1.0&tabs=http – John Mar 02 '21 at 09:39
-
1Unfortunately, MS Graph API (Subscriptions) are not suitable for this. MS says the notification latency is up to 60 minutes for call records. See https://learn.microsoft.com/en-us/graph/webhooks#latency. Also, call records seem to only come into existence once the call is completed, so even aggressive polling wouldn't be helpful. – final Nov 26 '22 at 11:58
I investigated this issue for three days or so. These are my findings:
- The MS Graph API is too slow. See https://learn.microsoft.com/en-us/graph/webhooks#latency.
callRecord
Notifications have a guaranteed latency of <60 minutes. Also,callRecord
s are only created after the call has finished, so they're useless for incoming calls. - I didn't want to write a MS Teams bot for this. I don't want my code to sit between each and every call just to get some information. Also, I think that bots would not work for calling a user's personal number, only for service accounts (Call queues / Auto Attendants).
- The MS Teams client (I only checked on Windows) does not write the phone number into any file before the call is answered. By watching
storage.json
, you can figure out more or less reliable whether the phone is currently ringing, but without the calling number. - The indexedDB cache files eventually contain the calling number, but only once the call is answered. Also, I didn't find a library to read IndexedDB files that are on disk.
- I did not find any third party software that could do this. Some paid Team apps can do this for calls to service accounts (e.g. Landis Contact Center)
The only thing I could come up with was to read the text out of the notification window itself. After a lot of trial, error and pain, I managed to get this:
//needs a COM reference to UIAutomationClient
//using UIAutomationClient;
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern bool IsWindowVisible(IntPtr hWnd);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool IsWindow(IntPtr hWnd);
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
internal static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);
public void GetTeamsCallNotifications() {
do {
var teamsNotificationWindowHandle = FindWindowByCaption(IntPtr.Zero, "Microsoft Teams Notification");
try {
var pUIAutomation = new CUIAutomation();
var windowElement = pUIAutomation.ElementFromHandle(teamsNotificationWindowHandle);
var trueCond = pUIAutomation.CreateTrueCondition();
while (IsWindow(teamsNotificationWindowHandle)) {
//incoming call window has: two buttons (type 50000), a ISO phone number in a group-field (50026), and no text field (50020)
if (IsWindowVisible(teamsNotificationWindowHandle)) {
var elementArray = windowElement.FindAll(TreeScope.TreeScope_Descendants, trueCond);
string number = "";
int noButtonsFound = 0;
var debugFields = new List<string>();
for (int i = 0; i < elementArray.Length; i++)
{
var element = elementArray.GetElement(i);
debugFields.Add($"{element.CurrentControlType}={element.CurrentName}");
if (element.CurrentControlType == 50000)
noButtonsFound++;
if (element.CurrentControlType == 50026 && System.Text.RegularExpressions.Regex.IsMatch(element.CurrentName, @"^\+[1-9][0-9 ]+$"))
number = element.CurrentName.Replace(" ", "");
}
Debug.WriteLine(string.Join(";", debugFields) + "\r\n");
if (noButtonsFound == 2 && !string.IsNullOrEmpty(number))
Console.WriteLine(number + " is ringing");
}
Thread.Sleep(500);
}
}
catch { }
Thread.Sleep(5000); //Teams is probably closed, need a new window handle
} while (true);
}
Some comments:
- The Teams Notification Window always exists when MS Teams runs, it's just either hidden or visible
- There only ever exists one Teams Notification Window, even when multiple notifications are shown.
windowElement.FindAll
will give you all the elements of all notifications. - The code is pretty light-weight
Limitations of this code:
- Windows only, not centralized (i.e. needs to run on every client)
- A change in the layout of MS Teams could break it
- It's unknown whether the call was answered or not.
- A second notification of any kind will break it temporarily (until the second notification disappears).
You can improve on the last limitation if you're willing to accept other limitation. For instance, you can just search all text fields for a phone number. But then the code will trigger if someone sends you a text message containing a phone number. Or you can find the call notification pretty reliably if you know the display language of the Teams client by looking at the caption of the answer / decline buttons.

- 203
- 1
- 8