How can you send a iMessage to a group chat? I have searched everywhere and I can't find anything. I want to send it to a group chat named something, possibly If I get a list of buddies in the chat I can send it to everyone at once? A problem may be that I'm also in the chat, so that might be a problem.
To send to an existing group chat, you will need to obtain the chat's internal guid. There are 2 methods of doing this.
Extract it from the messages.app internal database, located on disk at ~/Library/Messages/chat.db. It is the guid column under the chat table. If you have the group chat named it will be easy to find by display_name.
You can use an AppleScript handler for Messages with the on chat room message received handler to capture the ID when someone posts in that chat.
Once you have the guid (should in a format similar to iMessage;+;chat831551415676550949), you can use AppleScript to send the message.
tell application "Messages"
set myid to "iMessage;+;chat831551415676550949"
set mymessage to "Hello World"
set theBuddy to a reference to text chat id myid
send mymessage to theBuddy
end tell
To send an image, replace the mymessage text with:
set ImageAttachment to POSIX file "File path here" as alias
Related
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.
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.
I am trying to send NEW messages using applescript through the macos messages app.
on run {targetBuddyPhone, targetMessage}
tell application "Messages"
send targetMessage to buddy targetBuddyPhone of service "SMS"
end tell
end run
The above script runs fine on the condition that there is already a conversation started for the specific targetBuddyPhone in the messages app. Any ideas how to send a NEW message?.. I can't believe it isn't possible.
It could be possible to call URL from Apple Script in this form:
sms://open?addresses=+15558675309,+15558675301/&body=Text%20Here%20end!
It will not send message, but just prefill it and user will need to press Enter key.
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.
I have an email that I need to schedule to send later. I know you can schedule an apple script to fire off at a set time using iCal, but I have been unable to find one that works. It doesn't necessarily have to be done this way though. I would be grateful of a solution to this problem.
This works for me with a run script alarm in iCal on 10.6.8
tell application "Mail"
activate
set mymail to make new outgoing message at the beginning of outgoing messages with properties {subject:"Triggered"}
tell mymail
make new to recipient at beginning of to recipients with properties {address:"first#email.com, second#email.com"}
set content to "hi"
end tell
--show message window (otherwise it's hidden)
set visible of mymail to true
--bring Mail to front
activate
send mymail
end tell
I'm also getting an error like outgoing message 1 doesn’t understand the send message when trying to send an outgoing message. Referring to a message created from a script still seems to work though.
tell application "Mail"
set m to make new outgoing message with properties {subject:"subject", content:"content"}
tell m
make new to recipient at end of to recipients with properties {address:"jana#doe.com, john#doe.com"}
end tell
send m
end tell
You could also create a Calendar alarm in Automator.
I just accomplished this without Automator, using only Apple Mail:
Double-click anywhere your calendar to start creating an event.
Give the event a name. This will be the subject line of the email.
Set the date and time of the event to when you want the email to be sent.
If you want the email to be sent on a schedule, choose a repeat frequency and potential termination date.
For the alert, choose Custom....
Select email. You might be prompted to add a contact card to the Contacts app.
Choose the person to whom you want to send the email, and set the time to At Time Of Event. Press OK.
You can choose to add Notes, a URL, or attachments. I haven't tried these options, but I assume that they are carried forward in the email that is sent.