Using Webhooks with fmMMS
fmMMS includes a 'Webhooks' folder containing a series of PHP files for each Gateway for working with both the FileMaker Data API and the FileMaker PHP API. For each Gateway you will find the 2 folders like the following example for the Twilio MMS Gateway:
Inside each of these folders are a number of PHP files that you can use to receive automatic delivery status updates and incoming MMS messages as follows:
- WebhooksDeliveryReceipts.php: this is used to receive automatic delivery status updates from the MMS Gateway as messages are delivered. If you need to track the delivery status of sent messages you can use this to receive updates automatically from the Gateway without having to manually check on the status of individual messages
- WebhooksIncomingMessages.php: this is used to receive incoming MMS messages either sent in reply to an outgoing message from fmMMS or directly to your dedicated mobile number provided by your MMS Gateway
You might also see the following files for some Gateways and for the Data API folders:
- getMediaURL.php: this file is used to make the files you store in the Media table (typically a jpeg or png file etc to send as attachments with your outgoing MMS messages) dynamically available to certain MMS Gateways so they can retrieve the image from your server without you first having to export it and upload it to a server. Some Gateways do require a link to an actual file on the server so this file also, for certain Gateways, downloads the file to the server where it is running to make this available to the Gateway to then download (make sure you set the permissions for the folder containing this file to have read/write access)
- deleteMediaFile.php: this is used in conjunction with the Data API version of the getMediaURL.php file for some Gateways which don't work with the default behaviour of how the FileMaker Data API returns images stored in FileMaker container fields. Some Gateways require a link to an actual file on the server - we use the getMediaURL.php to retrieve the file from the Media table record and download it to the web server it is running on, but that will leave behind the media file. Once you no longer require the media file on your web server you can use the button in the Media record to delete the file on the server if present, which calls the deleteMediaFile.php to delete the file (make sure you set the permissions for the folder containing this file to have read/write access)
You will need to replace the value for the $hostname variable in each of the PHP files with the IP address or DNS name of your FileMaker Server.
To use Webhooks with fmMMS you will need to ensure the following are in place:
- your copy of fmMMS must be hosted by FileMaker Server v16 or later if you are using the PHP API Webhook files
- your copy of fmMMS must be hosted by FileMaker Server v17 or later if you are using the Data API Webhook files
- you will need to deploy and configure Custom Web Publishing with PHP if you are using the PHP API Webhook files
- If you’re using the Data API Webhook files you will need to enable the Data API and host the PHP files (either on your FileMaker Server or elsewhere, for example Amazon Lightsail or your own web server running PHP)
- you will need a static IP address/domain name for the web server that is part of the FileMaker Server deployment (we need to notify the MMS Gateway what the URL to the php file is that will be hosted on your Server)
- you need to install the supplied Webhooks files on your Web Server and determine the URL to each page from the outside. For example if your web server has a domain name of www.myserver.com and you create a folder called fmMMS and place the WebhooksIncomingMessages.php file inside the fmMMS folder the URL will be: https://www.myserver.com/fmMMS/WebhooksIncomingMessages.php
- some Gateways require that the URL needs to begin with HTTPS
If you’re not sure about what the external URL to the WebhooksIncomingMessages.php file is talk to your IT person – they may need to setup port forwarding on your Internet router in some cases.
N.B. In January 2021 Claris announced that Custom Web Publishing with PHP is being deprecated and they are making changes to how PHP is bundled with FileMaker Server. Please see this support article for further details.
The web server “root” folders for the installation location of the PHP files for FileMaker Server v16 and later is:
Windows (HTTP or HTTPS):
[drive]:\Program Files\FileMaker\FileMaker Server\HTTPServer\Conf
where [drive] is the drive on which the Web Publishing Engine component of your FileMaker server deployment resides.
Mac OS X (HTTP):
Mac OS X (HTTPS):
N.B. the HTTPS options require a valid SSL certificate to be installed.
If you are using FileMaker Server v17 or later you cannot using the FileMaker Server Admin Console to enable Custom Web Publishing using the PHP API. You will need to use the Command Line Interface to enable these – see the FileMaker Server 17 Help for more information on these commands.
If you are having issues with Webhooks not being received successfully we recommend using Webhook.site to generate a custom URL to use as your Webhook URL and use Webhook.site to test and inspect the contents of the incoming Webhooks.
N.B. the Webhooks PHP files are not included with the trial version. If you would like to test out incoming MMS messaging with your trial version of fmMMS please contact us and we can setup a temporary host the PHP file and configure it to push incoming messages to your FileMaker Server.