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
Hydro Quebec API wrapper.

HydroQC Hydro Quebec API wrapper. This is a package to access some functionalities of Hydro Quebec API that are not documented. Documentation https://

Olivier BEAU 9 Dec 02, 2022
Discord.py(disnake) selfbot

Zzee selfbot Discord.py selfbot Version: 1.0 ATTENTION! we are not responsible for your discord account! this program violates the ToS discord rules!

1 Jan 10, 2022
⚔️ Fastest tibia bot API

📝 Description tibia bot api using python ⌨ Development ⚙ Running the app python bot.py ✅ ROADMAP Add confidence to floor level to have more accuracy

Lucas Santos 133 Dec 28, 2022
Pincer-ext-commands - A simple, lightweight package for pincer prefixed commands

pincer.ext.commands A reimagining of pincer's command system and bot system. Ins

Vincent 2 Jan 11, 2022
Discord Bot Sending Members - Leaked by BambiKu ( Me )

Wokify Bot Discord Bot Sending Members - Leaked by BambiKu ( Me ) Info The Bot was orginaly made by someone else! Ghost-Dev just wanted to sell "priva

bambiku 6 Jul 05, 2022
Telegram bot to download tiktok video/audio

TikTokDL (Bot) Telegram RoBot to Download Tiktok video/audio. Features: 👉 Download TikTok Video without Watermark 👉 Download TikTok Video with Water

X-Noid 23 Nov 21, 2022
A Telegram AntiChannel bot to ban users who using channel to send message in group

Anti-Channel-bot A Telegram AntiChannel bot to ban users who using channel to send message in group. BOT LINK: Features: Automatic ban Whitelist Unban

Jigar varma 36 Oct 21, 2022
Info gathering | API hacketarget.com

InfoFetch Info gathering | API hackertarget.com set-up: apt-get install python3 pip3 install requests apt-get install git git clone https://github.com

Muhammed Rizad 4 Nov 22, 2021
DiscWrappy - A Python wrapper for the Discord bot API

DiscWrappy - A Python wrapper for the Discord bot API

Jeff Morris 4 Apr 25, 2022
Repository for the Nexus Client software.

LinkScope Client Description This is the repository for the LinkScope Client Online Investigation software. LinkScope allows you to perform online inv

107 Dec 30, 2022
A python discord client interaction emulator for the DC29 badge code channel

dc29-discord-signalbot A python discord client interaction emulator for the DC29 badge code channel Prep Open Developer mode Open the developer mode f

8 Aug 23, 2021
This is a simple collection of instructions and scripts to accompany the computerphile video about mininet and openflow.

How to get going. This project should work on Linux or MacOS. I used Ubuntu 20.04 and provide some notes here. Note, this is certainly not intended as

Richard G. Clegg 70 Jan 02, 2023
Python client for CoinPayments API

pyCoinPayments - Python API client for CoinPayments Updates This library has now been converted to work with python3 This is an unofficial client for

James 27 Sep 21, 2022
A Python AWS Lambda Webhook listener that generates a permanent URL when an asset is created in Contentstack.

Webhook Listener A Python Lambda Webhook Listener - Generates a permanent URL on created assets. See doc on Generating a Permanent URL: https://www.co

Contentstack Solutions 1 Nov 04, 2021
Stackoverflow Telegram Bot With Python

Template for Telegram Bot Template to create a telegram bot in python. How to Run Set your telegram bot token as environment variable TELEGRAM_BOT_TOK

PyTopia 10 Mar 07, 2022
Pure Python 3 MTProto API Telegram client library, for bots too!

Telethon ⭐️ Thanks everyone who has starred the project, it means a lot! Telethon is an asyncio Python 3 MTProto library to interact with Telegram's A

LonamiWebs 7.3k Jan 01, 2023
A tool that ensures consistent string quotes in your Python code.

pyquotes Single quotes are superior. And if you disagree, there's an option for this as well. In any case, quotes should be consistent throughout the

Adrian 9 Sep 13, 2022
This repository will be a draft of a package about the latest total marine fish production in Indonesia. Data will be collected from PIPP (Pusat Informasi Pelabuhan Perikanan).

indomarinefish This package will give us information about the latest total marine fish production in Indonesia. The Name of the fish is written in In

1 Oct 13, 2021
python3.5+ hubspot client based on hapipy, but modified to use the newer endpoints and non-legacy python

A python wrapper around HubSpot's APIs, for python 3.5+. Built initially around hapipy, but heavily modified. Check out the documentation here! (thank

Jacobi Petrucciani 140 Dec 21, 2022
Basic Python3 request wrapper for the PancakeSwap API

🐍 Python Pancakes 🥞 A simple request wrapper for the Pancake-Swap API. Installation Install package # Using pip $ pip install pythonpancakes # Or f

Scott Burlovich 30 Nov 20, 2022