Use Automator to send files via Messages App - sms

I've seen some older posts about this issue but no real fixes.
I"m using macOS 13.1 and I would like to use Automator to send my clients iMessage or SMS texts that include images. I am able to send actual "text" just fine.
When I try to send a file, I see the file in the Messages app but I get a failed to send error. I see the same behavior using SMS or iMessage.
My simple Code
set image to POSIX file "/Path/To/File.ext"
tell application "Messages"
activate
set iMessageService to 1st account whose service type = iMessage
set client to participant "5551234567" of iMessageService
send image to client
end tell
Again, I can send texts to the same number but not a file. I am able to send the file to the number directly from the Messages app.
Google, Apple Developer, multiple phone numbers.

Related

How to send a video to an iMessage group chat using AppleScript

I am new to AppleScript and am trying to find a way to automate sending a specific video to an existing iMessage group chat. My current code is as follows:
tell application "Messages"
repeat 3 times
send POSIX file "/Users/(myName)/Desktop/IMG_4027.MOV" to chat "Test GC"
end repeat
end tell
When I run the code and open iMessage, I see the file sending in the correct group chat. I am able to click on the file in iMessage and it opens to the correct video. However, the file never delivers, and after a couple of minutes I get an alert from iMessage saying my message "failed to send," and a little red mark within iMessage saying "not delivered."
Note: when I replace the "POSIX....MOV" part of my code with words or a sentence, the program works fine and the words/sentence is delivered in the group chat. The problem only exists when sending a file.

Simple AppleScript to send SMS by Messages app fails with error MacOs Monterey 12.0.1

I wish to automate the sending of SMS texts using AppleScript to control the Messages app in MacOS Monterey (12.0.1). My very simple test script fails with an error message as below:
tell application "Messages"
send "Test" to participant "123456789" of account "SMS"
end tell
Running the script fails with this error:
error "Messages got an error: Invalid key form." number -10002 from account "SMS"
Obviously, I am using a valid phone number (my own) which is among my contacts (in fact, Script Editor recognizes the number and offers additional info via a drop down list).
The MacBook Pro M1 I'm using is setup to send and receive text messages, I use that all the time. I get the same result if I try to send an iMessage by replacing "SMS" with "iMessage". Thank you for your help.
Try:
tell application "Messages"
launch
repeat while (count of windows) is 0
end repeat
set a to first account whose service type = SMS and enabled is true
set p to participant "123456789" of a
send "test, please ACK" to p
-- properties of p
end tell
Note: You may not be able to text yourself, and you may need to already have texted the recipient.
tell application "Messages"
set iMessageService to 1st account whose service type = iMessage
set imessagebuddy to participant "00301234567890" of iMessageService
send "ignore the last messages. just testing. i am still the applescriptmaster" to imessagebuddy
end tell

I can send Google Assistant messages to my windows application, but how do I send a message back?

I'm using IFTTT to send a Google Assistant message to my Windows application via Drop Box. If I say "[keyword] [message]" (for example: "Computer: Play Game of Thrones Season 2 Episode 4") IFTTT will write the text translation of [message] to a file on drop box that my application monitors and from there I can read the [message] and act on it.
What I would like to be able to do is send a reply back to the device that sent the message... For example if I tell my phone to have my computer start a movie on my computer and for whatever reason my app can't find the movie I want to be able to communicate that back to the device that originally sent the message, whether that be my cell phone or tablet or Google Home smart speaker.
I know there is probably no official way to do this but i'm looking for creative solutions (like the one I use to get the message in the first place)... anything at all that works even if it involves multiple third-party services.
There's no good way to send back an acknowledgement through the IFTTT integration. You'd need to build your own Action which would use something like push notifications to communicate between your local device and a cloud-based webhook.

OS X Messages AppleScript handler: save images?

I've been attempting to use AppleScript to save incoming messages on an Apple Messages account, like so:
on active chat message received theMessage from theBuddy
set theFileID to open for access POSIX file "/Users/me/Desktop/test" with write permission
write theMessage to theFileID
close access theFileID
return theMessage
end active chat message received
which works great for text messages, but if the user sends an image the message appears to just be an empty string. Is there any way to fetch this image, or - as I fear - is it not accessible?
This isn't a direct answer, but I've discovered that the OS X Messages app uses SQLite for storage, at ~/Library/Messages/chat.db. It has a table named attachment which lists the filenames of all attachments.
For my purposes, this is enough - but I'd love to hear if there are more legitimate alternatives.

OS X: open e-mail client, create new mail and add file as attachment

We want to make it for users of our (Java) application as easy as possible to send bug-logs to us. First, we imagined to open a bug-report page of our website and prefill an up-load-input field with the path of the file to upload, but this does not work for security reasons.
Is it possible on OS X (command line call, Apple Script, what ever) to open a new e-mail in the default e-mail client and add a certain file as attachment?
You can do this from the command line (terminal). Here's an example:
open -a Mail filetosend.ext
This opens the Mac Mail app, creates a message and attaches the file, ready to send.
Unfortunately there's no standard way to attach a file; you'd have to write a separate script for any of the many email clients the user has installed, and that's assuming they actually use an email client—many people use Gmail, for example.
If you can't encode the information in text, you can just submit the report by HTTP(S) yourself. There are several open source frameworks that can help with this, such as FeedbackReporter (which uses HTTP) and UKFeedbackProvider (for email).
Does it necessarily have to be an attachment? You could inline text based info in the message body using the bog standard mailto: URL which would work in any OS and any email client.

Resources