question

RonAvriel-3361 avatar image
3 Votes"
RonAvriel-3361 asked CharlieChen-9294 answered

Graph change notifications for Teams presence is very limited

Hi,

Only a single Graph change subscription to Teams presence can be created. The second subscription fails with:

 Status Code: Conflict
 Microsoft.Graph.ServiceException: Code: ExtensionError
 Message: Operation: Create; Exception:[Status Code: Conflict; Reason: A subscripton already exists. It must be deleted before a another can be made.]

There is workaround to subscribe to multiple users presence in a single subscription by setting the resource to:
Resource = $"communications/presences?$filter=id in ('{userId1}','{userId2}')"

However, this workaround is very limited because:

  1. Each time a user needs to be added or removed then the single subscription must be deleted and created again. Note that it is not possible to update the subscription with a new resource containing the new list of users. MS Graph silently ignores this update.

  2. If one user in the list cannot be subscribed, then the whole subscription fails without knowing which user failed.

  3. The number of users that can be subscribed this way is limited.



Is there another way to subscribe to multiple users presence effectively?
Are there any plans to allow multiple presence subscriptions ?
Are there any plans to allow an application (not delegated user) permission to subscribe to presence?

Thanks,
Ron

office-teams-app-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JoseySandoval-5919 avatar image
0 Votes"
JoseySandoval-5919 answered RonAvriel-3361 edited

@RonAvriel-3361, as you've correctly noted, only one subscription per user can be created at a time (each subscription can include up to 650 targets/IDs). Presence subscriptions are best suited to scenarios such as a user monitoring the presence of frequent contacts or team mates. By creating subscriptions using multiple users, each subscribing to 650 separate targets, you can leverage the subscription API to monitor a larger number of users depending on your use case. However, it may be more effective for you to use the getPresencesByUserId API, batching IDs into a single request (again, up to 650). Here, you can make multiple requests with the same user.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@JoseySandoval-5919 , my requirement is to subscribe to multiple users presence change, not to constantly poll them.

The current model of a single subscription to multiple users is very limited because:

  1. At around ~70 users the change notification subscription request fails with "Message: Operation: Create; Exception: [A task was canceled.]"

  2. If a single target user subscription (out of 650) fails, then all other (649) subscriptions are canceled and need to be re-subscribed. In addition, the failed user must somehow be parsed from the exception text message.

  3. Each time a Teams user needs to be added or removed then the single subscription must be deleted and created again. It is not possible to update the subscription with a new resource containing the new list of users.

IMHO, multiple independent change subscriptions, each targeting a different Teams user, should be supported.

2 Votes 2 ·
CharlieChen-9294 avatar image
0 Votes"
CharlieChen-9294 answered

Hi @JoseySandoval-5919

May I ask a question about "By creating subscriptions using multiple users, each subscribing to 650 separate targets, you can leverage the subscription API to monitor a larger number of users depending on your use case"

Do you mean every user can call the API to create a separate subscription? Which means it can work around creating more than 1 subscription for all users?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.