Building a LocalWiki Changebot

One thing that became obvious soon after becoming part of the Code for America family was the abundance of community-focused wikis – sites where anyone can contribute, intended to facilitate community around shared knowledge. Some cities have very successful and robust wikis (I’m looking at you, OaklandWiki), but others have some work to do to catch up.

During National Day of Civic Hacking last year in Lexington, OpenLexington (the local Code for America brigade) launched LexingtonWiki, which is built on LocalWiki. Unfortunately, it hasn’t yet gotten much traction, which is a huge bummer! The Lexingteam thought it might be cool to have Twitter notifications when a page on the wiki is edited/updated to try and publicize the wiki and get more folks editing. Turns out it’s a pretty easy thing to set up.

This is how we did it:

  • Every LocalWiki instance has a Recent Changes RSS feed, and there’s a pretty cool but casually hidden/relatively unknown feed for those changes. It lives at https://[your wiki's URL]/Recent_Changes/_feed.
  • Discovering that feed was like, 90% of the challenge. From there, we set up a recipe in IFTTT to automatically tweet when that feed was updated.

IFTTT stands for IF This Then That. It’s a service that allows you to combine internet services – in this case, a connecting a feed update to Twitter. People use IFTTT for all kinds of stuff: getting a text message every day with the day’s forecast, backing up their contacts to a Google Spreadsheet, or saving their Instagram photos to Dropbox.

  • Setting up a recipe in IFTTT is pretty easy. After you get an account and log in, click Create a Recipe.
  • Click the link where it says “this” and select Feed from the list of triggers.
  • Since every item added to the feed is a new change, you can select New feed item as your trigger.
  • Copy and paste the URL for the feed into the box provided and click Create Trigger.
  • Click where it says “that” and choose Twitter as your action channel. You will probably have to set up IFTTT such that it can interact with your Twitter account, if you haven’t already.
  • Under Choose an Action, click Post a tweet.
  • Now you can compose your tweet. The EntryTitle and EntryUrl fields will be automatically populated from the feed. The rest of the tweet is all yours to compose! When you’re done, click Create Action.
  • Look over everything to make sure you like it, and then click Create Recipe.

Boom!

You have a LocalWikiBot. Recipes on IFTTT are triggered automatically every 15 minutes, so if you have a lot of edits, expect a flood of tweets on that mark. You can also set up your bot to have an action outside of Twitter: check out the full list of possible channels here.