Code Monkey home page Code Monkey logo

serverless-webhooks's Introduction

Serverless Webhooks

license serverless serverless

Serverless Webhooks is a small python project that digests webhooks from services that don't easily support push notifications and turns them into Pushbullet pushes. Depending on the number of events this project should fit under the free tier on AWS.

At this stage it supports GitHub, Discourse and Mailerlite webhooks inbound and only Pushbullet for notifications. Eventually I would like to move the Pushbullet code out to be more portable and support other platforms.

Setup

Enncrypted Variables

This project uses AWS SSM environment variables to store secret tokens. A below example shows how to store them using the AWS CLI tools:

aws ssm put-parameter --name /hooks/pushbullet_api_key --value <secure token in here> --type SecureString

Requirments

Install serverless and serverless-python-requirements:

npm install -g serverless
sls plugin install serverless-python-requirements

Install python requirements
Note: Its highly suggested you install the python requirments inside a virtualenv!

pip install -r requirements.txt

Now login to Pushbullet and generate an access token. This access token should be store as a SSM variable under /hooks/pushbullet_api_key.

Now deploy your Serverless gateway:

sls deploy

Endpoints

GitHub

  1. Generate a secret token
    You could use ruby -rsecurerandom -e 'puts SecureRandom.hex(20)'
  2. Add your secret to AWS SSM under /hooks/github_secret eg:
    aws ssm put-parameter --name /hooks/github_secret --value a3f7b3d530ab15e2f07df0324f8255cfcade49cd --type SecureString
    
  3. Confirm your gateway that serverless created above (check it via sls info)
  4. Go to your repository settings -> Webhooks.
  5. Add a new webhook:
    • Payload URL -> Your serverless POST endpoint for GitHub
    • Content Type -> application/json
    • Secret -> The secret you generated above
    • Events -> The events configured in config.yaml
  6. Click add Add Webhook!

If you've done everything above correctly you should recieve a Ping event from GitHub via Pushbullet.

Discourse

  1. Generate a secret to sign the payloads with You could use ruby -rsecurerandom -e 'puts SecureRandom.hex(20)'
  2. Add your secret to AWS SSM under /hooks/discourse_secret eg:
    aws ssm put-parameter --name /hooks/discourse_secret --value a3f7b3d530ab15e2f07df0324f8255cfcade49cd --type SecureString
    
  3. Confirm your gateway that serverless created above (check it via sls info)
  4. Go to the Discourse Admin interface -> API -> Webhooks -> New Webhook
  5. Enter your settings into Discourse:
    • Payload URL for the Discourse endpoint (/v1/discourse)
    • Content-Type -> application/json
    • Secret -> the one you generated above

If you've done everything above correctly try and send a ping event to your Discourse endpoint!

Mailerlite

Doco coming!


Licence: MIT

serverless-webhooks's People

Contributors

dependabot[bot] avatar jloh avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

miyaichi

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.