Inspiration

I have a friend who works on a lot of side projects and he wanted an app that could easily log time spent working for a client.

What it does

Koura is a Messenger bot that makes it simple for businesses to send invoices to customers. When a customer receives an invoice in their inbox, they can go online to make a payment using a credit card. Once the payment goes through, Koura will let the business owner know that the invoice has been paid. Koura has support for time tracking, which allows users to log hours spent working on a task and then attach a time sheet to their invoice.

How I built it

Frontend

  • Facebook Messenger is the bot's user interface

Backend

  • The backend is written in Python 3 and uses Django 1.11
  • I used Docker containers to test my logic before deploying to AWS. Shout out to LambCI for providing images that replicate a live AWS Lambda environment.
  • I used Zappa to package my Django application into a Lambda-compatible ZIP archive
  • All payment processing is done through Stripe

Infrastructure

I used Terraform to deploy all the infrastructure for Koura on AWS. Terraform automatically provisions:

  • S3
  • Lambda
  • RDS (Postgresql)
  • ElastiCache (Redis)
  • VPC
  • CloudFront
  • Route 53
  • CloudWatch
  • IAM Roles
  • API Gateway
  • SQS

Here is the graph Terraform generated for my infrastructure (click to zoom in):

Challenges I ran into

  • The library that I used to package my Django application, Zappa, does not have support for handling Lex events so I had to fork the repository and add my own solution.
  • Initially I used Lex's web interface to configure my bot, but that quickly became a bottleneck. I ended up writing a Python script that takes my bot's configuration in YAML format and automatically creates/updates the bot along with its intents and custom slot types.

Accomplishments that I'm proud of

  • It was tricky at first, but I was able to design a FormIntent class that makes it fairly simple to turn standard Django Form objects into Lex intents. This allows me to leverage Django's libraries when I need to validate user input.
  • I used FIFO queues (via SQS) to feed Facebook messages into Lex
  • First time using Terraform
  • First time using Lambda
  • First project using Python 3
  • 100% serverless
  • 87% test coverage (so close...)
  • 243 unit tests (not sure if that is really an accomplishment...)

What I learned

  • Terraform makes provisioning infrastructure much easier. All my infrastructure is stored in source control, and I don't get slowed down by a GUI if I ever need to make a lot of changes
  • Lambda is amazingly cheap and versatile. I was surprised at how relatively easy it was for me to package a full Django app within a Lambda function
  • Lex is pretty darn smart. Especially when it comes to determining a user's intended actions.

What's next for Koura

There are a ton of features I would love to add to this bot. Here are the top ones:

  • Switch from using Facebook Messenger to a mobile application built with React Native
  • Add time tracking
  • Add charts for hours worked, cash flow, outstanding payments, etc.
  • Give businesses the option to set up recurring payments

Built With

Share this project:

Updates