Slack->DynamDB->Some applications

Overview

slack-event-subscriptions

About The Project

Do you want to get simple attendance checks? If you are using Slack, participants can just react on a specific post, then we can check the attendance based on the reaction. It's so simple and fun.

Built With

If you are not familiar with the libraries below, please read the documentation for the links below before getting started.

Getting Started

Prerequisites

  • Python3 (below 3.9, Zappa doesn't support 3.9 yet)
  • AWS credentials
  • Slack App
    1. Create the new app from https://api.slack.com/apps.
      screenshot_01
    2. Copy the signing secret.
      screenshot_02
    3. Add an OAuth scope (users.profile:read) and install to work space.
      screenshot_03
      screenshot_04
    4. Copy the OAuth Access Token.
      screenshot_05

Installation

  1. Clone the repo
    git clone https://github.com/UpstageAI/slack-event-subscriptions.git
  2. Install Python packages
    cd slack-event-subscriptions
    pip install -r requirements.txt
  3. Init Zappa
    zappa init
  4. Update the zappa_settings.json like the example below.
    • (REQUIRED) aws_region, REGION_NAME : AWS region for your services
    • (REQUIRED) SLACK_SIGNING_SECRET : Siging secret of your slack app
    • (REQUIRED) SLACK_OAUTH_TOKEN : Oauth token of your slack app
    • (REQUIRED) TABLE_NAME : Table name for DynamoDB
    • (OPTIONAL) SLACK_CHECK_CHANNEL : Specific channel id for the event subscription. (if it's empty, you will get the events from all channels.)
    • (OPTIONAL) KEY_WORD : In case you want to filter some users based on their name.
    ###Example for `zappa_settings.json`
    
     {
         "dev": {
             "app_function": "app.app",
             "aws_region": "ap-northeast-2",
             "profile_name": null,
             "project_name": "slack-event-sub",
             "runtime": "python3.8",
             "s3_bucket": "zappa-ih029w3pa",
             "environment_variables": {
                 "SLACK_SIGNING_SECRET": "<YOUR_SLACK_SIGNING_SECRET>",
                 "SLACK_OAUTH_TOKEN": "<YOUR_SLACK_OAUTH_TOKEN>",
                 "SLACK_CHECK_CHANNEL":"XXXXXXXXXXX",
                 "REGION_NAME": "ap-northeast-2",
                 "TABLE_NAME":"slack_attendance_check",
                 "KEY_WORD":""
             }
         }
     }
  5. Deploy the app and copy the endpoint from the output
    zappa deploy dev
    ...
    Waiting for stack slack-event-sub2-dev to create (this can take a bit)..
    50%|███████████████████████████████████████████████                                               | 2/4 [00:09<00:09,  4.90s/res]
    Deploying API Gateway..
    Deployment complete!: https://eycl36fqk9.execute-api.ap-northeast-2.amazonaws.com/dev
    
  6. Create the tables (for the first time)
    zappa invoke dev 'from db import create_table;create_table()' --raw
  7. Update the configurations for slack app.
    1. Enable events by adding <YOUR_ENDPOINT_URL>/slack/events
      screenshot_06
    2. Add workspace event reaction_added and user_change
      screenshot_07
  8. Save and reinstall your app.

Usage

Once you finish the setting, post the sample message in your slack channel and add a reaction.
screenshot_08

Then, you can find two tables from your DynamoDB.
screenshot_09 the shorter name one is the table for the event storing
screenshot_10 And, the table with a suffix _user is an actual organized version by the date and the name of the users.
screenshot_11

You can also access the data via api <YOUR_ENDPOINT>/csv, and it will return csv version.

user_id,username,z20210112
U01JH17VD19,Jungwon Seo,17:35:19
U01JH17VD20,Junglost Seo,17:36:20
U01JH17VD33,Jungdraw Seo,17:37:33
...

The csv api supports two query parameters d and s.

  • d: specific date for the list (e.g., d=20210112), if none, entire dataset will be returned.

  • s: sorting key for the result (e.g., s='user_id`). Only ascending order supports yet.

How to Test

You can update the temporary environment variable in pytest.ini

pytest test.py

Ohters

  • Updating the work
    zappa update dev
  • Cleaning the work
    zappa invoke dev 'from db import delete_table;delete_table()' --raw
    zappa undeploy dev 

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Jungwon Seo - [email protected]

Project Link: https://github.com/UpstageAI/slack-event-subscriptions

Owner
UpstageAI
UpstageAI
Automatic generation of crypto-arts based on image layers

NFT Generator Автоматическая генерация крипто-артов на основе слоев изображения. Установка pip3 install -r requirements.txt rm -rf result/* Как это ра

Zproger 31 Dec 29, 2022
Presentation and code files for the talk at PyCon Indonesia

pycon-indonesia Presentation and code files for the talk at PyCon Indonesia. Files used for the PyCon Indonesia presentation. [Directory Includes:] Be

Neeraj Pandey 2 Dec 04, 2021
Keypirinha plugin to install packages via Chocolatey

Keypiriniha Chocolatey This is a package for the fast keystroke launcher keypirinha (http://keypirinha.com/) It allows you to search & install package

Shadab Zafar 4 Nov 26, 2022
Best badge generator API to count visitors of your Repository / Account 🥇

github visitors badge A badge generator service to count visitors of your markdown file. Hello every one! In this post, I will tell you the story of m

Sᴇɴᴜ Gᴀᴍᴇʀ Bᴏʏ 〽 3 Dec 11, 2021
radiant discord anti nuke src leaked lol.

radiant-anti-wizz-leaked radiant discord anti nuke src leaked lol, the whole anti sucks but idc. sucks to suck thats tuff bro LMAOOOOOO join my server

ok 15 Aug 06, 2022
A Powerful, Smart And Advance Group Manager ... Written with AioGram , Pyrogram and Telethon...

❤️ Shadow ❤️ A Powerful, Smart And Advance Group Manager ... Written with AioGram , Pyrogram and Telethon... ⭐️ Thanks to everyone who starred Shadow,

TeamShadow 17 Oct 21, 2022
A stable telegram bot to get restricted messages with custom thumbnail support

Save restricted content Bot A stable telegram bot to get restricted messages with custom thumbnail support

DEVANSH 3 Feb 09, 2022
Converts a text file of songs to a playlist on your Spotify account.

Playlist Converter Convert a text file of songs to a playlist on your Spotify account. Create your playlists faster instead of manually searching for

Priya Aggarwal 18 Dec 21, 2022
Clisd.py - UI framework with client side rendering for python

clisd.py Clisd is UI framework with client side rendering for python. It uses WA

2 Mar 25, 2022
Projeto de teste para acesso a API SWAPI.

SwapiTest Projeto de teste para acesso a API Swapi com informações sobre Star Wars. Como rodar o programa Foi utilizado o pipenv, então basta clonar o

Gabriel de Souza Alves 1 Nov 23, 2021
quote is a python wrapper for the Goodreads Quote API, powered by gazpacho.

About quote is a python wrapper for the Goodreads Quote API, powered by gazpacho.

Max Humber 11 Nov 10, 2022
A python script that can send notifications to your phone via SMS text

Discord SMS Notification A python script that help you send text message to your phone one of your desire discord channel have a new message. The proj

2 Apr 25, 2022
Lazy airdrop based on private temporary ids

LobsterDAO This uses a modified MerkleDistributor, which allows to issue a lazy airdrop using temporary IDs. In this example it uses Telegram chat_id

41 Sep 10, 2022
Python SDK for Facebook's Graph API

Facebook Python SDK This client library is designed to support the Facebook Graph API and the official Facebook JavaScript SDK, which is the canonical

Mobolic 2.7k Jan 07, 2023
Python client library for Postmark API

Postmarker Python client library for Postmark API. Gitter: https://gitter.im/Stranger6667/postmarker Installation Postmarker can be obtained with pip:

Dmitry Dygalo 109 Dec 13, 2022
Create Basic ERC20 token with Solidity, Brownie and Python

Create Basic ERC20 token with Solidity, Brownie and Python Demo Check out Cornell Token on Rinnkeby network with Etherscan. Installation Install brown

Ethan Huang 2 Feb 16, 2022
Fetching tweets and integrating it with Kafka and PySpark

KafkaPySpark Zookeeper bin/zookeeper-server-start.sh config/zookeeper.properties Kafka Server bin/kafka-server-start.sh config/server.properties Kafka

Priyansh 2 Dec 29, 2021
Discord bot to administer IITD Study Servers (unofficial)

IITD-Bot Discord bot to administer IITD'20 Acad Server Commands hello to check if bot is online ?help to display this message ?set kerberos to set y

Aditya Singh 47 Dec 19, 2022
A badge generator service to count visitors of your markdown file.

Github Visitors Badge A badge generator service to count visitors of your markdown file. Hello every one! In this post, I will tell you the story of m

Kɪꜱᴀʀᴀ Pᴇꜱᴀɴᴊɪᴛʜ Pᴇʀᴇʀᴀ 〄 1 Feb 06, 2022
AWS Glue PySpark - Apache Hudi Quick Start Guide

AWS Glue PySpark - Apache Hudi Quick Start Guide Disclaimer: This is a quick start guide for the Apache Hudi Python Spark connector, running on AWS Gl

Gabriel Amazonas Mesquita 8 Nov 14, 2022