
This service offers the sending of SMS messages to German networks from 1.6 cents per message; SMS messages can be sent worldwide at prices from 4.9 cents per message, plus 19% VAT in each case. After registration, 30 free SMS messages are available to start with, which can be sent for test purposes. There is no monthly basic fee with this provider. In the following you will learn how you can send SMS messages automatically directly from your FileMaker database.
Registration with smstrade
To be able to send SMS messages via the SMS gateway, you must first register with smstrade. Registration is free and includes the sending of up to 30 free SMS messages to start with.
Master data for the SMS gateway
First of all, three fields are required in your FileMaker database to contain the access and master data for the SMS gateway. These fields apply globally for use in your entire FileMaker solution. Alternatively, you can also use global variables instead of fields, which are created in a Script must be initialized. The following fields are required for the master data in order to send SMS messages:
- Sender - Sender identification of the SMS, e.g. '0049123456789' or '+49123456789'
- Gateway Key - Gateway key, which you will receive after registering at smstrade.de.
- Route - smstrade offers three tariff options:
- basic for sending SMS messages within Germany
- gold for worldwide shipping with any sender ID
- direct for worldwide shipping directly via the network operator
Create three fields or global variables in your database that you can access throughout your solution. After registering with smstrade, enter the master data in the corresponding fields. For sending SMS messages within Germany, we recommend the 'basic' tariff option.
The script for sending SMS
In the next step, we will program a script with which you can send any SMS messages to any recipient from the entire database. The script can later be called up with the following five script parameters:
- Receiver - Telephone number of the recipient, e.g. '0049123456789' or '+49123456789'
- Text - Text of the SMS message (up to 1,530 characters as a linked SMS)
- Sender - Sender ID, is usually generated from the master data field.
- Gateway Key - Gateway key, is usually generated from the master data field.
- Route - Route (tariff), is usually generated from the master data field.
If you create fields 'Sender', 'Gateway Key' and 'Route' from master data fields, the script should first check whether these fields have been maintained. For this reason, our script contains a corresponding query at the beginning. Below you will find the entire script for sending SMS messages with the support of the MBS FileMaker plugin.
Pass script parameters
When this script is called, five script parameters are passed in a string whose values are separated by an apostrophe (|). To separate the string, we use a Own function called "StringTrennen". To be able to use the script as shown, first create the following Custom Function (separate function) in FileMaker Pro Advanced:
StringDisconnect (String; Number)
If(number = 1;
CharacterLinks ( String; (Position ( String; "|"; 1; 1))-1);
CharacterCenter ( String;
(Position ( String; "|"; 1; Number-1))+1;
(Position ( String; "|"; 1; Number)) - ((Position ( String; "|"; 1; Number-1))+1)
)
)
Script for sending SMS
If you have inserted the custom function mentioned above or have another custom function that can extract strings separated by one character, create a new script in the script editor and name it as a subscript according to your personal naming scheme (e.g. 'ts.SMS_Versand').
If [NOT IstLeer(Sender) AND NOT IstLeer(Key) AND NOT IstLeer(Route)]
#Script parameters: Tel | Text | From | Key | Route
Set variable [$tel_nr; Value:StringTrennen(Get(ScriptParameter); 1)]
Set variable [$text; Value:StringDisconnect(Get(ScriptParameter); 2)]
Set variable [$from; Value:StringDisconnect(Get(ScriptParameter); 3)]
Set variable [$key; Value:StringDisconnect(Get(ScriptParameter); 4)]
Set variable [$route; value:StringTrenn(Get(ScriptParameter); 5)]
#
# Initialize transfer
Set variable [$r; Value:MBS("Trace")]
Set variable [$to; value:MBS("String.EncodeURLComponent"; $tel_nr; "utf8")]
Set variable [$from; value:MBS("String.EncodeURLComponent"; $from; "utf8")]
Set variable [$body; Value:Exchange(MBS("String.EncodeURLComponent"; $text; "utf8"); ""; "+")]
Set variable [$curl; Value:MBS("CURL.New")]
Set variable [$result; value:MBS("CURL.SetOptionpost"; $curl; 1)]
Set variable [$result; Value:MBS("CURL.SetOptionVerbose"; $curl; 1)]
Set variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; "https://gateway.smstrade.de")]
#
# Set input XML and SMS details
Set variable [$content; value: "key=" & $key & "&" & "to=" & $to & "&" & "message=" & $body & "&" &
"route=" & $route & "&" & "from=" & $from & "&" & "charset=utf-8"]
Set variable [$content; Value:MBS( "String.ReplaceNewline"; $content; 2 )]
Set variable [$result; Value:MBS("CURL.SetOptionPostFields"; $curl; $content)]
#
# Start transfer
Set variable [$result; Value:MBS("CURL.Perform"; $curl)]
#
# Check result
Set variable [$$debugText; Value:MBS("String.ReplaceNewline"; MBS("CURL.GetDebugAsText"; $curl);1)]
Set variable [$$resultText; Value:MBS("String.ReplaceNewline"; MBS("CURL.GetResultAsText"; $curl);1)]
Set variable [$r; value:MBS("CURL.Cleanup"; $curl)]
Otherwise
Display your own dialog box ["SMS gateway not set up"; "No master data entered!"; "OK"]
End (if)
In the first part of the script, the passed script parameter string is first extracted into individual variables. In the second part, the CURL engine of the MBS FileMaker Plugin is initialized. The third part composes the string that leads to the Server of the SMS gateway is sent. Sending takes place in the "Start transfer" subscript. In the last part, the sending status is written to the global variables $$result and $$debug and can be read out here after sending.
Download demo database
So that you don't have to type out the entire source code in C=64 style, we provide you with the solution described in this article as a Example file available for download. The sample file is in the fmp12 format and uses FileMaker 12, 13 or 14 with installed MBS FileMaker Plugin in advance. If you do not have a license for FileMaker Pro Advanced, but only for the normal FileMaker Pro, you can use this sample file, which already contains the required custom function for separating the transfer string.

Markus Schall has been developing individual databases, interfaces and business applications based on Claris FileMaker since 1994. He is a Claris partner, FMM Award winner 2011 and developer of the ERP software gFM-Business. He is also a book author and founder of the M. Schall Publishers.


Sounds wonderful. Is there also a way to RECEIVE SMS via FileMaker?
Thank you very much,
Matthias
There is a solution "fmsms" at https://www.fmsms.comwhich can also be used to receive SMS messages.