Search code examples
apibotsslack-apislack

It's possible to know when was the last activity of an Slack channel's member using the API?


I have seen in the API reference that the method user.getPresence() return a object with a property "last_activity" (a UNIX timestamp) but only if you request that information of the author user:

If you are requesting presence information for the authed user, this method returns the current presence, along with details on how it was calculated.

What means in this case "authed user"? Can I get that timestamp for any user in the channel or only for the user who I have used in order to generate the app token?


Solution

  • The authed user (short for authenticated user, which is used elsewhere in the Slack API documentation) refers to the user who is using the API, so the one who authenticated your app using oAuth. It refers to the resource owner in Slack's figure below:

    Negotiating tokens with Slack's OAuth 2.0 authorization flow. Image created by Slack.

    It is detailed on the users.getPresence page that, when requesting the presence of a different user, only the current presence (either active or away) is returned.

    More details about presence and status can be found here.