A Twitter bot with rtweet, Mapbox and GitHub Actions

rOpenSci package or resource used*

rtweet

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*

Image

More images at the @londonmapbot account.

Sector

Other

Field(s) of application

geography, geospatial, communications, social studies, sociology

Twitter handle

4 Likes

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.

4 Likes

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.

4 Likes