Giter Club home page Giter Club logo

slackblast's Introduction

Slackblast

Code style: black

Slackblast is a Slack application you can get up and running in your Slack environment that invokes a simple Backblast form for someone to fill out in the Slack App (mobile, desktop, or web) when they type /slackblast, /backblast, or /preblast. Slackblast interfaces with your PAXminer database directly, and its posts do not need to be scraped by PAXminer (PAXminer will ignore them). If you have not already set up PAXminer, do that first.

Slackblast serves over 100 regions and runs on AWS Lambda - installation is as simple as a simple link click, without the need for you to get your own server up and running.

When the user types /slackblast, /backblast, or /preblast and hits send, a window like the one below will pop up:

Getting started

Installation to your Slack Space is simple. For best results, please make sure you have a working install of PAXMiner in your region.

  1. Click this link from a desktop computer
  2. Make sure to select your region in the upper right if you are signed into multiple spaces

To use, simply type /slackblast, /backblast or /preblast from any channel and a form should come up.

Slack App Configuration

Slackblast has a number of region-configurable settings. To access and set these, use the /config-slackblast command.

Strava Integration

When enabled, slackblast will put a "Connect to Strava" button on the post, which tagged users can use to connect the slackblast to an existing Strava activity. When clicked, the following process is used:

  • If the user has not used this button before, they will be prompted to allow Slackblast access to their Strava account
  • Otherwise, a list of recent Strava activities will be shown to the user, which they select
  • On the next screen, the user can modify the title / text of the Strava activity, which defaults to the title / moleskine of the Slackblast post
  • After closing / submitting, Slackblast will make a callout in the post thread, recording how far the PAX traveled and how many calories they burned

Custom Fields

Slackblast now allows regions to add fields to backblasts for other things they might want to track. For example, you could track the distance traveled, calories burned, or the category of F3 activity the post is for. This information will be stored in JSON format alongside the backblast, which can later be queried with MySQL's JSON functions (https://dev.mysql.com/doc/refman/8.0/en/json.html). I'll provide some examples / tutorials soon.

To get started, click the Enable / Edit Custom Fields button in /config-slackblast. This will bring up a secondary menu where you can add / delete / edit / enable new fields. Once added and enabled, Custom Fields will be added to the bottom of your Slackblast forms.

Create Posts by email

Wordpress allows you to send a post to a special address via email and it will convert it to a post. If you are not using hosted wordpress, then you can create a dedicated gmail or other account and use this address. The /config-slackblast menu allows you to set a email server, port, address, and password to the email account you would like the email to come from (gmail is probably best), as well as the email-to-post address you would like it to go to. For those using Postie, you can also enable a format so that users are tagged and the AO is used as a category.

Lock Editing of Backblasts

If enabled, this will lock down editing of backblasts to the Q / Co-Qs, the original poster, or Slack admins.

Moleskine Templates

These templates will serve as the default when your users start a new backblast or preblast.

FNG Welcome Message

Slackblast now has functionality to welcome new users (FNGs) into your region's Slack Space! This will trigger automatically as soon as new users join. To configure, use the /config-welcome-message. There are two things to enable:

  1. Welcome DMs: These will be sent to the user via a direct message. You can set your region's template in the editor. This is a good place to help your FNG navigate your Slack space, where to go for help, terminology, etc.
  2. Channel Welcome Posts: These are shout-outs in a channel of your choosing. When enabled, this will welcome your user in a fun message, letting the rest of your guys welcome them as well.

Contributing

Slackblast is in active development, and I welcome any and all help or contributions! Feel free to leave an Issue with bugs or feature requests, or even better leave us a Pull Request.

Local Development

If you'd like to contribute to Slackblast, I highly recommend setting up a local development environment for testing. Below are the steps to get it running (I did this in unix via WSL on Windows, YMMV on OSX):

Development Environment:

If you don’t have a development environment of choice, I’m going to make two strong recommendations; VSCode is a VERY good and free IDE, and I would strongly make the case for using a unix environment.

  1. VSCode: Download Visual Studio Code - Mac, Linux, Windows
  2. Unix environment: if on Windows 10+, you can enable “Windows Subsystem for Linux” (WSL), that will allow you to run a version of linux directly on top of / inside of Windows. VSCode makes it very easy to “remote” into WSL: Install WSL (I use Ubuntu FWIW).
  3. Python 3.12: you may already have this, but if not I recommend pyenv to manage python installations: pyenv/pyenv: Simple Python version management. Specifically, Slackblast currently uses Python 3.12
  4. MySQL 8: all of my apps use Beaker’s PAXMiner MySQL 8 instance on AWS RDS in prod, so I would recommend having a local MySQL instance for local development purposes. The easiest way I found to do this was through Docker, which comes pre-installed in most unix environments How to Run MySQL In A Docker Container (howtogeek.com)
    • Note, I had to modify some of these steps to accomodate WSL, here's what I ran (where MYDB and MYPASS are of your choosing, remember these for later!):
