Step 8 – 2 Way Messaging/Replies
The options for 2 way messaging (sending and receiving messages using fmSMS) will depend on the SMS Gateway that you use, the Sender ID that you use and how you host fmSMS:
- Some SMS Gateways allow you to “poll” their server for any replies to messages sent from a shared virtual mobile number or a dedicated virtual mobile number. This requires manual intervention – someone needs to click the Get Incoming Messages button in the Account details screen to initiate this process (some Gateways also allow you to filter by date range and where supported the Date From and Date To fields will be visible). This method is supported when fmSMS is hosted/opened in FileMaker Pro or hosted by FileMaker Server.
- Most SMS Gateways that offer 2 way messaging will have an option to “push” incoming messages to you automatically using Webhooks in a similar way to how automatic Delivery Receipts are delivered. This is also our preferred method, but it does require that fmSMS be hosted by FileMaker Server and that you configure the Customer Web Publishing service or enable the Data API with FileMaker Server v17 or later. A static IP address is also recommended as you have to provide the SMS Gateway with a URL to a php page on your server. For the Data API you will need a domain name with an SSSL certificate installed. We provide the necessary PHP pages that convert the incoming message into a record in the Replies table in fmSMS for both the PHP API and the Data API. Some Gateways charge additional fees to use this feature and if you require a dedicated virtual number you will need to rent/purchase one through your SMS Gateway.
Manually Check for Replies
To manually check for new Replies in fmSMS (where supported by your SMS Gateway) click on the ACCOUNTS button at the top of the screen to view your list of Accounts. Click the arrow button to view the details for the Account you wish to check for new replies, then click the Get Incoming Messages button (if the SMS Gateway associated with this fmSMS Account does not support manually checking for replies you will receive an alert).
fmSMS will then communicate with the SMS Gateway and check for any new replies since it last checked and then download any awaiting replies. If the SMS Gateway supports filtering by a date range the the Date From and Date To fields will be visible which you can use to filter the request for replies received between the 2 dates.
To view incoming Replies click on the REPLIES button at the top of the screen to view all existing Replies (you may need to click the Show All button on the FileMaker toolbar if you have Replies but none are showing):
Click the arrow button to the left of the Reply From field to view the details for an individual Reply:
The following details are available for a Reply:
Reply ID – this is generated automatically by fmSMS and can be ignored
Sender – the name of the Contact (if found) who send the Reply
Sender Mobile – the mobile phone number of the sender of the Reply
Destination – the number for the Reply was sent to (typically a shared virtual number or a dedicated virtual number – not all SMS Gateways provide this)
Timestamp – the timestamp for the Reply
Gateway Message ID: the SMS Gateway ID/reference for this Reply
Gateway Reply Ref: if the SMS Gateways allows you to include a hidden unique identifier in outgoing messages sent from a shared virtual number this will also appear here. This can be used to match an incoming Reply with a previously sent Message
Reply Body: the text of the incoming Reply
To help you match an incoming Reply to a previously sent Message we display the following below the Reply Body field:
Previous Messages By Gateway Message ID: we use the Gateway Message ID to match the Reply to a previous sent Message from fmSMS
Previous Messages by Gateway Numeric ID: some Gateways don’t allow alphanumeric reference numbers to be used as the hidden identifier when sending Messages from shared virtual numbers (we always use the fmSMS Message ID, e.g. MG1106 or the numeric component where required). For these SMS Gateways that only allow numeric identifiers to be used we match on the numeric component of the fmSMS Message ID
Previous Messages to this Sender: all previous Messages sent from fmSMS to the mobile number of the sender of the Reply
Automatically Receiving Replies
As mentioned above many SMS Gateways also offer the option to automatically send Replies directly to your Server using Webhooks. This has the advantage of not having to manually check for new Replies – they will automatically appear in your copy of fmSMS. To set up automatic Replies you will require the following:
- your copy of fmSMS must be hosted by FileMaker Server v16 or later if you are using the PHP API Webhook files
- your copy of fmSMS 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
- you will need a static IP address/domain name for the web server that is part of the FileMaker Server deployment (we need to provide the SMS Gateway with a URL to a php page that will be hosted on your Server)
- 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)
- you need to install the sharedNumberReply.php and/or dedicatedNumberReply.php files (supplied as part of your purchase of fmSMS) on your Web Server and determine the URL to these pages from the outside. For example if your web server has a domain name of www.myserver.com and you create a folder called fmSMS and place the dedicatedNumberReply.php file inside the fmSMS folder the URL will be: http://www.myserver.com/fmSMS/dedicatedNumberReply.php
FileMaker Cloud Compatibility – if you’re using FileMaker Cloud to host fmSMS you will need to use the Data API Webhook files as FileMaker Cloud does not support Custom Web Publishing with PHP.
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 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.
For the Data API Webhooks you will first need to make sure that you have enabled the Data API in the FileMaker Server Admin Console under Connectors:
Once you have determined the URL to the dedicatedNumberReply.php and/or sharedNumberReply.php files you then need to update your account settings with your SMS Gateway to enable the automatic Replies option and provide the URL to these pages so they can sent the Replies for shared/virtual numbers to these pages (these will then be converted into records in the Replies table).
The process for this is different for each SMS Gateway – if you open each PHP file in a text editor you will find instructions at the top of the page for how to update your account with the particular SMS Gateway with the URL to your Webhook PHP file. For example the dedicatedNumberReply.php file for Twilio includes these instructions at the top of the php file:
Here’s how this works on the Twilio website:
- login to your Twilio account via their website
- click on Phone Numbers in the side navigation (or go to https://www.twilio.com/console/phone-numbers/incoming)
- Click on your Twilio Number to edit it, then under Messaging selected Configure with Webhooks/TwiML
- select A Message Comes in “Webhook” and enter the URL in the adjacent field
- set the HTTP method to POST.
- click Save
If your preferred SMS Gateway is not listed here please let us know – we can easily modify the dedicatedNumberReply.php and sharedNumberReply.php files for additional SMS Gateways that support this feature.