Manipulate Presence

We’ll cover the following endpoints from Slack’s Users API in this lesson.

  1. users.setPresence: This endpoint manually sets user presenceThis is a flag with the value of either “auto” or “away.” When it is set to “away,” the user is shown as non-active..
  2. users.getPresence: This endpoint gets user presence information.

Retrieve a user token

Even though our application can set its presence with our current token, this isn’t that useful because no user can see the application’s “activity” status. It’ll be a lot more useful if a user could manipulate their presence, and to do that, we’ll need a user tokenThis is a string of characters that third parties can use to authenticate a request on a user’s behalf.. To get the user token, follow the steps below:

  1. Go to Slack’s API website and click on your application.
  2. Go to the “OAuth & Permissions” tab on the left-hand sidebar.
  3. Now scroll down and click the “Add an OAuth Scope” for the “User Token Scopes.”
  4. Give the application the following scopes: users:read and users:write.
  5. Click “reinstall your app” on the yellow notification.
  6. Click the “Allow” button and copy the “User OAuth Token.”
  7. Paste it in the code widget below.

Get hands-on with 1200+ tech skills courses.