Microservices and FileMaker: an Update to Billy Bass

For my 2018 Developer Conference IoT session, I used Billy Bass to demonstrate how to drive motors from inside FileMaker remotely across the internet.

I’ve outlined the intended setup in figure 1. The FileMaker user types the text of what they want Billy Bass to say, Amazon AWS Polly synthesizes the text to speech, and somehow, Billy Bass speaks it.

Workflow showing of setup of when the FileMaker uses types the text for the speech
Figure 1. Workflow

FileMaker Server itself is also on AWS, on a Windows EC2 instance in our setup but does not need to be; your FileMaker Server can be anywhere. The fish is controlled through a Raspberry Pi and can be anywhere as long as it is reachable from the internet.

Putting it together for DevCon was quite the adventure that you can revisit in this four-part blog series.

How it Works

The magic, of course, is in how Billy Bass receives its instructions and does as it is told. For the DevCon presentation, I had settled on using a Python script running on the Raspberry Pi. The downside of that approach is that the Python script needs to be in a continuous loop to query FileMaker Server through the Data API, looking for flagged records, as outlined in figure 2 below.

Python script running no the Raspberry Pi for Billy Bass to receive its instructions.
Figure 2. Python script

It would be a lot more efficient if we could do away with the constant polling that originates from Billy Bass. So, for this redux, I decided to adopt a microservice approach in which the fish would be dormant until it receives an instruction.

Microservices and FileMaker

A microservice is nothing but a tiny web service, meaning that all you need is an URL to talk to it and send it instructions to execute something. There are many technology options available to construct this web service. You can use stacks such as PHP, ASP.NET, Ruby, Python, and, of course, JavaScript. JS would be our preferred choice these days, probably a Node.js Express implementation.

These are the same choices you would consider, for instance, when you need to set up a webhook integration where some system needs to send data to your FileMaker solution and you have no control over the JSON structure of that data. In my Engage 2020 session on webhooks, I talk about those choices at the 22:50 mark.

Setting up a Node.js Microservice

Like most things, setting up a Node.js micro-service is easy enough if you have done it a few times, but it can be a bit daunting if you are new to it. Fortunately, there is an option that uses Node.js in a very user-friendly fashion: node-red.

With node-red, you can create micro-services entirely in your browser by simply linking steps together into a flow. If you are familiar with Claris Connect, the basic concept is somewhat similar. In that Webhook video, I get into node-red at the 28-minute mark. You can also review other very good resources in our community:

Back to our setup. On the hardware side, we have the Raspberry Pi with the Squawker Talker, connected to the motors and speaker of Billy Bass.

Photo of Billy Bass connected to the Raspberry Pi and Squawker Talker
Photo from side showing the squawker talker connected to Billy Bass
Figure 3. Raspberry Pi and Squawker Talker connected to Billy Bass

Flow Setup

And with node-red installed on the Raspberry Pi, the basic flow that does what we need it to do looks like this:

Workflow showing the work of what needs to be done
Figure 4. Basic flow of what is needed to be done

Reading this from left to right: the web service listens to the /fms endpoint for any GET requests, and it expects to be passed a FileMaker record id as a query parameter in the URL (which is what :id indicates).

With that record id, node-red will request the specified record from FileMaker Server through the Data API (the green Get Record node), retrieve the mp3 sound file from the container field (the green Extract Containers node), and play it. It will then respond to the caller with an “everything ok” http response code 200.

Inside FileMaker

From inside FileMaker, the user types in the text they want Billy to speak.

Figure 5. FileMaker field to type in the text for speech

FileMaker makes an API call to AWS Polly to convert the text to speech and then makes another API call to node-red to initiate the playback.

The script that interacts with the node-red microservice is extremely simple:

Screenshot of the script that interacts with the node-red microservice.
Figure 6. Script that interacts with the node-red microservice

Calling any API from FileMaker is done through the Insert from URL script step on line 32. Lines 31 and 29 construct both the required URL (in the $endpoint variable) and the cURL options (in the $options variable).

Next Steps

Setting the hardware fiddling aside, I think you will agree that the software engineering to make this work is not complicated. Node-red allows you to very easily set up these kinds of micro-services that FileMaker can talk to, AND can interact with FileMaker themselves through the Data API. Node-red is an easy path into the world of microservices. Since it is based on Node.js, it offers a path up to actual Node.js coding if required or desired.

As always, feel free to ask any questions in a comment below and on community.claris.com.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top