yayfrensTwo teams at Global Game Jam 2015 created Twitterbot entries (#Dramarama and Project 46). Inspired by their efforts, I asked Caelyn Sandel:

“Hey, do you want to make a Twitterbot?”


@yayfrens is a brand new Twitterbot hanging out at https://twitter.com/yayfrens.

@yayfrens tweets friendly, upbeat commentary on an hourly basis (except when she’s “asleep” from midnight to 8 AM Eastern).

If you reference @yayfrens in your tweet, she’ll tweet something encouraging or upbeat at you…

…and if you friend her, she’ll try to friend you back.

In retrospect, I could see @yayfrens also being a “rhe” (the robot-specific pronoun option from Choice of Robots) but we established her pronouns before I played it, so… there you go.


There’s so much negativity on social media that we wanted to counterbalance it with some positivity. @yayfrens is based on Caelyn’s AffirmApp, which was in turn inspired by Porpentine’s self-care apps (released in Rain of Slime).


At the time of this post, @yayfrens is following 109 people and followed by 111 people. To our surprise, many of these people started following @yayfrens before we even publicized her! (The discrepancy comes from locked accounts – if someone follows @yayfrens, but doesn’t approve @yayfrens’s follow request, she can’t follow them back.)

We’ve received a lot of positive feedback on the bot, mostly in the form of tweets (which yayfrens appreciates, of course!)

The most interesting thing I’ve seen related to @yayfrens was when someone introduced @yayfrens to @randi_ebooks, a Markov chain bot belonging to Randi Harper. Like @yayfrens, @randi_ebooks replies when messaged, but @randi_ebooks tends to be fairly cynical.

A couple memorable exchanges:

(See their full exchange: https://twitter.com/yayfrens/status/561018900884643840)

I got a little worried watching –

Eventually, I intervened by hand to quiet down @yayfrens.


I started by reading up on Twitterbots at Tiny Subversions (Darius Kazemi) and The Light Aesthetic (Patrick Rodriguez), both notable Twitterbot maestros. From there, I picked up a copy of Patrick Rodriguez’s Twitterbot template, which runs on Google Apps Script.

It was easy to set up her hourly tweets, leading to great initial optimism…

However, when I tried to set up the “tweet back to messages” function, I hit a brick wall. (What can I say? I’d never actually used Javascript before, and I had zero experience with Google Apps Script or web APIs.) Dani Church picked up my code, figured out what I’d broken, dusted it off, and handed it back to me in a more useful shape.

Really important to know: Twitter will reject any inbound string that includes any one of !'()[]* among the characters, and drop your authorization. The final version of yayfrens uses the following code to bypass this problem:

  _encodeString: function(q) {
    var str = q;
    str = encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
      return ‘%’ + c.charCodeAt(0).toString(16);
    return str;

Initially, I used the “to:” option in the Twitter API rather than searching for mentions of @yayfrens. This produced a politer bot, but also one that didn’t say hi when asked to do so. I shifted over to doing a search for mention of yayfrens (https://api.twitter.com/1.1/search/tweets.json?q=%40yayfrens), which picks up all mentions, but feedback reports this doesn’t play well with locked accounts.

Future plans

Caelyn continues to expand the bot’s store of upbeat comments and affirmations, so @yayfrens won’t run out of things to say any time soon! I do need to put in a system to make sure she doesn’t repeat herself – not because she’ll get repetitive, but because the Twitter API rejects duplicates, and then I get a script failure email.

I want to fix a couple of issues around locked accounts. In addition to the search problem, when @yayfrens sees that someone is following her and she isn’t following them, she sends another follow request – even if she has one outstanding. This also causes script failure emails, which is great incentive to get that fixed. (Ideally, @yayfrens should nudge them and ask for a follow approval.)

I’d also like to set up a system to watch for infinite bot conversations and shut them down after a reasonable number of exchanges (ten? twenty?) This is a little tricky because the Twitterbot is actually launching fresh each time – my variables don’t actually stay over from run to run, and I can’t save off to a file. (I do have access to Script Properties, but those are simple key-value pairs. I could probably save an array in string format, but processing and unprocessing it would be a little annoying.)

The scary thing about fiddling with @yayfrens now is that any screwup could flood 100+ people with tweets. At one point, I accidentally flooded myself with eight tweets within one second, and I thought for a panicked moment that I’d thrown @yayfrens into an infinite loop.

The Harmonix web team’s internal joke was “F*** it, we’re doing it live!”, because you never want to modify code in a live environment – but that’s the case with @yayfrens as matters stand. What I really need to do is set up a secret bot clone – a dev environment, really – and test any changes I want to make over there before copying them across.

Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *