Giter Club home page Giter Club logo

airq_bot's Introduction

Air Quality Twitter Bot

This is a simple serverless application that creates plots and graphics based on data taken from the air quality monitors installed by the US Embassy in Sarajevo. If you have a Twitter developer account, and have generate the appropriate keys you can deploy your own bot.

This is a collection of AWS Lambda functions that are managed by a AWS Step Function, and scheduled to run every hour via AWS CloudWatch. If you wish to deploy the app yourself you need to create each lambda function separately, and bundle it together with their dependencies, a guide on how to do se can be found here.

The dependencies are :

  1. Feedparser - feed_parser function
  2. Numpy & matplotlib - make_hist function
  3. Pillow and Numpy - merge_images function
  4. Pillow - write_on_img function
  5. Twython - publish_to_tw function

Other imported libraries are already available through AWS Lambda, so there is no need to import them.

All functions except for 'feed_parser' rely on the following environmental variables being set:

  1. make_hist - REGION_HOST, S3_BUCKET
  2. merge_images - REGION_HOST, S3_BUCKET
  3. write_on_img - REGION_HOST, S3_BUCKET
  4. publish_to_tw - REGION_HOST, S3_BUCKET, CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_SECRET

You will need to have an S3 bucket created, where you can copy the 'assets' folder into. It contains the font to use, as well as the basic templates used for writing the AQI values. Specify the name of the bucket and the region it is in as the env values for S3_BUCKET, and REGION_HOST, respectively.

Once you have created the lambda functions, with the dependencies included, you can proceed to create the state machine. It does not depend on any user input. The cloudfront template is provided as 'state_machine.yml'. In case of any errors please open the cloudfront template designer, and validate it there as the YAML format can have odd validation issues.

You can either start the step function from the step functions console, or set it to run periodically using cloud watch.

This is a great guide for genomics on AWS, it helped me understand lambda and SF much better. For guides into using AWS Lambda and other services please consult their documentation.

The bot can be found on Twitter, and so can I.

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.