Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript to reply to most recently received message in Messages

I've been using this applescript for a while:


set _message_ to "{query}"

tell application "Messages"

set _chats_ to get every text chat

repeat with _chat_ in _chats_

try

set _check_ to updated of _chat_

set _current_ to updated of _recent_


if _check_ > _current_ then

set _recent_ to _chat_

end if

on error

set _recent_ to _chat_

end try

end repeat

send _message_ to _recent_

end tell


But unfortunately with El Capitan it started sending messages to seemingly random people, certainly not the last one I received a message from. I am looking for a way to modify this script such that it will send _message_ to the last person I either sent a message to or received a message from (as if I opened the app, selected the conversation that appears first and texted them _message_)

Such a script would be incredibly useful, especially when paired with Alfred, allowing one to hold a conversation over text while operating another app in full screen.

Any help is greatly appreciated

Posted on Nov 22, 2015 4:03 PM

Reply
3 replies

Applescript to reply to most recently received message in Messages

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.