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

You might also like...
Slack bot for monitoring your Metaflow flows!
Slack bot for monitoring your Metaflow flows!

Metaflowbot - Slack Bot for your Metaflow flows! Metaflowbot makes it fun and easy to monitor your Metaflow runs, past and present. Imagine starting a

A simple script & container to pull COVID data from covidlive.com.au and post a summary to a slack channel
A simple script & container to pull COVID data from covidlive.com.au and post a summary to a slack channel

CovidLive AU Summary Slackbot This bot is a very simple slackbot that pulls data, summarises and posts up to date AU COVID stats to a provided slack c

A Python app to serve Conveyor room requests and run approvals through Slack
A Python app to serve Conveyor room requests and run approvals through Slack

✨ CONVEYOR FOR SLACK ✨ This is a friendly little Python app that will allow you to integrate your instance of Conveyor with your Slack workspace. In o

Send Informative, Concise Slack Notifications With Minimal Effort

slack-templates Send Informative, Concise Slack Notifications With Minimal Effort slack-templates Slack Integration Available Templates Usage Report t

A python library for creating Slack slash commands using AWS Lambda Functions

slashbot Slashbot makes it easy to create slash commands using AWS Lambda functions. These can be handy for creating a secure way to execute automated

Python app to notify via slack channel the status_code change from an URL

Python app to notify, via slack channel you choose to be notified, for the status_code change from the URL list you setup to be checked every yy seconds

Automation application was made by me using Google, Sheet and Slack APIs with Python.

README This application is used to transfer the data in the xlsx document we have to the Google Drive environment and calculate the "total budget" wit

A quick and dirty script to scan the network, find default credentials on services and post a message to a Slack channel with the results.

A quick and dirty script to scan the network, find default credentials on services and post a message to a Slack channel with the results.

Webservice that notifies users on Slack when a change in GitLab concern them.

Gitlab Slack Notifier Webservice that notifies users on Slack when a change in GitLab concern them. Setup Slack Create a Slack app, go to "OAuth & Per

Comments
  • Add sorting key for users

    Add sorting key for users

    db2csv 함수에, sorting_key 파라미터를 추가하였고, 일단 default로 username을 넣어 두었습니다.

    User를 sorting 하는 부분

    ## Sort by key
    if sorting_key in columns:
        users = sorted(users, key=lambda k: k[sorting_key]) 
    
    opened by thejungwon 2
  • Feature/init db

    Feature/init db

    일단 pytest를 진행하기 전에, 말씀하신 table 생성과 삭제를 위해 table 관련된 함수를 새로 작성하였습니다.

    그리고, table의 생성과 삭제는 외부에서 호출하는 식으로 처리하도록 변경하였습니다

    zappa invoke dev 'from db import create_table;create_table()' --raw
    zappa invoke dev 'from db import delete_table;delete_table()' --raw
    
    opened by thejungwon 1
  • Add lambda function for attendance check using dynamodb and s3

    Add lambda function for attendance check using dynamodb and s3

    일단, 제공해주신 샘플데이터를 활용한 상태로 테스트를 마친 상태입니다!

    몇 가지 확인을 못한 점은, DynamoDB Scan말고 Query를 쓰고 싶었는데 인덱스 설정을 변경을 해야하는 것 같아서 일단 Scan으로 event_ts를 찾는 방식으로 처리했습니다.

    그리고 현재는 모든 유저를 하나씩 Slack에 요청하는 상태인데, 한번에 여러 유저를 요청 할 수 있는 방법이 있는지는 아직 확인 하지 못했습니다. 그래서 일단은 Lambda 실행 시간을 조금 넉넉히 줘야 할 것 같습니다.

    opened by thejungwon 1
  • Zappa + github action

    Zappa + github action

    https://velog.io/@jbae/Github-Action%EC%99%80-zappa%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%98%EC%97%AC-Lambda-%EB%B0%B0%ED%8F%AC-%EC%9E%90%EB%8F%99%ED%99%94%ED%95%98%EA%B8%B0-z0k5upph17

    필요할까요?

    opened by hunkim 1
Owner
UpstageAI
UpstageAI
A simple python bot that serves to send some notifications about GitHub events to Slack.

github alerts slack bot ?? What is it? ?? This is a simple bot that serves to send some notifications about GitHub events to Slack channels. These are

Jackson Alves 10 Dec 10, 2022
Full-featured Python interface for the Slack API

This repository is archived and will not receive any updates It's time to say goodbye. I'm archiving Slacker. It's been getting harder to find time to

Oktay Sancak 1.6k Dec 13, 2022
A Flask inspired, decorator based API wrapper for Python-Slack.

A Flask inspired, decorator based API wrapper for Python-Slack. About Tangerine is a lightweight Slackbot framework that abstracts away all the boiler

Nick Ficano 149 Jun 30, 2022
Slack Developer Kit for Python

Python Slack SDK The Slack platform offers several APIs to build apps. Each Slack API delivers part of the capabilities from the platform, so that you

SlackAPI 3.5k Jan 2, 2023
Quickly edit your slack posts.

Lightning Edit Quickly edit your Slack posts. Heavily inspired by @KhushrajRathod's LightningDelete. Usage: Note: Before anything, be sure to head ove

Cole Wilson 14 Nov 19, 2021
As Slack no longer provides an API to invite people, this is a Selenium Python script to do so

As Slack no longer provides an API to invite people, this is a Selenium Python script to do so

Mehdi Bounya 4 Feb 15, 2022
Reddit cli to slack at work

Reddit CLI (v1.0) Introduction Why Reddit CLI? Coworker who sees me looking at something in a browser: "Glad you're not busy; I need you to do this, t

null 3 Jun 22, 2021
A slack bot that notifies you when a restaurant is available for orders

Slack Wolt Notifier A Slack bot that notifies you when a Wolt restaurant or venue is available for orders. How does it work? Slack supports bots that

Gil Matok 8 Oct 24, 2022
A self hosted slack bot to conduct standups & generate reports.

StandupMonkey A self hosted slack bot to conduct standups & generate reports. Report Bug · Request Feature Installation Install already hosted bot (Us

Muhammad Haseeb 69 Jan 1, 2023
This automation protect against subdomain takeover on AWS env which also send alerts on slack.

AWS_Subdomain_Takeover_Detector Purpose The purpose of this automation is to detect misconfigured Route53 entries which are vulnerable to subdomain ta

Puneet Kumar Maurya 8 May 18, 2022