Giter Site home page Giter Site logo

hjerpbakk / slackprofilebot Goto Github PK

View Code? Open in Web Editor NEW
9.0 4.0 3.0 395 KB

Simple Slackbot for validating user profiles.

Home Page: https://hjerpbakk.com/blog/2017/05/25/profilebot

License: MIT License

C# 98.72% HTML 0.45% PowerShell 0.74% Dockerfile 0.10%
slackbot profile-validation profile-checking dotnet

slackprofilebot's Introduction

Profilebot - the profile checking Slackbot for you!

Build status codecov

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

Usage in Slack

Profilebot runs like any other Slackbot. Open a direct message to Profilebot and start talking.

As admin

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).

Admin usage

As a regular user

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.

Download & setup

  1. Clone the repository: git clone https://github.com/Sankra/SlackProfilebot.git

  2. Go to Hjerpbakk.Profilebot.Runner/Configuration and create a copy of config.default.json.

  3. Rename the copy to config.json.

  4. Go to your Team's Slack bot integration page.

  5. Enter 'profilebot' as the Username and click the 'Add Bot Integration' button.

  6. Copy the generated API token and paste it as your apiToken in config.json:

    {
    	"apiToken": "xxxx-00000000000-xxxxxxxxxxxxxxxxxxxxxxxx",
    	"adminUserId": ""  
    }
    
  7. 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.

  8. Copy the user id and paste it as your adminUserId in config.json:

    {
    	"apiToken": "xxxx-00000000000-xxxxxxxxxxxxxxxxxxxxxxxx",
    	"adminUserId": "x0xxx0000"  
    }
    
  9. Build and run Hjerpbakk.Profilebot.sln.

You should now be able to send direct messages to Profilebot in your team's Slack.

Customize the profile validation

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.

1. Extend SlackProfileValidator

Open Hjerpbakk.ProfileBot.SlackProfileValidator and edit the ProfileValidationResult ValidateProfile(SlackUser user) method.

2. Inherit from ISlackProfileValidator and create your own validator

  1. Create a new class and inherit from ISlackProfileValidator.
  2. In Hjerpbakk.ProfileBot.Runner.ProfileBotHost, edit the IServiceContainer CompositionRoot(string slackToken, string adminUserId) method. Instead of serviceContainer.Register<ISlackProfileValidator, SlackProfileValidator>();, register your own validation class.

Profilebot has a simple dependency graph

Running

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

slackprofilebot's People

Contributors

hjerpbakk avatar mmalvik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

slackprofilebot's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.