Using the highly-rated answer from StackOverflow How to send an imessage text with applescript, only in provided service?:
on run {targetBuddyPhone, targetMessage}
tell application "Messages"
set targetService to 1st service whose service type = iMessage
set targetBuddy to buddy targetBuddyPhone of targetService
send targetMessage to targetBuddy
end tell
end run
On Ventura, this errors at save with "Expected class name but found identifier." and highlights the first instance of "service". How should the script be corrected?
Is there a difference in grammar between releases? This code works on Big Sur.