Twitter Bot Workshop

NYU ITP, Spring 2017. Instructor: Allison Parrish. Send me e-mail.

Turn in your homework here.

Example code on Github.

Description

Over the past decade, the “artbot” has emerged as an exciting new genre of artistic practice. Bots like @thinkpiecebot, @censusamericans, and @tiny_star_field demonstrate that bots aren’t limited to being anodyne conversational agents—they can be incisive satirists, insightful reporters, and even graffiti artists. This class guides students through the process (both conceptual and technical) of making bots—not just as interfaces, but as vehicles for rhetoric and expression in and of themselves. Diving deep into the affordances of Twitter as a software platform, students will learn how to write computer programs that post tweets automatically, hold conversations, interact with other bots and make use of Twitter’s search functionality. Weekly technical exercises and readings will culminate in a final project. Example code will be provided in both Python and Javascript.

Ethos, methodology and structure

In this class, you’ll be making Twitter bots in response to weekly prompts that suggest a number of formal and functional characteristics, in accordance with the technical and conceptual content of the class that week. This class is billed as a “workshop,” and a great deal of in-class time will be devoted to exactly that: giving feedback on one another’s Twitter bots. The balance of our time will be spent in programming tutorial sessions and reading discussions.

The readings in this class are offered in the interest of encouraging informed and diverse work. The readings are mandatory, and you should prepare at least one question to present to the class for each reading assigned. We’ll spend 20-30 minutes of each class session discussing the readings as a group.

We’ll use the entire final session of the class for final project presentations. For more information about the requirements and parameters of the weekly assignments and final project, see below.

Attendance, lateness and in-class behavior policies

Attendance

You are expected to attend all class sessions. Absences due to non-emergency situations will only be cleared if you let me know a week (or more) in advance, and even then only for compelling personal or professional reasons (e.g., attending an important conference, going to a wedding). If you’re unable to attend class due to contagious or incapacitating illness, please let me know (by e-mail) before class begins.

Each unexcused absence will deduct 5% from your final grade. If you have three or more unexcused absences, you risk failing the course.

Timeliness

Be on time to class. If you’re more than fifteen minutes late, or if you leave early (without my clearance), it will count as an unexcused absence.

In-class behavior

Laptops must be closed while your fellow students are presenting work. You’re otherwise welcome to use laptops in class, but only to follow along with the in-class tutorials and to take notes. (Keeping all of this in mind.)

Procedures should punch up

Read Leonard Richardson’s Bots should punch up. “You can poke fun at yourself (Stephen Colbert famously said ‘There’s no status I would not surrender for a joke’), you can make a joke at the expense of someone with higher social status than you, but if you mock someone with lower status, it’s not cool.” Be sensitive to what your classmates might find offensive, triggering, or violent; be graceful (not defensive) and listen carefully when your work gets called out.

Academic integrity

Please review the Tisch School of the Arts Academic Integrity policy. For the purposes of this class, “plagiarism” that violates the academic integrity policy is defined as representing someone else’s code (or other procedure) as your own. (We will, of course, liberally be using text that other people have written as source material for our code and procedures—this does not violate the academic integrity policy. You are, however, expected to cite the sources of these materials where possible.)

Disability accomodations

I am asked to include the following verbiage on my syllabus:

If you are a student with a disability and feel you
need accommodations, you must register with the Moses
Center for Students with Disabilities. They are located
at 726 Broadway, 2nd fl. and can be reached at
212-998-4980 or mosescsd@nyu.edu.

You can find more information about NYU’s disability policies here. I am dedicated to making my classroom accessible for all individuals, but ask that requests for accommodations be made through official channels. (This makes things easier for both of us, in the long run.) I’m happy to (confidentially) discuss any accessibility-related issues that arise in the class. You are not required to disclose your disability.

Assignments and projects

Turn in your homework here.

This class has five deliverables: four weekly bot-building assignments, and a final project.

The weekly bot-building assignments concern the technical and conceptual content discussed in a particular class session, and are due at the beginning of the following session. Work turned in after the deadline will not be accepted. Each of these assignments will take the form of a Twitter bot. You must write a blog post to document assignment; this post should talk about what you hoped to accomplish with the bot and provide an evaluation of how well your implementation matched your ambitions. This post should also include a link to the source code of your bot for my review. (If you don’t want to share your source code publicly, you can send it to me instead by e-mail as an attachment.) Weekly projects will be the subject of in-class feedback sessions.

The final project has no set requirements, but I will evaluate your project based on how well it demonstrates your mastery of the technical and conceptual content of the class. You must document your final project in a blog post and include a link to your source code. Additionally, you will present your final project on the final day of class. Plan on a presentation that lasts from eight to twelve minutes.

Grading policy

Component Percentage
Attendance and participation 35%
Bot assignments 4 x 10% (40%)
Final project 25%

Here’s the breakdown of how grades correspond with percentages.

Grade Percentage
A 90 to 100
B 80 to 89
C 70 to 79
D 60 to 69
F Below 60

For students taking the class as pass/fail (i.e., all ITP students), anything below a B (79% and below) will be graded as a fail. More information on ITP’s grading policy here.

Schedule

Session 1 (2017-01-25): What Is The Bot

Notes

  • Generate text from grammars with Tracery. My Tracery tutorial; here’s Beau Gunderson’s Tracery Writer, which we’ll use in class
  • Lines to JSON is a little utility I made that formats lines of plain text as JSON, to make it easier to incorporate them into a Tracery grammar.
  • Darius Kazemi’s Corpora Project is a database JSON files with various lists of things that you can easily cut and paste into a Tracery grammar.
  • Once you’ve written a Tracery grammar, you can turn it into a Twitter bot instantly with Cheap Bots Done Quick

Reading

To be discussed 2017-02-01.

Assignment

Due 2017-02-01: Make five bots with Cheap Bots Done Quick. Be experimental!

Session 2 (2017-02-01): Persistence, enumeration, exhaustion

  • Homework presentations
  • Reading discussion
  • Posting to Twitter through the API
  • Retaining state and advancing through a corpus
  • Scheduling code to run periodically

Notes

Reading

To be discussed on 2017-02-08.

Assignment

Assignment #2 (due 2017-02-08): Make a bot that iterates, enumerates, or exhausts.

Session 3 (2017-02-08): Listening, responding and conversing

Notes and example code

Examples of bots that respond (using the user stream):

Reading

To be discussed 2017-02-15.

Assignments

Assignment #3 (due 2017-02-15): Make a bot that responds (to @-replies or direct messages). Note: for this week, do not make a bot that responds to people who haven’t “opted in” (i.e., people who don’t follow your bot).

Session 4 (2017-02-15): Twitter as corpus

  • Homework presentations
  • Reading discussion
  • Using the Search API
  • Using the Streaming API to listen for keywords

Notes and example code

Reading

To be discussed 2017-02-22.

Assignment

Assignment #4 (due 2017-02-22): Make a bot that uses Twitter as its corpus. Also, come prepared with an idea about what you want to do for your final project.

Session 5 (2017-02-22): Bots elsewhere

  • Homework presentations
  • Reading discussion
  • Final project proposals
  • Your bot as a web server, using Express
  • Simple SMS bot with Twilio

Example code

Notes

There are so many tutorials for working with Twilio out there! We’ll essentially be following this one: Receive and reply to SMS and MMS messages in Node.JS

Dan Shiffman has a good overview of writing server software with Node.JS and Express.

Session 6 (2017-03-01): Final project presentations

  • Final project presentations