Skip to content

Twitter Bots for Community Building

2015 was not a hugely productive year for me. I’ll get to that in another post.

But one thing that stands out as something I’d been Meaning To Do, and then actually did, was to create my first functional Twitter bot. It turned into a project I’m actually pretty proud of, and it continues to be one that I monitor and maintain.

This won’t be an overly technical post, but I’d love to talk through the thought process and fine-tuning that went into creating @VegAssist, the Vegan Assistant.

Automating a Hobby

Sometime last year it occurred to me that a simple form of vegan advocacy I could do was to search Twitter for people using phrases like “I want to go vegan” or “Help me go vegan”, and offer them a little support, or whatever advice they needed. The idea was just to be friendly and supportive to people who had expressed an interest in learning more about it, or just needed some practical tips they could use right away.

A lot of people use Twitter as a sort of stream of consciousness. If brands can use this data, why not causes and communities, I figured.

I was a little shy about it at first; I don’t want to pop into someone’s mentions unwelcomed. So I was pleased that I was overwhelmingly met with positive responses from the people I was engaging with.

The only thing was, it took time (I was performing the searches manually from Twitter’s web-based search tool), and I was just one person (still am!). When something takes a lot of time, it’s a great opportunity to ask if any part of it can simply be automated! In my wildest dreams, I thought about designing an advanced AI Twitter bot that could take over for me, responding to people and answering common questions. But this was to be my first Twitter bot — my first bot in general — and so I decided to work on the first baby-step toward that dream, with just the skills I already have.

The Happy Spot Between the Human and the Impersonal

After discussing with some friends, I decided that a bot that simply replied to people with a generic link or piece of advice would seem impersonal. When a bot replies to me, I don’t really feel like I’ve been given any actual attention; I don’t feel helped. Plus, a generic response could miss any sensitive context that a human could parse from the Tweet’s intent. Not everyone is expressing the same sentiment when using a phrase like “I want to go vegan.”

So the best thing I could do, I decided (again, with some discussion), would be to retweet (RT) the requests for assistance, and I or one of the bot’s Twitter followers could follow-up with more personal advice.

I used Node, and a Node library called twit, which made API interactions very simple.

I created a Twitter account, and got the API credentials through that account. This would allow my code to interact with the account.

VegAssist code base on GitHub

The code tracks the keyword “vegan” on the Twitter public stream. Any tweet with that word in it will get checked to see if it contains a match on one of the pre-programmed phrases that we’re looking for. In the first version, it performed a simple exact-text match; ie, if a Tweet contained exactly the phrase “I want to go vegan,” it would get retweeted, but if it contained some simple variation, like “I really want to go vegan,” it would NOT match. Once I put the code up to the public on GitHub, and shared it with the Reddit vegan community, I got a lot of enthusiastic responses and offers to contribute! It wasn’t long before a contributor converted all my exact-match phrases into RegEx rules, with a list of common adverbs! What this meant was that now simple phrase variations would also be caught and retweeted:

  • “I totally want to become a vegan”
  • “I think I want to be vegan”
  • “I definitely want to go vegan”

All now match!

As well, posting to the community grew the bot’s follower count. I now had a small contingent of helpful and friendly vegans, eager to offer advice if they happened to see one of the RTs.

Look at that happy fella!
Look at that happy fella!

Administrative Challenges

One thing that’s super important to me about this bot is that it’s a welcome assistance for the people who are retweeted. While I know there’s a common perception of vegans being aggressive in their advocacy, I was really impressed with how people really clicked with the tone of the bot. But I also know that Twitter can be a minefield of harassment and misunderstood intent, so I’ve taken it as my responsibility to do what I reasonably can to ensure that the people being engaged are being so respectfully and with good intent.

Early on, among the hundreds of very friendly and helpful followers, I saw one that was being needlessly aggressive; giving what was, in my opinion, bad advice; and engaging in petty arguments with people when they expressed any disagreement. For many people who are RT’d by my bot, they might never have had a real-world interaction with a vegan; if this was going to be their first encounter with a vegan, I didn’t want it to be a bad one.

I knew it was time to draft up a Project Document, so that I could make it very clear what the project was all about, and what kind of activity would get a user blocked.

I hosted the Project Document on GitHub pages: VegAssist Project Document

I blocked that problem user, and have found that I haven’t really had a need to clarify the rules with anyone else.

User Response

In my worst fears, I thought the bot could fail early, being seen as little more than an annoyance! But thanks in no small part to the previously mentioned followers of the bot, the responses have been very positive! It’s very common that the support tweets get “liked”, a “thank you” response gets sent out, or follow-up questions get asked (and generally answered). People also generally aren’t getting overwhelmed, which was another fear of mine. They say “Help me go vegan”, and usually get at least a few “likes”, and often between one and three responses, offering help, and asking more about what the person’s concerns might be.

The best responses I’ve seen have been those people who are RT’d by the bot, then when they see that notification, they check out the feed, and see all kinds of other people in the same situation as them (wanting to go vegan, but maybe not knowing how). Many people follow the bot, and click “like” through the feed, even offer support messages to other aspiring vegans! It’s very encouraging.

There have absolutely been people who didn’t really want to be engaged when they tweeted out — maybe half-heartedly — that they wanted to go vegan. Whenever a person has made that clear, I manually unretweet them, no questions asked (if I’m not completely clear about whether they’d rather be unRT’d, I ask — usually even if people are a little shocked, they’ve actually said not to worry about it, they don’t mind the RT and tweets of assistance).

One upcoming feature is the ability to get the bot to unRT a person by request, automatically. Again, really the last thing I want is for people to feel harassed or otherwise bothered by the bot and its well-meaning followers (even if it only is two or three people).

A Template for Community Support?

I’m overall very pleased with the bot. I’ve had many contributions to the code in the form of additional languages, and other suggestions.

Since the code is up on GitHub, it occurred to me that other communities, not necessarily related to veganism, could use the code and adjust the phrase-matching for their own outreach and advocacy. I’d love to see the repo cloned and used in such a way! It’s a great way for a small development team to leverage social media for a positive end, and give help to people who are literally asking for it, and might not otherwise get it!

Comments are closed.