Skip to content

pagbrl/mriq

Repository files navigation

Mriq

Mriq is a simple Slack application enabling coworkers to show their gratitude to each other

Installation

Mriq is a Symfony 4 app. Mriq comes with a docker environment that might be used for production, making the minimal installation process simpler.

Slack app creation

Create a new Slack app. Name it however you see fit. We will then setup the needed components and permissions needed.

Interactive Components

Enable interactive components for your app and set the endpoint to ${serverIP}/reaction, which will enable users to react to their transactions.

Slach Commands

Mriq currently supports two commands :

  • A command used by users to give mriqs to each others. You can set up any slash command (we'll use /treat for this example). Request URL should be set to ${serverIP}/treat. Hint should show /treat @user 6 reason. You should also tick the "Escape channels, users, and links sent to your app" tickbox.
  • A command for users to display their mriq balance. Request URL should be set to ${serverIP}/mriq. Hint should show /mriq, since this command accepts no parameters.

OAuth and permissions

This menu will enable you to get your OAuth access. In order for the app to be able to post in private channels and in Slackbot channel, you need to use the OAuth Access Token, and not Bot User OAuth Access Token. Those token will be available once you install the app to your workspace.

In the Scopes section, chose the following permissions :

  • bot
  • commands
  • chat:write:bot (for the bot to be able to post in various slack channels)
  • users:read (for the app to be able to get the users list periodically)

Bot Users

Set the display name and username of your bot, and leave the Always Show My Bot as Online option to off (users have no interest in talking directly to the bot).

You're all set ! You can now install the app to your workspace and get your OAuth Access Token (needed by the server-side application).

Server-side installation

Mriq is a Symfony 4 app. Mriq comes with a production-ready docker environment, making the installation process very simple.

First, clone the mriq repo. You must then copy the .env.dist file to .env and fill the various variables needed. They are pretty self explanatory. You can retrieve the id of the channel in which all transactions will be logged using Slack API Tester.

Let's break the variables into two categories : Docker environment variables and Symfony parameters.

Docker environment variables

MYSQL_DATA_DIR= //Directory mounted to the mysql container to persist db data
MYSQL_ROOT_PASSWORD= //Well mysql root password

APP_DIR= //Directory where your app is located on the host
APP_ENV= //App environment (should be prod)

Symfony parameters

APP_SECRET= //Automatically generated by Symfony, fill with any value really
DATABASE_URL="mysql://root:${MYSQL_ROOT_PASSWORD}@mysql.host:3306/mriqs" //We use the root user because we're inside the docker network so the mysql container is not reachable from anywhere public. Please use another user if your mysql install is publicly available.

MAX_TRANSACTION_AMOUNT= // Max amount of mriqs for one single transaction
MAX_MRIQ_AMOUNT= // Max amount of mriqs to give a user can have
FAUCET_AMOUNT= // Amount of mriqs automatically given to users every 4 hours (exept users who already reached MAX_MRIQ_AMOUNT)
MRIQ_CHANNEL_ID= // Channel where transactions will be posted

You can now run the app :

docker-compose up -d

This will install all dependencies and run your app. The app runs on port 80 by default.

Usage

The app is pretty straightforward to use. It registers transactions and deals mriqs to users periodically.

In order for the app to function normally, you can setup two crontab tasks :

# This will deal ${FAUCET_AMOUNT} mriqs to users every 4 hours
0 */4 * * * /usr/bin/docker exec -it mriqs-php php bin/console mriq:faucet
# This will update the list of users from Slack everyday to keep it in sync. You can also run this task less often or even manually.
0 0 * * * /usr/bin/docker exec -it mriqs-php php bin/console users:update

You should be good to go, go spread the love 💌!

About

Mriq

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors