Part 3: Sending SMS from FileMaker with AppleScript


A reader, Pierre Boucher, asked if I had tried using AppleScript to send SMS. I hadn’t but a quick web search revealed a fairly straightforward approach, so of course I had to see if I could make it work.

Download Demo File

My two web sources were:

http://www.cubemg.com/how-to-send-a-text-message-with-applescript/

tell application "Messages"

set iMessageid to get id of first service

set theNumber to buddy "+1yournumber" of service id myid

--enter the number that you want to send your message to here

send "CubeMG just made my life 10x easier!" to theNumber

end tell

This didn’t work right away, because there was a small bug in the script, it should have read:

tell application "Messages" 
set iMessageid to get id of first service 
set theNumber to buddy "+1yournumber" of service id iMessageid 
--enter the number that you want to send your message to here 
send "CubeMG just made my life 10x easier!" to theNumber 
end tell 

I saw more discussion with regards to the issue of naming the ’service’,

Equipped with someone else’s hard work of figuring this out, I was able to translate this into FileMaker with the script:

And the juicy bit was the Set Variable $TheAppleScript.

So now, I have four blog posts about sending SMS from FileMaker.

Basic SMS – Dirt simple approach: use the sms: tag on a phone number. The limitation seems to be that you still have to flip over to iMessage and click ‘Send’/ This might work with Windows as well, though not tested.

Shortcuts approach – More complicated approach that will work on both Mac and iOS devices. It is more finicky because you have to set up the Shortcut as well. More moving parts.

AppleScript approach – Mac only, includes Send.

All three of these approaches are included in the current demo file, but if you want more detail on any of them, just click through the the appropriate blog entry.

There are other ways of doing this, including the use of Twillo. DB Services have documented that approach. Employing a third-party service and an API brings the benefit of two-way communications. It also usually has some cost associated per message sent.

See also

Part 1: Sending SMS Messages from FileMaker

Part 2: Sending SMS Messages from FileMaker using Apple Shortcuts

Dialing for Dollars – Getting FileMaker to Call or Text to an iPhone, Skype, Facetime or Zoom

Bonus AppleScript Debugging Tip

When troubleshooting this AppleScript from FileMaker, I used the Calculate AppleScript option.

I built up the AppleScript in a FileMaker Variable and of course it didn’t work properly the first time I ran it. To troubleshoot, I brought the calculated AppleScript to the surface by requesting a dialog box using the Show Custom Dialog step. It seems to me that I used to be able to copy and paste text from these dialog boxes, but that no longer works, so instead, I chose to paste a screenshot into Preview app and copy the text from there.

Show Custom Dialog step
Debugging the AppleScript – turn on the Show Custom Dialog step.
Screenshot the dialog box (Command Shift – 4 and select the area) and switch to Preview and then select New from Clipboard (Command-N)
In Preview, select the text, this is a recent feature in Macintosh OS, that allows you to select and copy text from any image.

Click the Hammer icon to build the script to see if it will run correctly.

5 Responses to “Part 3: Sending SMS from FileMaker with AppleScript”

  1. Antonio Esposito October 31, 2022 at 11:48 am

    Hi, wonderful job, with compliments. I think the best Internet Message System in the world is Whatsapp. Is there a system or Api method to interface with it too?
    Best Regards

Trackbacks/Pingbacks

  1. | Part 1: Sending SMS Messages from FileMakerHomeBase Software - October 29, 2022

    […] Part 3: Sending SMS from FileMaker with AppleScript […]

  2. | Part 2: Sending SMS Messages from FileMaker using Apple ShortcutsHomeBase Software - October 29, 2022

    […] Part 3: Sending SMS from FileMaker with AppleScript […]

%d bloggers like this: