A Twitter bot with rtweet, Mapbox and GitHub Actions

Tags: #<Tag:0x00007f557748a7f0> #<Tag:0x00007f557748a6b0> #<Tag:0x00007f557748a5c0> #<Tag:0x00007f557748a4d0> #<Tag:0x00007f557748a3b8>

rOpenSci package or resource used*


What did you do?

I set up a GitHub Action that includes R code that generates random coordinates in greater London, queries the Mapbox API for a satellite image and uses the Twitter API via {rtweet} to post the image to the @londonmapbot Twitter account.

URL or code snippet for your use case*


More images at the @londonmapbot account.



Field(s) of application

geography, geospatial, communications, social studies, sociology

Twitter handle


I can add something here because I did some very similar to Matt’s case study.

I wanted to set something up to do some regular tweeting to promote content for my business, R for the Rest of Us. I use rtweet in a very similar way to Matt. The one piece I do in addition is to query a Google Sheet, from which I draw tweets and then post them. I did this using googlesheets4.

You can see the code I used here and the GH Action here.


See also canberramapbot (source) by Qiū Ruì, which uses londonmapbot’s underlying code. There’s also narrowbotR (source, blog post) by Matt Kerlogue, which builds greatly on the initial idea and incorporates calls to the Flickr API and embedding of geodata into the tweet.