fmSMS Integration - Embedding

Twilio) then you can just import the scripts for your SMS Gateway. There are scripts for each SMS Gateway in the following script folders (not all Gateways support all fmSMS features so you may not find a script for your selected SMS Gateway in each of these);

Send Message Gateway Subscripts<br>Get Incoming Messages Gateway Subscripts<br>Check Account Balance Gateway Subscripts

If you find a script in these folders for your selected SMS Gateway then you could just import these. For example if you are only going to be working with Twilio you would import the following scripts:

Get Replies - Twilio<br>Get Replies - Twilio API for WhatsApp<br>Send SMS - Twilio<br>Send SMS - Twilio API for WhatsApp<br>Get Message Status - Twilio

If you do import just the scripts for your selected Gateway you will then need to update the following scripts which branch for each supported Gateway:

Check Account Balance<br>Send SMS from Selected Gateway<br>Query Status of Current Message

You can generally not import scripts in the following folders as they are used in the fmSMS demo file and usually not required for your solution file:

Utility Scripts

System

Do import these:

System View Selected Related Record

System Create New Blank Record

Developer

Do import these:

Set Default Country

Toggle Debug Mode

Step 8: Value Lists

You will need to recreate the Value Lists from the fmSMS file in your solution file. You can use FileMaker Pro Advanced to copy and paste these from the fmSMS file:

Step 9: Layout Contents – Copy and Paste Layout Objects/Content

Now that we have the necessary value lists and scripts in your solution file you can now copy/paste the Layout objects/content from the layouts in the fmSMS file. You will first need to size the layouts and layout parts to the correct sizes, or you can customise these to suit your requirements. We are assuming that you will be changing the layouts to match your existing theme and styles, but whilst you are testing the integration you can copy/paste these “as is” and once everything is working you can then come back and restyle the layouts to suit your requirements.

Step 10: Layout Script Triggers

Some of the fmSMS layouts have Script Triggers attached to them. You will need to manually reset these Script Triggers for the following layouts (all of these layouts are for use with FileMaker Go on the iPhone and iPad – if you did not recreate these layouts as your solution won’t be accessed by FileMaker Go users you can skip this step):

Contacts List - iPad

Contacts List - iPhone

Messages List - iPad

Messages List - iPhone

Step 11: Security/Privilege Set Changes

This is an optional step and depends on your particular requirements, but you may wish to make any necessary changes to your existing Privilege Sets to allow certain users access to the fmSMS functionality etc.

If you will be working with an SMS Gateway that sends incoming messages/delivery receipts to your FileMaker Server using the FileMaker PHP API or Data API then you will also need to create the required Accounts/Privilege Sets as follows:

Web Privilege Set:

Web Account:

fmphp Extended Privileges:

fmrest Extended Privileges (requires FileMaker Server 17 or later):

If you will be using FileMaker Server to perform server side scripts (e.g. sending bulk messages) you will also need to create the required Accounts/Privilege Sets as follows:

Server Side Script Account:

If you don’t wish to assign this the Full Access Privilege Set you can create your own Privilege Set here with the appropriate permissions and assign that to this Account.

Step 12: Custom Menus

This is an optional step and depends on your particular requirements, but you may wish to recreate the Custom Menus used in the fmSMS file or modify them to suit your requirements. Using FileMaker Pro 17 Advanced or later you can copy and paste custom menus from one FileMaker solution to another.

Step 13: OnFirstWindowOpen Script Trigger

The fmSMS file has a OnFirstWindowOpen Script Trigger set via the File Menu>File Options:

The OnFirstWindowOpen Script script performs a number of functions that are specific to the fmSMS file, but you may need to replicate some of this functionality in your existing OnFirstWindowOpen Script Trigger in your solution file (or set a OnFirstWindowOpen Script Trigger if you do not currently have one set). The most likely features you will need to recreate in your OnFirstWindowOpen Script Trigger include:

Branch by FileMaker client: this is handled at the start of the OnFirstWindowOpen Script Trigger by checking the type of FileMaker Pro client:

Step 14: Import Records

You will need to import all the records from the fmSMS file from the following tables into your solution files tables:

Gateways

GatewayCodes

Templates

When importing make sure you do NOT select the “Perform auto-enter options while importing” in the Import Options dialog. Make sure you reset the zz_Serial# field in each of these to the next serial number.

You will also need to manually create a single record in the Interface table if you imported that table.

Step 15: Create buttons on your Contacts layouts to Send Single/Bulk SMS

You will need to create some buttons in your existing Contacts layouts to send a Single and Bulk SMS. You can copy/paste these buttons from the Contacts Form layout in the fmSMS file:

Create Bulk SMS

New SMS

Step 16: Update PHP API Files

If you will be working with an SMS Gateway that sends incoming messages/delivery receipts to your FileMaker Server using the FileMaker PHP API then you will also need to update the PHP files to reference your solution file and Web Account Name/Password that you created earlier. You need to update the following lines in the PHP files for the SMS Gateway you will be working with:

$hostname = '127.0.0.1';<br>$database = 'yourSolutionName';<br>$username = 'yourWebAccountName';<br>$password = 'yourWebAccountPassword';

Step 17: Update Data API PHP Files

If you will be working with an SMS Gateway that sends incoming messages/delivery receipts to your FileMaker Server using the Data API then you will also need to update the Data API PHP files to reference your solution file and Web Account Name/Password that you created earlier. You need to update the following lines in the PHP files for the SMS Gateway you will be working with:

$hostname = 'your FileMaker Server DNS Name';<br>$database = 'fmSMS';<br>$username = 'Web';<br>$password = 'Web';<br>$layout = 'WebReplies';

Step 18: Update Merge Fields Script

The script Update All Contacts Merge Fields is used to generate a list of merge fields that you can insert into Templates. You will need to update this script so that it works with your existing Contacts table. You only need to update the Set Variable $contactsMergeFields step at the top of this script. It uses the ExecuteSQL function to get a list of fields from your Contacts table:

ExecuteSQL ( "SELECT FieldName FROM FileMaker_Fields WHERE TableName='Contacts' ORDER BY FieldName" ; "" ; "" )

You just need to replace ‘Contacts’ with the table occurrence name for your Contacts table. For example if your Contacts table name is Customers and you have a table occurrence on your relationship graph called Customers you would change this to:

ExecuteSQL ( "SELECT FieldName FROM FileMaker_Fields WHERE TableName='Customers' ORDER BY FieldName" ; "" ; "" )

Step 19: Testing/Check for Errors

You are now ready to start testing by sending a test message to yourself. You will need to follow the instructions in our Getting Started guide to create the necessary Contact, Sender and Account records first before attempting to send a message. We also recommend that you use a tool like BaseElements to check for any errors that were introduced as part of the integration first (typically you will find some calculations that are still commented out due to missing relationships/table occurrences).

Still need help? Contact Us Contact Us