In this explainer I walk you through the steps I took to create a twitter bot
that tweets daily about people who died on that date.
I created a script that queries wikidata, takes that information and creates
a sentence. That sentence is then tweeted.
For example:
A tweet I literally just send out from the docker container
I hope you are has excited as I am about this project. Here it comes!
There are 3 parts:
Talk to wikidata and retrieve information about 10 people that died today
Grab one of the deaths and create a sentence
Post that sentence to twitter in the account wikidatabot
Throw it all into a docker container so it can run on the computer of someone else (AKA: THA CLOUD)
You might wonder, why people who died? To which I answer, emphatically but not
really helpfully: ‘valar morghulis’.
1. Talk to wikidata and retrieve information
I think wikidata is one of the coolest knowledge bases in the world, it contains
facts about people, other animals, places, and the world. It powers many boxes
you see in Wikipedia pages. For instance this random page about Charles the first has a box on the
right that says something about his ancestors, successors and coronation.
The same information can be displayed in Dutch.
This is very cool and saves Wikipedia a lot of work. However, we can also use it!
You can create your own query about the world in the query editor. But it is quite hard to figure out how to do that. These queries need to made in
a specific way. I just used an example from wikidata: ‘who’s birthday is it today?’
and modified it to search for people’s death (that’s how I learn, modify
something and see if I broke it). It looks a lot like SQL, but is slightly different.
Of course this editor is nice for us humans, but we want the computer to do it
so we can send a query to wikidata. I was extremely lazy and used the
WikidataQueryServiceR created by wiki-guru Mikhail Popov [@bearlogo](https://twitter.com/bearloga).
This is the query I ended up using (It looks very much like the birthdays one
but with added information):
querystring