How to get total workspace (team) user count via Slack API? - slack-api

I am trying to get the total number of users within a Slack workspace. Just the count.
Things I've considered:
Iterating over the users.list
Unnecessarily heavy on the API and gets me waaaay more data than I need (the less I know about the users, the better imo)
Includes inactive users (so cannot get a proper indication without iterating over everything)
Using conversations.info
Requires a scope that I currently don't use (channels:read). Getting read access to channels seems like a very intrusive permission (even though my app doesn't use it and I don't want to scare off users by requesting this sort of information).
Is there an easier way to getting this information or any ideas I have not considered yet? Let me know!

You could make a call to [conversations.members][1] for the #general channel. It won't return a total number of users but it will return a list of all user ids pertaining to members of that channel, you'd just need count the ids on your end. Every user on a workspace is automatically added to the #general channel. No one can leave that channel nor can it be deleted or archived so it's sure to have the most accurate count of total workspace users. The conversations.members method does require the channels:read scope though so that's something to keep in mind.

Related

Trying to get analytics on Microsoft teams calls

I am trying to put together analytics on Microsoft teams calls. I would like to get hold times, number of transfers, call time, etc. I came across this call https://graph.microsoft.com/beta/communications/callRecords and it gives me a list of calls with call times, but I can't find a way to get hold times, what line it came in on, etc. Greatly appreciate any pointers.
First of all, this end point https://graph.microsoft.com/beta/communications/callRecords only allows you to query a single call record using its ID, it does not support querying a list of call records for the whole tenant or for a specific user.
The only way currently to find this ID to query the call record is by setting up a web hook to receive change notifications. Refer to the following documentation for more info on change notifications.
To directly address your question, i am not one hundred percent sure but i believe the information you're looking for could be found inside the list of sessions and segments inside a call record.

Get Twilio Chat User Channels sorted by last activity or unread count?

We are developing a chat system where users can be in many chat rooms, and I'd like to be able to show the most recent channels first.
This could be either by the time the last message was sent, or even by the number of unread messages, as long as there is some order and I don't need to go through all the pages of channels and get additional metadata to sort it manually.
I can't see any options in the docs and even though the response metadata has a "key" set to "channels", I haven't been able to figure out a query parameter that can change that.
It seems like channels will always be returned ordered by the random unique channel ID, so for pretty much every use case you'd need to get all channels and sort manually. Is that the case or am I missing something?
Twilio developer evangelist here.
I'm afraid you cannot order the channels within the API right now. This feature is on the roadmap though, however I can't give any time estimates for it.
The solution for now is sorting manually. I will update once that changes though.

How to hide value from Firebase in multi part request iOS

I'm using Firebase in my iOS app but I want to ensure a value is never sent from the server to the client.
Users in the app are shown to each other based on a score they have. So a user with a score of 5 will see other users who have a score of 5. I don't want to include this value in the request/response to Firebase.
Where I can manage the server I can have server side logic handle this by looking up the user on the server then calling a function that determines who has the same score and returning the relevant users without the client ever receiving the user score.
With Firebase my understanding is I'd have to send the value to Firebase in a query i.e. get all users with this user's score.
How can I do this without exposing the user's score? I want something along the lines of a node user_scores where I can query the current users score and then using this query another node users to return me the relevant users without having to nest the query on the client and thus expose the score in the request/response?
Many thanks!
Your understanding is pretty much on point, there is no way to make a "dynamic" query like this without actually exposing the varying parameter to the client.
Here are two ideas you could try to use as a workaround:
A variation of "security by obscurity": instead of exposing a single number, obfuscate that value in a way that makes guessing its purpose and other values an unpleasant experience; and share that with the client.
If you keep your users grouped by this key, not just as a flat list where this is a child node, you can use security rules to enforce that the user cannot read any other group than theirs.
(Note that this is also true for numerical values. Security rules are not filters.)
In a much more involved strategy, you could make the query static. Store and maintain a list of matching users per user, so the clients can load their own personal list without any varying parameters sans the UID.
(This is probably not really feasible if there is a lot of movement involved. But it might work in some edge cases.)

How do I get a realtime list of all seminars in a given room, filtered by time period, via Adobe Connect's API?

We are attempting to build free/busy calendars on our website for our Adobe Connect seminar rooms using data provided by the Adobe Connect API.
Our first attempt used sco-session-seminar-list. This returned data in the expected format and seemed to work perfectly. However, upon review we found that many existing sessions were not being returned. Some of the rooms do not have the API user setup as a host or presenter, so I suspect that may be causing a problem, though the user can see these sessions in the admin which indicates to me that they should have access.
We then tried report-bulk-objects. This did return all seminars as desired. However, it hits the reporting database which means that seminars created in the last 24 hours may not appear. Worse, it does not appear that there is any way to filter by room (or parent sco-id) using this method.
I cannot find any other relevant methods in the API documentation that would work better than the above two for our needs. However, it seems like a free/busy calendar should be a relatively common use of the API.
We finally found a non-intuitively named function that worked for this sort of information:
url="http://#AdobeConnectUrl#/api/xml
name="action" value="sco-expanded-contents">
name="sco-id" value="#roomID#">
name="filter-gte-date-begin" value="2015-01-01">
name="filter-lte-date-begin" value="2015-01-08">
This function will also work for a more informational calendar as it returns details other than just the start and end times (such as the seminar name). It pulls all sessions that occur under the sco-id requested, including those in subfolders. It also runs in real-time.

Twitter - public Stream handling deletion notices

I am using the Twitter public stream API to search for some keywords. I am writing my script in Java and therefore I use twitter4j. Now I stumbled over the information about status deletion notices:
Status deletion notices (delete)
These messages indicate that a given Tweet has been deleted. Client
code must honor these messages by clearing the referenced Tweet from
memory and any storage or archive, even in the rare case where a
deletion message arrives earlier in the stream that the Tweet it
references.
https://dev.twitter.com/docs/streaming-apis/messages#Status_deletion_notices_delete
So I created methods to remove records from my database when such a notice occurs. Unfortunately such a notice never occurs. I searched to find out what I am doing wrong and found some posts in the twitter developer section concerning the same problem:
https://dev.twitter.com/discussions/17393
https://dev.twitter.com/discussions/19943
https://dev.twitter.com/issues/1355
https://dev.twitter.com/discussions/12836
but unfortunately all these discussions got no answer. So for me it seems like I did no mistake with my code but twitter4j never sends me an deletion notice.
I want to respect the privacy of the twitter users - at least for legal reasons. So my question is:
What can I do to respect the privacy of the users ?
What do I have to do to satisfy my legal duties ?
One alternative seems to be to periodically iterate through all saved Tweets in my Database and request them from twitter to see whether I get a result back or not (so they were deleted). But this doesn't seem to be a practicable way because the data will get more and more and therefore at some point of time I will have limitations (in time, allowed twitter requests, ...). So what should I do?
Thanks in advance! Your help is greatly appreciated.
Ludwig
twitter4j v.3.0.6
Given the nature of the volume of tweets, it's unreasonable to assume that you would check to see if all the tweets are still there. You should make sure that you properly act on a delete notice from twitter. The onus is on them to actually send the delete notification.
That being said, I receive delete notifications from twitter. However, we aren't using the public stream, we are using sitestreams, which relies on authorizing specific social accounts and streaming all updates for those accounts (e.g. favorites, follows, blocks, tweets, retweets, etc) to us in realtime.
If you are doing a stream with filters, for example, it's probably not feasible (or at least very taxing) to run all deleted items through the same pipeline as new items. Or perhaps, to guess at which you were sent based on the times that you were running your filter.
As noted in the issue you linked to, the public streaming API will not necessarily send them out. I'd endeavor to handle them, and possibly provide a tool to manually remove any if a request comes in through another channel, but not worry too much about it, given that twitter doesn't provide the proper facility to be notified of such instances.

Resources