How I built a Twitter bot using FME Cloud

How I built a Twitter-bot with FME

Challenge: build a system that tweets a random satellite photo every day.

Solution: FME!

The idea came to me during a bike ride: wouldn’t it be cool to leverage the power of FME Cloud and some other services to build a Twitter-bot that tweets out a random satellite photo once a day. So I set out building such a system. I started off by registering a Twitter account of course and managed to find a suitable name: @DailySatPic


In broad terms, the steps would be

  1. Determine a random location, on land.
  2. Retrieve a satellite photo centered on that location
  3. Upload it to Twitter

Step 1: a random location

This is straightforward enough using FME’s RandomNumberGenerator to generate two random numbers which will be our lat/lon. I use the Natural Earth 10m land shapefile as a Clipper feature to determine whether the point is actually on land, if not it loops through the randomizer again. Because of the looping that bit of the process has to be in a Custom Transformer.

Step 2: the imagery

For this I’m using the cloudless Sentinel-2 WMS service that’s kindly offered by EOX. I’ve contemplated using a non-cloudless service, but there would be a chance of an all-cloud image.


Step 3: uploading it to Twitter

This is where I hit an unexpected snag, while FME does have a number of Twitter transformers they’re not working in the current version due to a new Twitter API being rolled out. But I found a way around it by uploading the image to a folder on Dropbox which is being monitored by IFTTT. IFTTT is a service that lets you connect different online platforms. Once it sees a new image appearing in that Dropbox folder it picks it up and tweets it, so for all intents and purposes this has the same effect. I decided to add a bit to my process though: clean up the Dropbox folder at the start of the run, to prevent it from filling up.


I can imagine people wanting to see what images have been tweeted already and where they are on Earth, so I’ve expanded the workspace, it now also uploades the image to an Amazon S3 bucket and a point geometry of the center of the image is then uploaded to CARTO where I’ve set up an interactive map linking back to the image, so when the viewer clicks the map icon a popup is shown with the image.


Up in the cloud

I then set up an FME Cloud instance to run this workspace on a schedule. There was a bit of a struggle here because this FME Cloud instance needs to be able to access all of the external services (Dropbox, S3 and Carto) as well so I did have to go through the authentication process again but once that was sorted out it was up and running smoothly.

This entry was posted in Geen categorie. Bookmark the permalink.

Comments are closed.