Skip to content

agrigg/slackblast

 
 

Repository files navigation

Slackblast

All Contributors

Slackblast is a simple application you can get up and running in your Slack environment that will pop up a simple Backblast form for someone to fill out in the Slack App (mobile or desktop or web) when they type /slackblast. The advantage of slackblast is that it puts the backblast in a format that is compatible with PAXminer, which makes it easier to compile stats on users each month.

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

Screenshot

For a short tutorial on how to use the app, go to https://www.loom.com/share/705b67bfd30f40ae902fae7a6c1a7421

Getting started

From a technical perspective, Slackblast is a Python web application that utilizes the modal window inside slack to make posting backblasts easier for PAX.

Go to https://api.slack.com/start/overview#creating to read up on how to create a slack app. Click their Create a Slack app while signed into your F3 region's Slack. The main idea is that you will set up a slashcommand, e.g. /slackblast or /backblast, that will send the request to your server that is running this web application (we recommend using a free Azure App Service) that will respond with a command to tell Slack to open up a modal with the fields to fill out a backblast post. When the user hits submit on the modal, the information will be sent to your server where it will then format it and post to the designated Slack channel!

Bonus: the post will be in a format friendly for Paxminer to mine and gather stats.

Bonus 2: the post can be emailed to automatically post to Wordpress

Go to https://azure.microsoft.com/en-us/services/app-service/ to create a Free Azure App Service to host this web application. The VSCode Azure Extensions will be helpful to upload your own .env file with your region's specific Slack and opinionated settings. See how to integrate your Azure App Service with Github for easy deployments.

When you finish setting up and installing the slackblast app in Slack, you will get a bot token also available under the OAuth & Permissions settings. You'll also get a verification token and signing secret on the Basic Information settings. You will plug that information into your own .env file. When you finish creating the Azure app, you will need to get the URL and add it (with /slack/events added to it) into three locations within the slackblast app settings. Lastly, you will need to add several Scopes to the Bot Token Scopes on the OAuth & Permissions settings. Read on for the nitty gritty details.

All environment variables

slackblast requires the following environment variables:

Variable Description
SLACK_BOT_TOKEN A value from the token on the OAuth page in the slack app
SLACK_VERIFICATION_TOKEN A value from the Basic Information -> Verification Token field in the settings for your slack app.
SLACK_SIGNING_SECRET Secret from the App Credentials page for your app in Slack.
POST_TO_CHANNEL A boolean value True or False that indicates whether or not to take the modal data and post to a channel in slack
CHANNEL The channel id (such as C01DB7S04KH -> NOT THE NAME) you want the modal results to post to by default. other values supported. set to THE_AO to post to the channel that was selected in the modal by default. Set to USER to post a DM from the slackblast to you with the results (testing) by default. If blank or missing, then the default channel will be the channel the user typed the slash command. In the modal, the user can choose the "destination" and where to post to.
EMAIL_SERVER SMTP Server to use to send the email, default is smtp.gmail.com so if sending from a gmail account you only need to fill out email_user and email_password email
EMAIL_SERVER_PORT Email server port. default is 465
EMAIL_USER Email account to send on behalf of
EMAIL_PASSWORD Email account password
EMAIL_TO To send the post to an email address. This will default the choice in the modal but can be changed by user. set EMAIL_OPTION_HIDDEN_IN_MODAL to prevent user from changing it.
EMAIL_OPTION_HIDDEN_IN_MODAL Hide the option from the PAX on sending an email in the modal



Slack App Configuration

The url for your deployed app needs to be placed in three locations in the slackblast app in Slack:

  1. Interactivity and Shortcuts
    • Request URL
    • Options Load URL
  2. Slash Commands
    • Request URL

Format of the URL to be used

https://<YOUR-AZURE-APP-NAME>/slack/events

Scopes

app_mentions:read
channels:read
chat:write
chat:write.public
commands
im:write
users:read
users:read.email

Email

All of the email user and password variables will need to be set in order to send an email with the modal contents to the address specified.

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 using hosted wordpress set the EMAIL_TO address to the random Wordpress email generated by Wordpress, more information.

If you are not using hosted wordpress, then you can create a dedicated gmail or other account and use this address.

See .env-f3nation-community file for help on local development.

Deployment

Go to Azure App Services > Deployment Center and set up an integration with your Github repo where you forked this repo and have the Slackblast code. Azure will create a main_.yml file under .github/workflows folder, but it should be hidden by default and you should not need to worry about it. Whenever you make any change to your main branch, it will deploy the most recent code.

Here is further reading if you want to know what is going on under the hood.

Notes

Use vscode locally with a .env file with the above variables. With vscode Azure extension, you can right-click on 'Application Settings' and it will upload your .env variables right into the AppService.

Pushing to the github repo should trigger a new deployment to Azure if you set up the AppService correct.

Startup command(s)

To run locally:

pip install -r requirements.txt
gunicorn -k uvicorn.workers.UvicornWorker --bind "0.0.0.0:8000" --log-level debug app:app

In another console, use the url output by ngrok to update your slackblast app settings:

ngrok http 8000

See .env-f3nation-community file for more details on local development

Contributors ✨

Thanks goes to these awesome PAX (emoji key):


Trent

🤔 💻 📖 🧑‍🏫 👀

yankeestom

🤔 💻 👀

willhlaw

🤔 💻 📖 📆

jim-muzzall

🤔 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

About

Slack App to easily create BackBlasts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%