Slack API: How to list your bot applications? - slack

I want to list the bots owned by any user through the slack api. The list of applications owned by a user is missing from user.info and user.list. Which api method could I use to list the applications any one user owns? Or vice versa if I have a bot application id how could I determine who owns said bot?

The endpoint you are looking for is team.integrationLogs.
This method lists the integration activity logs for a team, including
when integrations are added, modified and removed. This method can
only be called by Admins.
You will have to parse through the log with all changes to get the current state, but this is the only endpoint with that kind of information.

Related

DM to any user on Slack using Slack API

I'm trying to send Direct Messages (DMs) to a user on Slack using chat.postMessage using Bot token. But I'm only able to send messages to the users that are in my workspace.
How can I send message to any user on another workspaces?
When I try to do so, I get: "error": "channel_not_found"
I've that user's UserID (U02....), user's email and my Bot token.
When you create a bot/app in Slack, you grant it OAuth Scopes which provide the bot access to certain information in your Slack instance. So for example, I expect you have added the users:read Bot Token Scope to your Slack app, so that it can determine the users, and userId's in your workspace.
However, this scope restricts the bot to only see users in your workspace.
There's a couple of ways around this though:
Solution 1 - Slack Connect
Now in Slack, you can message users in other workspaces with a feature called Slack Connect.
You'll first need to establish a connection with the user you want the bot to message. This can be arranged via an invite process, and once completed that userId should become available to the bot. You can use that userId in the channel field of the chat.postMessage API to direct message the user from the other workspace.
Solution 2 - Org Level App
If you are on an Enterprise version of Slack, you should have multiple workspaces within a company, that are all linked by an enterpriseId.
In this case, a possible solution might be to create what is known as an Org Level App to have access to information across multiple workspaces. More information on Org Level apps can be found here.

How to send message to all the members of the group on Installing teams bot

I have created a teams bot and had a service written in .NET core to handle events and user's messages to reply accordingly.
When I install a bot in a group, I need to send personal message(one-to-one i.e between bot and the user) to all the members of that group on installation. I am trying to do that in OnConversationUpdateActivityAsync event handler (which gets fired when I install the bot). But in this event I am getting information of the user who is installing the bot, not the other members which are added in that group, also I am not getting any information of the channel(channelId and members etc.) in which the bot is getting installed.
Any different approach or solution will work.
Thanks in Advance.
You haven't said if you want the bot to message the users privately (like 1-1 between the bot and user) or just send each person a personal message inside the group chat, but in both cases, Proactive Messaging is your correct approach. If you want to send a message inside the group chat itself, see this sample.
If you want to send the users messages directly, 1-1, they need to have the bot installed as a personal app already. It's possible to do this automatically, but it's a bit more work, and requires Microsoft Graph. The proactive messaging is a bit different too - you get the list of members as per the previous sample, but see here for how to get the required 1-1 conversation details, and how to send the actual message. This last link also has documentation on how to get started, and some background reading (at the bottom of the page).
#Hilton is correct, You need to specify in which scope you want to notify user 1:1 or directly in Group chat?
App should be installed in user scope if notifying user on installation, You can proactively install the App in User/Group Chat/ team scope using Graph API. To notify users in Teams or Group chat, You can fetch the list of members using List conversation members API, When you install the App using Graph API Bot received converstionUpdate, You can save the conversationReference and use it for proactively notifying.

How to get the tenant name when integrating with Microsoft Teams

I have created a Microsoft Teams bot that can create/update conversations and receives all kinds of events to an endpoint (user joined team, ...). All I see in the events is a tenant id. For teams, i get an id and sometimes a name which is great.
to create/update conversations I use this flow:
Get a token from https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token
POST to a channel: ${serviceUrl}v3/conversations/${conversationId}/activities
My question is, how can I get the name of a tenant? I can not find any API to do so?
Use case: A user sends me a support email. I have no way to check my database and find the correct entries because all I know is the tenant id.
I have looked into the Graph API but I'm not sure if my bot is actually able to make those calls (I get all kinds of strange permissions errors such as Authorization_IdentityNotFound The identity of the calling application could not be established.).
I want to make the calls to the API myself. I don't want to use any Microsoft SDK/Lib/...
It looks like I have to:
In Azure Portal -> App registrations -> API permissions add the Microsoft Graph application permission Organization.Read.All
For each tenant, ask the Microsoft Teams admin to visit: https://login.microsoftonline.com/${tenantId}/adminconsent
Get a graph token for the tenant via https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token (scope: graph.microsoft.com/.default)
Call the graph api https://graph.microsoft.com/v1.0/organization

How can I deactivate an slack user via slash-commands?

I want to create a bot that deactivates users under some criteria. I can not find any slash command that deactivates user accounts for free slack groups. I only see the option to kick from channel.
For paid versions the following can be used:
https://github.com/ErikKalkoken/slackApiDoc/blob/master/users.admin.setInactive.md
You can't do that. Slack exposes a SCIM API for user management, but it is not available for free teams.
To my knowledge there is no API methods to "kick" users automatically that works for free slack teams, so you will have to manually deactivate users you want to kick.
As a workaround I have a small bot running on my slack teams that report daily in a special admin channel which users need to be manually deactivated. That works of course only if you have a hard criteria that you can use to can test if a user is still eligible to be member of your Slack team.

Microsoft Exchange Meeting Master Copy

I have a custom application with its own database and a connection to exchange through EWS. Part of this application is a meeting tool which allows users to import exchange meetings and auto invite the other users which also use my application. As part of this tool I need to keep my meetings up to date with exchange, basically maintaining a centralized meeting storage. I can't simply store the user's exchange credentials due to security concerns and I also cannot customize the EWS server in any significant way (ie I cannot add Delegate Access).
The problem is that I am currently simply forcing all users to login to EWS whenever the go to view a meeting's details and it will query EWS to get the details using that user's EWS credentials and access their copy of the meeting. The problem is that there is no guarantee that any user has the same meeting details as any other user. As is partially explained here. Is there any way I can force the EWS FindItem call to only use the meeting's public (master) properties? i.e. Whatever version of the meeting the organizer has sent out/updated. I just need all users to return the same details when they query for the same meeting.
One solution I've considered is adding a 'bot' user whenever a meeting is imported into my application, and then just always using that bot's version of the meeting. However, I would really prefer to do something more 'under the hood' that doesn't require this extraneous user.
Is there any way I can force the EWS FindItem call to only use the meeting's public (master) properties
No FindItem will only every return you information about what is in the Folder your trying to access. You might want to consider using GetUserAvailiblity to check the organiser https://msdn.microsoft.com/en-us/library/aa494212(v=exchg.80).aspx would be the closest. I would say to make your application work correctly is you need an Service account that has been given at least read access to every users calendar, you can then make a call to get the organiser version of the Appointment which will also contain the user responses. If your using Office365 then the new REST Api does facilitate this in a more secure way eg demon apps https://blogs.msdn.microsoft.com/exchangedev/2015/01/21/building-daemon-or-service-apps-with-office-365-mail-calendar-and-contacts-apis-oauth2-client-credential-flow/

Resources