echo "bind-address = 0.0.0.0" >> /root/docker/f3dev/conf.d/mysqld.cnf
docker run --detach --name=MYDB --env="MYSQL_ROOT_PASSWORD=MYPASS" --publish 3306:3306 --volume=/root/docker/f3dev/conf.d:/etc/mysql/conf.d --volume=$HOME/mysql-data:/var/lib/mysql mysql
  1. Ngrok: you will use this to forward network traffic to your locally running development app: Download (ngrok.com). You will need to create a free account and install your authtoken: Your Authtoken - ngrok
  2. Poetry: I use Poetry for of my apps’ dependency / environment management: Introduction | Documentation | Poetry - Python dependency management and packaging made easy (python-poetry.org)
  3. Git: Git should be installed in most unix environments, here’s unix: Git (git-scm.com)
  4. Nodemon: this is a useful utility for having “hot reload” when you’re developing: nodemon - npm (npmjs.com). You will likely need to install npm: How to install Node.js and NPM on WSL2 (cloudbytes.dev)
  5. VSCode extensions: one of the best things about VSCode are the thousands of extensions that are available to help your coding experience
    • Once you will need for sure:
      • WSL (if using WSL)
      • Remote Explorer (may come with the one above)
      • Python Extention Pack
    • Some other favorites of mine
      • Github Copilot - has blown my mind on how good it is, but it is $10 a month
      • Gitlens
      • Error Lens
      • Ruff
      • Black Formatter

Project setup

  1. Clone the repo:
git clone https://github.com/F3Nation-Community/slackblast.git
  1. Use Poetry to install dependencies:
cd slackblast
poetry env use 3.12
poetry install
  1. Create your development Slack bot:
    1. Navigate to api.slack.com
    2. Click "Create an app"
    3. Click "From a manifest", select your workspace
    4. Paste in the manifest below
    5. After creating the app, you will need a couple of items: first, copy and save the Signing Secret from Basic Information. Second, copy and save the Bot User OAuth Token from OAuth & Permissions
display_information:
  name: slackblast-dev
  description: An invokable form to produce properly-formatted backblasts and preblasts
  background_color: "#000000"
features:
  bot_user:
    display_name: slackblast-dev
    always_online: true
  slash_commands:
    - command: /slackblast
      url: https://YOUR-URL.ngrok-free.app/slack/events # You'll be editing this
      description: Launch backblast template
      should_escape: false
    - command: /preblast
      url: https://YOUR-URL.ngrok-free.app/slack/events # You'll be editing this
      description: Launch preblast template
      should_escape: false
    - command: /config-slackblast
      url: https://YOUR-URL.ngrok-free.app/slack/events # You'll be editing this
      description: Configures your region's instance of slackblast (email settings, etc)
      should_escape: false
    - command: /backblast
      url: https://YOUR-URL.ngrok-free.app/slack/events # You'll be editing this
      description: Launch backblast template
      should_escape: false
    - command: /config-welcome-message
      url: https://YOUR-URL.ngrok-free.app/slack/events # You'll be editing this
      description: Opens a configuration menu for FNG welcome messages
      should_escape: false
    - command: /tag-achievement
      url: https://YOUR-URL.ngrok-free.app/slack/events # You'll be editing this
      description: Lauches a form for manually tagging Weaselbot achievements
      should_escape: false
    - command: /send-announcement
      url: https://YOUR-URL.ngrok-free.app/slack/events # You'll be editing this
      description: Triggers a announcement send
      should_escape: false
oauth_config:
  redirect_urls:
    - https://YOUR-URL.ngrok-free.app/slack/install # You'll be editing this
  scopes:
    user:
      - files:write
    bot:
      - channels:history
      - channels:read
      - chat:write
      - chat:write.customize
      - chat:write.public
      - commands
      - files:read
      - im:history
      - im:read
      - im:write
      - team:read
      - users:read
      - files:write
settings:
  event_subscriptions:
    request_url: https://YOUR-URL.ngrok-free.app/slack/events # You'll be editing this
    bot_events:
      - team_join
  interactivity:
    is_enabled: true
    request_url: https://YOUR-URL.ngrok-free.app/slack/events # You'll be editing this
  org_deploy_enabled: false
  socket_mode_enabled: false
  token_rotation_enabled: false
  1. Copy .env.example, replacing ADMIN_DATABASE_PASSWORD with the one you used to set up MySQL, SLACK_SIGNING_SECRET and SLACK_BOT_TOKEN from your Slack setup above, and save the new file as .env in the base directory. There are several secrets you will need from Moneyball.
  2. Initialize your local database by running the script:
cd slackblast # if not already in the slackblast subdirectory
source ../.env && poetry run python utilities/database/create_clear_local_db.py
  1. Run Ngrok with the following command from your terminal:
ngrok http 3000
  1. Copy the Forwarding URL (has ngrok-free.app at the end)
  2. Back in your browser for the Slack app, replace all of the YOUR_URLs with the ngrok Forwarding URL
  3. You are now ready to roll! This would be a good time to make sure you're on your own branch :)
  4. To run the app with "hot reload" (restarts anytime you save a file), run from the slackblast subdirectory:
source ../.env && nodemon --exec "poetry run python app.py" -e py
  1. Use ctrl-C to stop both Ngrok and nodemon
  2. Repeat steps 6-11 whenever you stop and want to come back to your app

Note

If you want to access your db through dbeaver, you can set it up like a normal db connection. Note, if using WSL, your WSL's IP address CAN CHANGE, meaning you would need to edit your connection when it does. I got the Server Host port number by running wsl hostname -I from Powershell from Windows.

Note

if you add or change packages via poetry add ..., you will need to also add it to slackblast/requirements.txt. You can make sure that this file fully reflects the poetry virtual environment via: poetry export -f requirements.txt -o requirements.txt --without-hashes

slackblast's People

Contributors

allcontributors[bot] avatar evanpetzoldt avatar hopsusa avatar jim-muzzall avatar nsottek avatar trentjonesln avatar willhlaw avatar wolfpackt99 avatar yankeestom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

slackblast's Issues

Better Modularization

As I expand features of Slackblast, I'd like to make them more modular so it's easier to work on them independently. So for example, I'd probably break out forms.py, moving the forms to their respective feature modules. Same with actions.py?

Strava Integration

Hello,
I'm not sure if I'm in the right place for this, but I'm having an issue with the Strava integration. When I click on the "Connect to Strava" button in the SlackBlast, a pop-up window launches, and says "Loading, do not close", but just hangs there indefinitely.

I've tried logged out of Slack and back in, and that did not help. I've tried it from the Slack mobile app as well, and that has the same results.

Is there a way to fix this, or things I could try?

Uploading Screenshot 2024-01-04 at 7.17.48 AM.png…

How to edit the backblast after posting?

Great tool! One question: is there any way to edit the bost's post after it is posted to the channel? For example, Q makes an error and wants to fix it, etc.

I am hoping there is some way to set the permissions for the bot's posts but not finding much after googling on this.

Update Python and move to Poetry

Project is on Python 3.8, it would probably be worth updating soon... I'm hoping that we can avoid changing the Lambda function URL, but that may not be avoidable.

Also want to move to Poetry for dependency management.

Better error handling

It would be good to surface some errors to users so they can help diagnose. Currently, most of the time it will fail silently.

FNG Welcome Message

Had a request / some ideas for adding a welcome message for guys who join the slack space; Slack has a trigger event for this. The basic idea:

  • Triggers automatically when new guys join the Slack space
  • Sends the guy a message, welcoming him and some introduction / overview
  • Optionally sends a callout in a specified channel
  • Configurable through /config-welcome-message or similar

Add special field for non-Slack PAX

As a Q submitting the backblast, I would like the form to separate out FNG field with “Not In Slack” field so that it is clearer what to do with PAX that are not in Slack and thus not taggable.

Humbly requested by Dilfer (Puget Sound) and favored also by Huggies (Phoenix, AZ).

PAXMiner is processsing some data for channels not tagged as AOs.

Background
We maintain two 3rd-F locations as channels for 1) preblasts and 2) qsignups. We don't want these two channels processed as "workouts" by PAXminer. These two channels are NOT set as AOs in the database AND paxminer isn't in the channel.

Issue
PAXMiner appears to be processing the data from the backblast. These backblasts were entered using the /backblast command and have the buttons at the bottom. When I say "appears," I mean that PAXMiner is counting the Q stats for these channels and including it in the report on the 1st-F channel as well as the individual 3rd-F channels. I assume the same is true of the PAX listed therein.

Resolution
If the issue is caused by using the /backblast command, then ensure /backblast command is checking for the AO flag in the database before processing the backblast. Then again, this issue might not exist at all (can't remember if I recently fixed these flags in the database #old).

Griswold, F3xT

Add personal stats

This would be a fun little "just because"... a command (/my-stats) that brings up a modal with a bunch of metrics / charts that summarize your posting numbers.

Add DR functionality

In tandem with Weaselbot's schema, the idea would be to automatically post in the PAX's home region (selected channel) when they post DR. This would eliminate the need for that PAX to create a DR post, as well as share with their home PAX what they are up to.

Allow for custom email tags

Basically the ability to append custom text to the end of the email. Could be used for postie or other.

So it wouldn't be postie specific but you could use custom tokens in this "setting" that would replace bits with values from slackblast:

#category: {{ the_ao }}

Ensure PAX Count value is a whole number

Because tools like PAXMiner are looking for a whole number, e.g. 7, then 'seven' should not be allowed in the slackblast post.

Proposals:

a) we can make maximum length 3 so 100 can be typed in but not seven. May catch a lot of these cases.
b) can look into updating the label to make it clear a number is expected. May also add a validation message depending on Slack's modal capability - which increases the interactivity and number of communications between slack and the server and overall making it nearly twice as complicated
c) the server can read the input and if it is not an integer, then server can parse the PAX and non-PAX names by hand to come up with the count

HC Button for Preblasts

Had an idea to add an HC button to preblasts. When clicked, it would:

  • Add the user to a list (at the bottom of the post in small type / context?)
  • Could also have a pax counter on the post
  • Clicking again would remove them from this list and decrease the counter
  • Either one (HCing or un-HCing) could optionally trigger a threaded response ("and @moneyball is in!" kind of thing)

Can there be a Co-Q

If there is the possibility of adding a 2nd Q, then PAXMiner will consider the 2nd name the Co-Q.

Can we have the Q field allow a primary and secondary name to be chosen?

Best options for a preblast?

Our region has requested a similar app for preblasts (which we use for nearly every beatdown). Looking for just some general guidance on best design approach for this. Full disclosure: I do mostly scientific programming in Python and webapp skills are fairly rudimentary. I did manage to get the slackblast app installed for us on Azure App Services and running in our slack workspace.

Thoughts on options:

  1. Build in the same app (forked version of this repo) and have an option to flip between a preblast modal or a backblast modal. Pros: ease of management. Cons: Maybe not the best UX approach (perhaps confusing to users).
  2. Build a copycat 2nd app, install as a second slack / Azure app. Pros: use separate slash command (e.g., /preblast vs. /slackblast), cleaner. Cons: more code and a 2nd app to manage. Can't fork a repo twice in github so any updates to this app would have to be manually added to the 2nd app.
  3. Is there a better 3rd option than either of these?

Thanks for the great app and any help on this design.

Add photos to backblasts

Slack doesn't have a filepicker, but we could:

  1. Prompt the user with a DM for a picture, and take whatever the user replies with and add to the post
  2. Use Google Photos URLs, download and add to post

Will need to think about how to do this for email, since those are sent right away when making a backblast. Played around with 1) a fair bit... bad news is that it is going to be either very messy or impossible :( Putting it on hold for now to work on other stuff

Make custom field form more dynamic

When adding a numeric custom field, the "options" field is required. Ideally, this would be dynamic to remove this field if numeric or freeform is selected.

Add Weaselbot integration

I have an idea for making it easier to tag manual achievements in Weaselbot via Slackblast. It would be a new command like /tag-achievement, which would load a form that has a dropdown for selecting an achievement from that region's achievement_list (if it exists). This would write directly to achievements_awarded rather than making a backblast to be picked up by Weaselbot.

Clean Up / Modularize handle_backblast_post

handle_backblast_post has gotten way too long and complicated due to its many entry points. It probably makes sense to separate out the entry points and modularize the common functionality.

Upload file option?

Would it be possible to add an option for uploading a File (such as Boy Band photo/video for NOR)?

Clean up /config-slackblast

Especially as we add more features, I would like to make the config menu a little more streamlined. My thought is to use sub menus for each category of the app (email settings, welcome settings, custom field settings, etc)

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.