Skip to content

Instantly share code, notes, and snippets.

@stringsn88keys
Created September 16, 2022 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stringsn88keys/70fb7e0cf73a987f3d41e060820c9c97 to your computer and use it in GitHub Desktop.
Save stringsn88keys/70fb7e0cf73a987f3d41e060820c9c97 to your computer and use it in GitHub Desktop.
Send an iMessage from the command line (one arg at a time)
#!/usr/bin/env osascript
# https://chrispennington.blog/blog/send-imessage-with-applescript/
on run parameters
# the number here is the number of seconds
set theDelay to 3
# Verify if this can use display names
set phoneNumber to "+1 (555) 555-1212"
tell application "Messages"
set targetBuddy to phoneNumber
set targetService to id of 1st account whose service type = iMessage
repeat with a from 1 to length of parameters
set textMessage to ( item a of parameters )
set theBuddy to participant targetBuddy of account id targetService
send textMessage to theBuddy
delay theDelay
end repeat
end tell
log "Message sent"
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment