How to send group iMessage text via Applescript?

I made an applescript (see below) using macOS Script Editor that sends an iMessage via Messages.

However, I want to send the message to a group of recipients. I know how to send the message out to multiple parties individually, but I want to send to a group.

Anyone know how to do this?

tell application "Messages"
	set targetBuddy to "(123) 456-789"
	set targetService to id of 1st account whose service type = iMessage
	set textMessage to "Wassup!"
	set theBuddy to participant targetBuddy of account id targetService
	send textMessage to theBuddy
end tell

I believe you need to set the Buddy to the desired chat:


But unless there is newer info somewhere, Apple may not be cooperative in helping you get the metadata you need to accomplish this:

1 Like

We had discussed this on the Keyboard Maestro forum.

With the revamped Messages app in Big Sur, Applescript is still supported, but a lot of the functionality has been depreciated. It’s still possible to send to individual people, but groups is harder.

One option is to use CardHop, which recognizes Group names in your contacts.

My current solution using Keyboard Maestro (as seen in that thread) is a macro that “builds” a new message to a group of users, one name at a time. It works well for me, but my original group is only two other people. If this were a big group of names, this might not be feasible.

Happy to help more, if I can!


I didn’t know about Script Debugger. Just did a shallow dive and I’m already impressed.


Thanks for the feedback

I did the trial but I’m only looking to buy macOS Keyboard Maestro once I’m satisfied i have enough uses for it. So far my needs have been met by Apple scripts, Automator, and Big Sur keyboard prefs options.

When you say “it’s still possible to send to individual people, but groups is harder”, does that mean there’s no way to do it using Apple scripts? My use case is simply sending a message to two other people, not a bunch.

I realize what I wrote was somewhat confusing. I have not found any way (in Big Sur) to automate messaging a group through applescript alone. I was referring to the workaround that I found with Keyboard Maestro. There is a clunky way where you can use AppleScript to control CardHop, but if you don’t have CardHop either, I would put that money towards KM.

If I didn’t say it before, this is a huge bummer. This used to be possible. While Apple can say Messages still “supports AppleScript,” clearly this is not a priority for the company (unless Shortcuts comes to the Mac in my lifetime.)

1 Like

Thanks for the clarification and insight.

Yeah, I think it’s only a matter of time before I buy KM given my automation appetite grows and grows! tenor-226540632

1 Like

FWIW, I tried the KM trial, and it sat completely unused. And then for some reason I bought it anyway, and only used it occasionally for a few months. Then one day I realized it would solve some automation issue that was very specific to me and no one else, but it made my life easier. 3 months later, I had probably written 50 macros. I have no idea what the count is now. :slight_smile:

1 Like

I had the same issue and managed to solve it, but only for an already-existing, named group in Messages. The steps I took are in this answer on StackOverflow.

1 Like

Vincent, I’ve tried renaming a group in Messages and tried to follow your directions in the StakcOverflow answer and still can’t get it to run. What were your exact steps if you recall?

I just updated the StackOverflow post to elaborate on that part of it. Let me know if that doesn’t get you there.