Can list messages but cant create subscription - microsoft-graph-api

I have an app that creates subscriptions for office365 users and does something whenever it gets a notification.
For 99% of users it works fine.
There's one user that I can't create subscription for even though he has an enabled exchange plan.
When I try to create subscription for him I get status code 404 and message: REST API is not yet supported for this mailbox.
However, I can list the user messages (i.e. mails) with API (GET request to https://graph.microsoft.com/v1.0/Users/{user_id}/messages)
Is it normal behavior? That user have no rest services enables for his mailbox (and therefore cant create subscription) but other rest services such as listing messages works just fine?

You are most likely getting this error because the organization has an hybrid deployment (Exchange on prem "linked" to the organization) and the mailbox that's failing is located on premises, not in the cloud.
Your application should handle the error and/or let the administrators know that this mailbox is failing, but there isn't much that can be done besides migrating the mailbox. For reference

Related

Is there any way to get user id/conversation reference to proactively message user on teams if installation event wasnt captured

Looking for the best course of action that would have the least impact on users to be able proactively message users with teams app (bot) installed but where they have not messaged the bot and the conversation reference was not captured at time of install.
The scenario is that have an enterprise bot that has been operational for over 3 years servicing 10s of thousands of employees. The bot is auto installed for all users in the tenant, but conversation references were only being stored in the last 2/3's of the applications life, and the install event was not being captured until recently. This was not an issue in past as all proactive functionality was predicated on some interaction with the bot.
I now have a need to be able proactively messages all users within tenant regardless of if they have messaged the bot or not, or if they last messaged the bot before conversation references were being stored. There are only a small subset of users the fall into this category.
Hoping some way to generate a conversation update, be it through graph or other means. The installationUpdate event through app update seemed promising as can update the application but seems only triggered if bot is added or removed
Review the information provided here: https://learn.microsoft.com/en-us/microsoftteams/platform/graph-api/proactive-bots-and-messages/graph-proactive-bots-and-messages?tabs=dotnet
Here is what we do
If we have the conversation ID in our cache/persistent store, we use
it to send the message
If we dont have, we use GET
https://graph.microsoft.com/v1.0/users/{user-id}/teamwork/installedApps/{teamsAppInstallationId}/chat
to get the chatid (the app id here is not the bot application ID, but the ID generated when the app is installed in the org app store and is available from the Teams Admin interface)
If the user does not have our app installed, we
install the app using the teamsAppInstallationId ID. This automatically generates a event without user intervention that
is sent to the bot which you can then use to capture the conversation ID.
POST /users/{user-id | user-principal-name}/teamwork/installedApps
This approach does require an Application Permission: TeamsAppInstallation.ReadWriteSelfForUser.All
You might look into using the List Teams functionality in the Graph API. You can use Graph to get teams and list their members, assuming you can grant your bot the necessary permissions. There are many features in the Graph API which might help you accomplish this.
To send a proactive message to user the bot requires the conversation reference. The conversation can be only retrieved when bot installed.
Without conversation reference you cannot send a proactive message using bot.
You can use Send message in a chat API to send message to chat with delegated permissions.
Could you please raise a uservoice for your case

MS Teams - Sending Messages to Users from External App

The organization that I work for previously used Slack as our collaboration tool. With Slack, I was able to register an app in the workspace and use the provided access tokens to invoke the API to send a message to a user from our external web application. It was very straightforward. There was no intermediate app that needed to be coded to enable this messaging.
Recently, we've transitioned from Slack to MS Teams, and in looking over the Graph API documentation, there does not currently appear to be a way to proactively send a message from an external application to a user. The available permissions for the chatMessage endpoint indicate the availability of only a delegated permission to send a message on behalf of a specific user; no permission exists to send a message on behalf of an external application.
Is it possible to use the Graph API to directly send a message from an external application to a user? Or must a bot application be created in order to achieve this?
It must be a bot application to achieve above mentioned requirement. ChatMessage endpoint works to send a message on behalf of user only.

Microsoft Graph API callRecords Subscription not receiving notifications

I am currently evaluating Microsoft Teams Graph API endpoints for us and our customers. Our goal would be to compile a list of past callRecords for a specific user.
Since the API does not (currently) offer an endpoint to just fetch a list of past/done callRecords we need to subscribe to the /communications/callRecords notifications.
Using the example project specified in the documentation ( https://github.com/microsoftgraph/nodejs-webhooks-rest-sample) we successfully created subscriptions and were also able to update these subscriptions (not part of the example project).
I am running the example project on my local machine using ngrok as suggested.
So far everything works, but we do not get any notification. I made various calls with the Teams Desktop App using the same user that gave admin consent for accessing callRecords but I never received a notification on any test subscription.
The current active subscription in question is "07b23247-66d9-46b9-ac67-a72d5d702628" and was created around 2020-09-09T09:20:00.000Z (I do not have the precise minute/seconds). It since then has also been successfully renewed.
Here is an extract of the subscription creation response:
{
'#odata.context': 'https://graph.microsoft.com/beta/$metadata#subscriptions/$entity',
id: '07b23247-66d9-46b9-ac67-a72d5d702628',
resource: '/communications/callRecords',
changeType: 'created',
expirationDateTime: '2020-09-12T07:20:09.036Z'
}
I do monitor all incoming traffic using ngroks http://127.0.0.1:4040 endpoint and so far I only received the validationToken requests. That tells me that the endpoint does indeed receive requests.
I am currently at a loss as where to look further for an error on my side.
I opened this stack overflow is as it is the requested action to take according to the troubleshoot section of the example project (https://github.com/microsoftgraph/nodejs-webhooks-rest-sample/blob/master/TROUBLESHOOTING.md).

What OAuth Scopes are required for a listen & reply Slack Bot using the Slack Events API?

I am trying to make a bot that will listen to all public & private channels, and IMs for a team, and will reply when it sees certain trigger words. This will be a "Slack App", installable to your team using the "Add to Slack" button, and includes a "Bot User".
I have asked for the "bot" OAuth scope, and subscribed to the "message.channels,message.groups and message.im" Team Events (at https://api.slack.com/apps/myAppId/event-subscriptions) but do not appear to receive event POSTs through the Events API when new messages are sent.
Adding the "channels:history,groups:history,im:history" scopes makes the bot receive these event POSTs, but I believe only for the user that added the bot, so it will not watch groups that the adding-user was not a member of, or IMs between 2 other users. This means that behaviour will be different, depending on which user installed my bot.
Is there a way of installing the app/bot for an entire team? The documentation seems to indicate that a 'bot' scope should have the ability to receive events, but I am not seeing this (I require the channels:history scope etc. above).
bot - request this scope when your Slack app includes bot user functionality. Unlike incoming-webhook and commands, the bot scope grants your bot user access to a subset of Web API methods, the RTM API, and certain event types in the Events API.
(from https://api.slack.com/docs/oauth-scopes)
The page on bots also claims that a bot can receive all messages through the RTM API:
This websocket will send you all of the messages and activity that happen in public and private channels that the bot user is invited to, as well as messages that are sent to it via direct message. A bot user opens this websocket with the RTM API by sending an authenticated call to the rtm.start API method. To learn more about connecting to the RTM API, read the documentation here.
(from https://api.slack.com/bot-users)
Is this same behaviour possible in the events API without needing to use the RTM API or add those additional scopes mentioned above?
I see from your comment that you have understood that the bot scope (and the channels.message Events subscription) allows your bot to receive from channels it is present in.
You have two options
1) you ask for channel.write scope in addition to bot, and you invite the bot in all channels (using the user token, not the bot token)
2) you work on your onboarding and figure out a way to get your "champion", ie the user who installed your app, to invite your bot in relevant channel.
Keep in mind that solution 1) is usually seen as very intrusive, especially in large teams where most people haven't heard of your app nor taken the decision to install it. But it can be suitable for some very specific use cases. Option 2) is the recommended route, but it is hard :-) Good luck!

How does Non Admin get Slack Quota Details and slackbot to backup to gmail etc

Does anyone know where slack puts the usage information?
For example, how many messages have we used?
How close are we to the dreaded 10,000 message free limit for searching?
How does a particular user (non-admin) backup everything OR better yet automatically post everything to gmail or drive or something else that last longer than 10,000 messages?
You can see the amount of message on the statistics page. https://myslack.slack.com/admin/stats
Usually every Slack user has access to that page (can be restricted to admins only).
To backup your messages you could develop a bot that automatically transfers old messages to an external cloud service and deletes the transferred message in Slack. The Slack API provides the method chat.delete for deleting messages. This approach will also work for private channels if the user that authenticated the bot is a member of that private channel.
Please note that your Slack will continue to function perfectly even after you have reached the 10.000 messages limit, but it will only show the newest 10.000 messages. If you really need to keep all messages you may want to consider either moving up to a paid tier or using a different service.

Resources