In a large Slack team, it's important that user profiles are completed enough for the users to recognise each other. Profilebot is a simple bot used for validating Slack user profiles. It is written in C# and it's easy to extend for all your profile checking needs. It runs out of the box either as a console app (Windows) or a Windows service.
Profilebot runs like any other Slackbot. Open a direct message to Profilebot and start talking.
If you are the admin of Profilebot, the following commands are available for you:
validate all users
notify all users
validate @user
notify @user
whitelist @user
Validating will inform you of the user's profile status, while notify will also send a direct message to the specific user(s).
As a regular user, anything you say will have the same effect: Profilebot will look at your profile and tell you if any information is missing.
-
Clone the repository:
git clone https://github.com/Sankra/SlackProfilebot.git
-
Go to
Hjerpbakk.Profilebot.Runner/Configuration
and create a copy ofconfig.default.json
. -
Rename the copy to
config.json
. -
Go to your Team's Slack bot integration page.
-
Enter 'profilebot' as the Username and click the 'Add Bot Integration' button.
-
Copy the generated API token and paste it as your
apiToken
inconfig.json
:{ "apiToken": "xxxx-00000000000-xxxxxxxxxxxxxxxxxxxxxxxx", "adminUserId": "" }
-
One user must be configured to be Profilebots admin user. This need not be an actual Slack admin, but the id must be a valid user id in the Slack team. Run https://api.slack.com/methods/users.list/test to find the user id you want to use.
-
Copy the user id and paste it as your
adminUserId
inconfig.json
:{ "apiToken": "xxxx-00000000000-xxxxxxxxxxxxxxxxxxxxxxxx", "adminUserId": "x0xxx0000" }
-
Build and run
Hjerpbakk.Profilebot.sln
.
You should now be able to send direct messages to Profilebot in your team's Slack.
At my company, DIPS AS we use the following validation rules:
- The email used must be a DIPS AS email
- Username must be the same as in all other internal systems
- Both first name and last name must be given
- What I do must tell others what you do
- A profile image must be set and be a picture of a human face
Customising the profile validation is easy, and you have two choices for how to do this.
Open Hjerpbakk.ProfileBot.SlackProfileValidator
and edit the ProfileValidationResult ValidateProfile(SlackUser user)
method.
- Create a new class and inherit from
ISlackProfileValidator
. - In
Hjerpbakk.ProfileBot.Runner.ProfileBotHost
, edit theIServiceContainer CompositionRoot(string slackToken, string adminUserId)
method. Instead ofserviceContainer.Register<ISlackProfileValidator, SlackProfileValidator>();
, register your own validation class.
Thanks to Topshelf, running Profilebot either as a service or a console app is super easy.
To run as a console app, just run Hjerpbakk.Profilebot.Runner.exe
. To exit, press CTRL + C
.
To install as a service, simply run the following in command prompt
:
Hjerpbakk.Profilebot.Runner.exe install
Hjerpbakk.Profilebot.Runner.exe start