Skip to content

necramirez/slack-rustat

Repository files navigation

The Rustat Hristov Slack bot

Rusi:

btw, I am thinking about adding a bot to help me set my slack status easier... something to help with the whole WFH situation 😕

I want to have pre-defined statuses, like ":hamburger: ...lunch" and ":afk: away from the keyboard", and others

and that would be easy to trigger with /status lunch or /status afk or /status clear ...

actually that exists 😄

it is not as nice as a one word status msg... but it's usable 🙂

Me:

So what you want is actually pre-defined status messages that may be activated with a shortcut/keyword?

Rusi:

yes, and maybe some other functions similar to slack's workflows - say I set my status with /status lunch - maybe after an hour, a message will popup with a button - "are you back" or something like that

or I can have /status meeting 30 to set a 30 minute meeting status message

the idea is that you should be able to see my slack status, and know what's going on - similar to when we are in the office together - you can just look at my desk and see me working, or having a meeting, or eating, or not being there 😄

Installation

Add to Slack

Usage

TL;DR

/rustat help
/rustat add <key> <message>
/rustat remove <key>
/rustat list
/rusi <key> [<expiry>]
/rusi clear

Welcome to ✨The Rustat Hristov Slack bot✨!

A "rustat" is a predefined ✨fancy status message✨. It can also mean "R. U. status", that is, "Are you ?", like "Are you lunch?" NOPE.

/rustat help -- Print this help text

Manage your rustats

/rustat add <key> <message> -- Save a rustat with the shortcut keyword <key>; if <message> starts with an emoji, that emoji will be used as status emoji

/rustat remove <key> -- Deletes a rustat with the shortcut keyword > <key>

/rustat list -- List all saved rustats

Set your status message

/rusi <key> [<expiry>] -- Activate the rustat with the shortcut keyword <key> that will (optionally) automatically be cleared by <expiry > (in human language!>); e.g. /rusi lunch, /rusi sleep until 10pm, /rusi meeting for 30 minutes or /rusi call until 2am EST

/rusi clear -- Clear your current status message (whether it's a > rustat or not)

Development

Setup

Requires:

Create .env then set the environment variables with values taken from your Slack app

  • supports .env.<sls env> where <sls env> is the value used in the serverless command invoked
  • e.g. .env.dev for sls deploy --env dev
cp example.env .env

Install app dependencies

npm i
sls dynamodb install

Running locally

Run ngrok

ngrok http 3000

Copy the ngrok URL and paste it into:

  • .env for SLACK_REDIRECT_URL
  • the Slack app's configured slash commands and OAuth redirect URL

Start serverless-offline

  • this watches for changes in the TypeScript source code and automatically rebuilds
  • however, it does not watch for .env changes -- you need to restart in that case
  • also, somehow, serverless-offline buries all console.log output ¯_(ツ)_/¯
  • the alternative is to run Slack Bolt locally as well, but that also is another PITA because it doesn't watch for local changes
npm run start:offline

DynamoDB data model

installations

Slack workspace installations

Entity Hash Range
installation PK#<enterprise_id>#<team_id> #SK#<user_id>

rustats

Entity Hash Range Other attributes
rustat rustat#<username> #key#<username>#<key> key, message

Ref: https://aws.amazon.com/getting-started/projects/design-a-database-for-a-mobile-app-with-dynamodb/4/

About

The Rustat Hristov Slack bot

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors