Auto delete text message from Messages App on Mac based on text string

I really, really want to be able to automatically DELETE text in Messages App based on if the text message contains a specific string. For example: It a text message in the Message App contains the following string:

"health insurance" or
"quote" or
"healthcare"

I want that text to automatically delete and block.

I get a lot of legit messages from unknown senders so that filter is not an option. Can anyone solve this?

I've messed with quick(er) deletion on macos messages app, and for me it felt too risky to take my finger off of the button that says "This conversation will be deleted from all of your devices," when I count on long message histories with friends and family and would hate to have them deleted by accident. I definitely would not be automatically deleting conversations based on the context of the text myself. If you worry about that too, it might be better to make something like:

And assign it a hotkey trigger. It would be an improvement to check if the person is blocked already, so you don't have a situation where you block someone but fail to delete, and then unblock them and delete upon the next trigger, since the menu option is still the same whether or not the person is already blocked, but how often will that happen? For me this is good enough.

Cool- maybe in addition - conditions could be

  1. Unknown Sender AND
  2. String contains....X, or Y or Z

If it over performs the message would still exist on my other devices. I use AT&T Active Armore to do this on iOS but on Mac I have to figure out something else.

I answered in the other thread you posted in (please don't double-post like that—it just makes the job of those who would like to help tougher, as we then have to follow two threads). Here's what I wrote there:

I assume for security reasons, Apple has made it basically impossible to read the content of a message via AppleScript. Perhaps there's some other way, but if there is, I'm not aware of it. The best you could do (that I can think of) would be to select all the text in the message and copy it; then Keyboard Maestro could work with it.

But if you're doing all that already, it's probably easier to just delete-and-block the message using a macro like the one @cfriend shared above. (I use a very similar version on my Macs.)

-rob.

1 Like