anwyho / bartbot.bak

[deprecated]๐ŸšˆBART-meets-Messenger chatbot that answers "Should I run to the station?" and more...!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

๐Ÿšˆ BARTbot

Deprecation Notice:

Ever since starting work at Mercedes-Benz R&D NA, my Python proficiency has skyrocketed. I hope to someday make this bot again in Python using Google Cloud Functions and Terraform or cloud-managed Kubernetes (since I know that now). It will be so much cleaner! I'll be especially motivated if I get a job in SF. ;)

Oh shoot.

You, yelling into your phone as you sprint from your Prius:

Do I need to run to catch the Bayfair train to Powell?

Bartbot:

4 min until the next train from Bayfair to Powell. Smell the roses - but not for too long. ๐ŸŒน

You, taking a moment to catch your breath:

๐Ÿ˜Ž

๐Ÿ’ญ Motivation

"Should I run to catch the train?" This was the main question that I wanted to answer with Bartbot.

I have always wanted to make some sort of quick access to the BART API but didn't know where to start developing. Then one day, as I looked for open-source projects to contribute to, I found some examples of Facebook Messenger chatbots! It was then that I became super inspired to create my own chatbot. Thus, Bartbot was born.

Being able to message (or even speak) to BART about the next trains seemed like such a convenient idea. So far, I've learned an incredible amount, since this project covers so much!

Things Bartbot taught me:

  • Writing libraries
    • Semantic Versioning
    • Readme-Driven Development
  • Logging & debugging
  • Package logistics
  • RESTful APIs
    • All the protocols
    • How to design them and how to call them
    • Key/secret management
  • Object Oriented Programming
    • Not the theoretical stuff they teach you in school
    • Inheritance is amazing
  • Functional Programming
    • Concurrency comes by design
    • It isn't always useful to run concurrently
  • Serverless programming
  • Natural language processing
  • NoSQL databases

๐ŸŽ Implementation

I went through plenty of design iterations for how to structure the code, but I have settled with the stack below:

  • Facebook Messenger
    • Periodic GET requests for challenge (verify my webhook is online)
    • POST requests for messages and postback events
  • Amazon Web Services
  • Wit.ai
    • Natural language processing for requests
  • Python 3.6
    • Serverless Framework
      • Handles AWS configurations to set up Lambda and API Gateway
      • Originally, I went with Zappa. It seemed pretty well done but ultimately didn't work for Bartbot.
    • Flask
      • Routes HTTP requests within app
      • I was playing around with Bottle and Zappa in another iteration, but neither were functional enough for Bartbot.
    • Requests
      • Makes HTTP requests easy-peasy
    • unittest
      • Testing testing testing! Helps with unit testing and some integration testing
    • virtualenv
      • Configures development environment
      • I customized some of the BASH scripts to include adding environment variables
    • Have a look at the Python requirements
  • BART API
    • API endpoint for BART information
  • Future Features
    • Pybart (In Development)
      • A Python library for accessing the BART API with caching
    • Dark Sky (Future Support)
      • API endpoint for weather information at specific stations
    • Transfer and arrival notifications
      • I've thought hard about how to implement these with AWS Lambda constraings (and even AWS Step Functions), but haven't come to any solid ideas yet, since neither can take the ~2hr longest trip (Antioch to Dublin Pleasanton). Please shoot me a message if you happen to have a work-around!
    • Increased use of concurrency (even though I'm working in Python)
      • I can easily see implementing futures

๐Ÿ”ง Set It Up

I will detail this section more at v1.0 release.

โœจ Releases/Changelog

Ayy check it.

๐Ÿ™ Contributing

I'm not sure if I'll be supporting contributors before v1.0, but watch the repo and see the contributing guideline if you're interested! It'll be soon.

Also, check out the functions-to-implement checklist.

๐Ÿ† Acknowledgements

This is an awesome get-started article!

This Serverless tutorial got my app up and running.

๐Ÿ”‘ Licensing

GNU GLPv3 Copyright 2018, Anthony Ho.

Doot doot, my dudes.

About

[deprecated]๐ŸšˆBART-meets-Messenger chatbot that answers "Should I run to the station?" and more...!

License:GNU General Public License v3.0


Languages

Language:Python 90.7%Language:Shell 9.3%