Giter Site home page Giter Site logo

kyhau / slack-command-app Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 75 KB

A Slack App/Bot that can handle requests triggered from a Slack Command which will take longer than 3 seconds to process, and posts the details back to the user.

Home Page: https://kyhau.github.io/slack-command-app/

Python 92.54% Shell 7.46%
slack-bot python aws aws-lambda aws-cloudformation aws-apigateway

slack-command-app's Introduction

slack-command-app

This repo provides the source code for building a Slack Command App/Bot with AWS API Gateway and Lambda Functions. This SlackApp can handle requests triggered from a Slash Command which will take longer than 3 seconds to process, and posts the details back to the user.

Overview

Architecture

Setup on Slack

To create a Slack Command in Slack (the default command in this repo is /lookup)

  1. Navigate to https://api.slack.com/apps.
  2. Select Create New App and select Slash Commands.
  3. Enter the name /lookup for the command and click Add Slash Command Integration.
  4. Enter the provided API endpoint URL in the URL field.
  5. Copy the Verification Token from Basic Information.

Deploy to AWS

  1. Deploy a CloudFormation stack with cloudformation/S3-Artifacts-template.yaml, that creates a S3 bucket for stroing the Lambda Function artifacts.
  2. Package and upload the Lambda Function artifacts to S3 with scripts/upload_artifacts_to_s3.sh.
  3. Store your Slack token in Parameter Store with scripts/create_ssm_parameter.py.
  4. Deploy a CloudFormation stack with cloudformation/SlackCommandApp-template.yaml, that creates the following AWS Components.
    1. An API Gateway to provide an endpoint to be invoked from a Slack Command.
    2. A Lambda Function lambda/slack_app_immediate_response.py to perform authentication, some basic checks and send an intermediate response to Slack within 3 seconds (Slack requirement). This function invokes another Lambda function to to the request tasks (synchronously invocation for quick task; asynchronous invocation for long tasks).
    3. A Lambda Function lambda/slack_app_async_worker.py to perform actual operation that may take more than 3 seconds to finish.
    4. A Lambda Function lambda/slack_app_sync_worker.py to perform actual operation that takes less than 3 seconds to finish.
    5. A KMS key for encryption in transit for Slack token.
    6. A S3 bucket for storing logs.

Try it on Slack

E.g. if command is /lookup, then

  1. Run /lookup async
  2. Run /lookup sync

slack-command-app's People

Contributors

kyhau avatar

Watchers

James Cloos avatar  avatar  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.