I was watching Travel Man on TVNZ recently with the sardonic Joe Lycett showing the very funny Roisin Conaty around the Austro-German historic border town of Salzburg. Entering the BlaueGans (Blue Goose) boutique hotel (built in 1350), Joe and Roisin are impressed by over 120 original artworks that adorn the hotel, including ‘Shannon’s Hand’ by David Moises, the inspiration for my next FME workflow.
‘Shannon’s Hand’ is an arty take on the Useless Box, a contraption by which the user flips a switch on a box, only for a mechanism to pop out of the box to turn the switch off. Other than the pure joy of the idea of a machine turning itself off, the useless box is as its name suggests, useless. It’s the kind of thing that I like. But what has this got to do with FME? Well, nothing other than I thought it would be quite good fun to create an FME based equivalent of the useless box.
In my last post I described how a webhook could be used to trigger an event. Working on this concept I decided to create a workflow that would be triggered by the creation of a feature in an ArcGIS Online feature service.
This process would also give me the opportunity to learn a bit more about FME Flow (formally FME Server), which I haven’t used before.
To start with, I needed to create the map layer in ArcGIS Online and the associated webhook. This wasn’t particularly difficult; the layer took only a few seconds. Configuring the webhook was a little more complicated because the webhook needs to know what action it is triggering. For that to happen I would have to jump into the world of FME Flow. FME Flow is an application that can be used to automate the running of FME Form workflows. A workflow is either run based on a specified schedule or by a trigger. In this case the trigger was going to be the webhook.
It was straight forward to create the Webhook trigger in FME Flow and soon I was copying the unique ID that FME generates into the Webhook code that ArcGIS Online requires. Once configured every time a feature was created in ArcGIS Online it would trigger the webhook, which in turn would trigger FME Flow, which in turn would run a workflow.
So now all I needed was a workflow to run. I jumped into FME Form (formally FME Desktop) to create the activity that I wanted to run. Keeping the useless nature of my plan in mind I decided that the most obvious thing to do would be to delete the feature that had just been created. Someone creates a feature and then a few seconds later that feature is deleted, perfectly useless!
Creating the Workflow in FME Form was pretty easy, it only takes two transformers, one to read the data in from ArcGIS Online, and one to delete the features. Once working it was necessary to publish the Workflow to FME Flow which is as simple as clicking on the publish button and following a few configuration screens where clicking next, next, next was all it took.
Back in FME Flow I now needed to link the published workflow to the webhook, which fortunately Safe Software makes very easy via a drag and drop interface. It now meant I had a webhook in ArcGIS Online which would be triggered when someone created a new feature. This would then trigger FME Flow to run a workflow that would delete the feature. I was all good-to-go so started testing.
After what appeared to be initial success, I began to see errors in the FME Flow logs. What was going on? The Webhook was triggering FME Flow, but the delete was failing. I consulted my colleague Pip who after a moment’s thought asked if I had created Application Credential in ArcGIS Online? Of course, I hadn’t, I wasn’t sure what they were! Pip explained that if I wanted FME to be able to edit I would need to give it permissions to do so. I would need an App ID and a App Secret which are used like a handshake between ArcGIS Online and FME. Fortunately creating Application Credentials wasn’t too complex, and within 5 minutes I was able to start testing again and this time it all worked as it should.
I would create a feature in ArcGIS Online, and a short time later FME would delete it, it was wonderfully useless, and I couldn’t help but smile at the results. Had Joe and Roisin been watching I am sure that they would have approved.
As useless as this workflow is, it’s not too difficult to see how with a few changes it might be useful. Imagine that instead of deleting a feature, FME ran a much more complicated workflow. In my previous blog – Beyond the Roadblocks – I spoke about automatically generating a letter of notice to businesses impacted by a road closure, well this could now be triggered when a new road closure was denoted on a map.
Webhooks are not just limited to ArcGIS Online, many SaaS applications support them, from Xero to Slack, or Twilio to Shopify, webhooks have become one of the main methods of communicating the occurrence of an event from one system to another and FME takes it to another level.