Inspiration
Friendship API solves a problem that I have: I am just terrible at staying in touch with my friends via email. This is a shame: email is really a great tool for keeping in touch.
What it does
Friendship API works like this: it uses ContextIO to look at people you interact with, filter out what looks like spam and business email, and send you a weekly email reminding you that you owe a person an email.
There's no account or password to manage: the weekly emails contain action links to ignore certain people in the future, generate another reminder, and cancel your subscription. Hence, I use the term "email application".
There's also very little storage we have to do: basically, we keep track of email addresses of people who sign up, their ContextIO tokens, what recommendations we send out, and a list of email addresses that the people want to ignore. If they cancel their subscription, we revoke our ContextIO tokens.
How I built it
How does one go about writing an app like this after getting the idea and setting aside a spare weekend? Well, here's the process I followed at least:
- Outline in your head (or write down) the features that you need to launch with.
- Talk it over with someone.
- Sign up for all of the accounts you might need and don't already have (in this case, the ContextIO developer account).
- Write a simple program to prove that the hard things are possible: in this case, that is reasonable to use ContextIO to get the data we need, and then to generate sensible recommendations.
- Use Celery to make the program calls asynchronous.
- Write a simple Flask app that calls into that program.
- Use RequestBin to capture the ContextIO callback, so you know how to capture the authentication token when someone signs in.
- Write the Flask endpoints to generate a ContextIO signup session, and the Flask endpoint to capture the ContextIO callback information, and process based on that.
- Hook up the recommendation function to send out an email.
- Write a barebones web page that calls out to your web site.
- Setup hosting for everything.
- Have someone who isn't you test out the flow.
- Write the rest of the functions for your bare minimum features.
- Theme the static site.
Challenges I ran into
The most annoying challenge I had was that gunicorn, the application launcher for Python applications at Heroku, uses forking to launch workers. SQLAlchemy (really, the underlying Postgres driver) handles this poorly, since it will then try to share connections amongst multiple processes, which crashes the application.
The next biggest challenge was probably configuring Celery. Celery is a little tricky configure so that the web app can easily submit jobs that are handled by the background workers, and getting this all working on Heroku.
Accomplishments that I'm proud of
I really like the fact that there are no accounts and no passwords. I hate managing accounts and passwords, and designing an app that uses neither is a little... different.
I'm also proud that this seems to make good recommendations with a fairly simple filtering algorithm.
What I learned
- ContextIO makes my life a lot easier if I want to integrate with people's email. :)
- Celery rocks (this is the first time I've used it in production).
What's next for Friendship API
- Suggest topics of conversation. We could pick topics randomly, or we could try to analyze past emails, perhaps.
- Better recommendations. There's still a lot of work that could be done to improve recommendations:
- Using past recommendations to influence future recommendations.
- Adjusting the metric used to pick who to recommend.
- More advanced filters to differentiate business, spam, and friendship conversations.
- Adjusting the frequency of recommendations. It's currently hardcoded to one week per email.
- Better-looking recommendation emails.
Log in or sign up for Devpost to join the conversation.