First Bot

Create a data-driven bot that responds to user input. Imagine your “bot” living on a cloud web server. A user visits a URL on that server, the server sends a message to your bot program, your bot does something.

Deploying this bot will probably involve you learning Flask and Github and also remember how to SSH into a remote server (or maybe use Heroku). Don’t worry, it’ll be fun.


Due date: 2017-03-17

Points: 100

Email me with the subject line of:


The email should contain a zip file named:

I actually prefer you put the code folder up as a Github repo, but if you run into a hiccup, you can email me for now.


The folder structure of your project should look like this:

├── data
    ├── samples

The file is a 600-word writeup of why you designed your bot to do what it did. Describe the data-finding/wrangling process, including any limitations. Please include links to any stories or other projects from which you drew inspiration.

The two library scripts don’t have to be named that. but think of those scripts as the ones in charge of the two different datasets that you’re using, including the downloading/parsing, etc. Your script should be importing the necessary functions from, etc., so that you aren’t writing a gigantic script.

The script should look something like this:

from library_1 import *
from library_2 import *

def bot(first_arg, second_arg):

You should plan on your bot returning a string, like a HTML string (which I’ll get you up to speed quick). Unless you’re doing something crazy, like producing a picture.

Here’s an example of a bot in this Github repo:

Notice how the code related to the Texas death penalty scraping is in a separate file, and how imports only the function it needs to do the job:

from texas_scraper import get_inmates


def bot(datestr):
    # etc ...
    story = make_story(refdate, sortedinmates[0])

Requirements for the bot

  • Accepts at least one argument from user input, such as user-location, name, date, zip code, age, etc.
  • Draws from at least 2 sources of data.
  • Outputs a message or “story” that reflects a filtering/transformation of the data.

Bot deployment

This is where things get a little bit tricky. After you make sure your bot works on your own computer, we’ll put it up on a cloud server.

To keep things simple for this first bot, we’ll assume that it works off of a trigger. And that trigger can be as simple as visiting a URL.

For example, consider ProPublica’s Election DataBot. Here’s the landing page:


The main feature is a section called the “Firehose” where all the updates are posted. Take a look at the imperfect output, and at the “stories” ProPublica considers important:

Congressional Leadership Fund filed a report about spending $1.1 million against

Jim Cooper voted “Yes” against their party in the House on H R 1004.

We can also click through to the individual candidates and committees to see their streams. Here’s Jim Cooper:

Look at the URL, in which TN and 5 are provided as arguments, and we get data/stories focused on Rep. Cooper.


So your bot will live on a web server. At the very least, it’ll post some HTML. You can make it fancy if you want. Or, you could have that web trigger make the bot send a text message or tweet. Up to you.