Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A command line utility for changing your Slack status.
#!/bin/bash
slacktoken=INSERT_SLACK_TOKEN_HERE
apiurl="https://slack.com/api/users.profile.set?token="$slacktoken"&profile="
lastname="LAST_NAME_HERE"
if [ $# -eq 0 ]
then
status=""
else
status=" | $@"
fi
curl --silent --data-urlencode "profile={\"last_name\":\"$lastname$status\"}" $apiurl > /dev/null
echo "Last name changed to $lastname$status"
@samervin

This comment has been minimized.

Copy link
Owner Author

@samervin samervin commented Jun 28, 2016

Per the documention, at https://api.slack.com/methods/users.profile.set

You'll need to set your last name, as well as get a token from https://api.slack.com/docs/oauth-test-tokens

To use, type slackstatus <status>. To reset your status (to just your last name), just type slackstatus with no arguments.

@sl5net

This comment has been minimized.

Copy link

@sl5net sl5net commented Jun 13, 2019

could you please help to find: slack token?
do i need a user token? https://api.slack.com/docs/token-types#user
i searched in my prefeences. do i need create it?

@samervin

This comment has been minimized.

Copy link
Owner Author

@samervin samervin commented Jun 18, 2019

@sl5net yes, you'll need a user token, or you can still generate "legacy" tokens.

However, Slack has "status" support now (https://api.slack.com/docs/presence-and-status#custom_status) and so this script is only any good if you want to change your name and not your Slack-status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment