Xojo Conferences

« Login in FileMaker we… | Home | MBS FileMaker Plugin,… »

Send text message from FileMaker via iMessage

A client recently asked how to send text messages (SMS) via iMessage. Instead of using a web service of some provider, he only has to occasionally send a few messages automated over his iPhone. So we got the following AppleScript for him:


property targetPhone : ""

property targetMessage : ""


on run

tell application "Messages"

set targetService to 1st service whose service type = iMessage

set targetBuddy to buddy targetPhone of targetService

send targetMessage to targetBuddy

end tell

end run


This script has two properties for the phone number (or email) and the message to send. The script asks Messages app on MacOS for the first service for iMessage and for the buddy with the given phone number. Than it sends a message to the buddy.

We use properties for such scripts, because we can compile the AppleScript once and pass data to the script by setting the properties. No escaping needed, no change in the script with place holders, but directly write values in the properties and run the script again.


In FileMaker we got the following script to compile the AppleScript, set properties and run it. As you see we store reference to compiled script in $$scriptID and only compile once.


If [ $$scriptID = "" ] 

Set Variable [ $$scriptID ; Value: MBS( "Applescript.Compile"; AppleScript Properties::AppleScriptCode ) ] 

If [ MBS("isError") ] 

Show Custom Dialog [ MBS("AppleScript.LastErrorMessage") ] 

Exit Script [ Text Result:    ] 

End If

End If

Set Variable [ $r ; Value: MBS( "Applescript.SetPropertyValue"; $$scriptID; "targetPhone"; AppleScript Properties::targetPhone) ] 

Set Variable [ $r ; Value: MBS( "Applescript.SetPropertyValue"; $$scriptID; "targetMessage"; AppleScript Properties::targetMessage) ] 

Set Variable [ $r ; Value: MBS( "Applescript.Execute"; $$scriptID) ] 


Please do not hesitate to contact us if you have any questions.

10 03 19 - 12:47
two comments

I assume the AppleScript resides in a text field? (in your example a text field called ‘AppleScriptCode’)
I have been playing with this and I get a value returned for $$ScriptID from the first ‘IF’ statement – I assume all the set variables calls are all executed correctly – but nothing seems to happen? Is there a way of tracking to see if the AppleScript is executing on the local machine?
Cheers Tom
Tom Beattie - 29 03 19 - 01:33

AppleScriptCode is a field here with the apple script code resides.
Can you step through and see if you get errors back?
Also for MacOS Mojave, FileMaker must be allowed to use AppleScript in system preferences, privacy section.
Christian Schmitz (URL) - 29 03 19 - 06:53

Remember personal info?

Emoticons / Textile

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.