Giter VIP home page Giter VIP logo

slackblast's Introduction

slackblast

All Contributors

Python web application needed to utilize modal window inside slack to make posting backblasts easier for PAX.

getting started

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 OAth & Permissions settings. Read on for the nitty gritty details.

environment variables

slackblast requires the following environment variables:

SLACK_BOT_TOKEN=<YOURTOKEN>
SLACK_VERIFICATION_TOKEN=<SLACKVERIFICATIONTOKEN>
SLACK_SIGNING_SECRET=<SLACKSIGNINGSECRET>
POST_TO_CHANNEL=<False or True>
CHANNEL=<USER or THE_AO or channel-id>

# EMAIL_OPTION_HIDDEN_IN_MODAL=<False or True>
EMAIL_TO=<[email protected]>
GMAIL_USER=<[email protected]>
GMAIL_PWD=<app-password>

set SLACK_BOT_TOKEN from the token on the oath page in the slack app

set SLACK_VERIFICATION_TOKEN from the Basic Information -> Verification Token field in the settings for your slack app.

set POST_TO_CHANNEL equal to True or False. Set to true if you are using paxminer. Indicates whether or not to take the modal data and post to a channel in slack.

set CHANNEL=channel-id to the channel id (ID such as C01DB7S04KH -> NOT THE NAME) you want the modal results to post to by default. set CHANNEL=THE_AO to post to the channel that was selected in the modal by default. set CHANNEL=USER to post a DM from the slackblast to you with the results (testing) by default. if CHANNEL is blank or missing, then the default channel will be the channel the user typed the slashcommand. NOTE: In the modal, the user can choose the "destination" and where to post to.

NOTE: In the modal, the user can choose where to post to.

email configuration

set EMAIL_OPTION_HIDDEN_IN_MODAL to True to not show the email option in the modal. The default is to show the option in the modal. Email will still send if others options are set.

set EMAIL_TO, GMAIL_USER, and GMAIL_PWD to send the post to an email address. You must set up the gmail account app password, see here: https://stackabuse.com/how-to-send-emails-with-gmail-using-python/ which refers to https://support.google.com/accounts/answer/185833. To automatically send the post into Wordpress, set the EMAIL_TO address to the random Wordpress email generated by Wordpress, see here: https://wordpress.com/support/post-by-email/#:~:text=Go%20to%20My%20Site(s,posts%20by%20sending%20an%20email%E2%80%9D.

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

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

deployment

main_slackblast.yml or main_.yml contains the code to deploy on Azure via github repository. However, this will be unique to your own installation and is gitignored by default since you shouldn't need to change this as Azure sets it for you.

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

๐Ÿค” ๐Ÿ’ป ๐Ÿ“– ๐Ÿ“†

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

slackblast's People

Contributors

trentjonesln avatar yankeestom avatar willhlaw avatar wolfpackt99 avatar allcontributors[bot] avatar

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.