Search code examples
slack-api

Check if a user is deleted


Im using the slack API with the python SDK.

Im trying to send a few messages to a few users and it seems chat_postMessage does not fail like I expected it to when trying to send a message to a deleted user.

So I need to do that check myself since I want to do something with the messages that were supposed to go to deleted users.

I saw this method: https://api.slack.com/methods/users.list but it forces me to "scrape" all the users which there are a lot of, and I might start running into rate limiting.

There is also this method: https://api.slack.com/methods/users.profile.get but I couldnt understand how it will behave for deleted users and it seems there is no indication in the response if its a deleted user or not (unfortunately I cant just test it myself right now).

So, to my question, is there a way to check if a user is deleted given a username? Or alternatively, make chat_postMessage fail for deleted users?


Solution

  • Try using [users.info][1] for a specific user using the user id. The response to this method has a deleted boolean that will hopefully help you.