Extending the WordPress API with Webhook routes for FileMaker
The WordPress platform offers a method for extending the WordPress API with custom API routes, which I’ll use to create a webhook route posting form data to FileMaker (or anything else for that matter).
What this is
The plugin, named “Rad Webhook Demo,” serves as an example and starting point for developers. Here’s a breakdown of its key features:
- Saving Configuration: The plugin allows users to save their FileMaker username, password, and base URL in the WordPress settings for easy access and reusability.
- Custom
wp-json
Endpoints: The plugin adds a new endpoint to the WordPress Rest API, enabling integration with form builders capable of sending data to webhooks. For instance, popular form builders like Kadence Forms can easily post data to these endpoints. - Data Transformation: The custom endpoints handle the form data received, allowing developers to perform any necessary transformations or modifications before forwarding it to FileMaker via the OData API.
What this is not
- Form Builder: The plugin does not include a form builder itself. It focuses solely on creating the necessary
wp-json
endpoints for the webhook. - OData Wrapper: While the plugin utilizes the FileMaker OData API, it doesn’t provide a comprehensive wrapper for the entire OData functionality. Developers still need to create their own
wp-json
endpoints for each form they want to submit.
Getting Started
To use the demo file and plug-in:
- Download the sample file and the plugin file or copy the code from the GitHub gist.
- Host the sample file on your FileMaker Server.
- Upload the plugin to WordPress and activate it.
- Enter the API details in the plugin settings page: Settings > Rad Webhook Demo. Use the account name and password of a FileMaker account with API access. The base URL should look something like this:
https://example.com/fmi/odata/v4/RAD_Webhook_Demo
. - Create a form using a form builder such as Kadence Forms, Gravity Forms, Contact Form 7, etc. Many popular form builders have a webhook feature.
- Configure the form with the webhook details. For example, the custom route that I created is
https://example.com/wp-json/rad-webhook-demo/submit
. I mapped the form fields to web hook fields (see below)
Demo file details:
Admin account name | Admin |
Account password | webhooks! |
API account name | api.access |
API password | khs!09kdsjfh |
How the process works
- A user submits data in a web form
- The form builder submits the data to the webhook route
- The webhook route (a custom WordPress API route) will process the data and send it along to the FileMaker database using the OData API (or the DataAPI if you prefer).
This allows us to send data to FileMaker without exposing the account details for the OData API. The plugin stores these credentials in the WP database and only uses them on the server to send requests to FileMaker.
Create your own plugin
You can use the provided plugin as a starting point. ChatGPT can help you rename the plugin and it’s helpful for getting started on your own API routes.
Demo
Test out the process by sending me a message. This will send the form to my database. Feel free to ask questions or just say hello.