Page 1 of 1

Problem sending iMessages with AppleScript...

PostPosted: Wed Mar 27, 2019 12:24 am
by russg
Hi All,
I copied the script below for sending text. messages via AppleScript in an Action. (I'm not using the iMessage plugin because of problems getting it to work). Here's my code:
=======
Code: Select all
use application "IndigoServer"
set pvSubject to value of variable "vTxtMsgSubject"
set pvMessage to value of variable "vTxtMsgBody"
set pvBuddy to value of variable "vTxtMsgBuddy"

set targetMessage to "{Indigo} " & pvSubject & " " & pvMessage
tell application "Messages"
   set targetService to 1st service whose service type = iMessage
   set targetBuddy to buddy pvBuddy of targetService
   send targetMessage to targetBuddy
end tell
========
This works great EXCEPT if the message app on the system running Indigo does NOT ALREADY HAVE a message from the buddy the script is trying to send to. This is an issue if you are adding a new phone number to send the message to, or if the string of messages from the recipient on the Indigo system have all been deleted.

Basically, there is no existing Buddy to reference. There would need to be a way to specify a NEW Buddy, somehow.

Is there a way to send a message using AppleScript that would work in these cases? I.e. the AppleScript is trying to send to a phone number that is not in the list of existing messages.

Any thoughts? I'd be willing to take on a Python script if it would work in both cases.

thanks in advance!
-russg

Re: Problem sending iMessages with AppleScript...

PostPosted: Wed Mar 27, 2019 8:12 am
by jay (support)
[MODERATOR NOTE] I don't know the answer but I moved the topic to the (more appropriate) AppleScript Scripting forum.

Re: Problem sending iMessages with AppleScript...

PostPosted: Wed Mar 27, 2019 2:38 pm
by mat
Have you tried the plugin? Works for me.

Re: Problem sending iMessages with AppleScript...

PostPosted: Wed Mar 27, 2019 5:49 pm
by jltnol
FWIW, I've been using the "Messages" plugin.

https://github.com/gazally/indigo-messages


Works great for me and may be something you can use.

Re: Problem sending iMessages with AppleScript...

PostPosted: Thu Mar 28, 2019 10:14 pm
by russg
I spent several hours playing with it, but I kept getting strange behaviors that crept up after porting Indigo from a VMWare virtual machine on an old Mac to a different physical Mac, w/o the VM.

It looks simple, there isn't much configuration, and I'd prefer to use it but I ran out of time and went with this. When I get a couple of free hours I'll take a look again; the developer has been great at answering questions and it would be ideal.
thanks - rush

Re: Problem sending iMessages with AppleScript...

PostPosted: Wed May 22, 2019 3:31 pm
by whmoorejr
I'm not positive... I only send messages to myself and my wife... but the only difference between your script and mine is of (service 1 whose service type is iMessage).

Code: Select all
tell application "Messages"
   set targetService to 1st service whose service type = iMessage
   set targetBuddy to buddy pvBuddy of targetService
   send targetMessage to targetBuddy of (service 1 whose service type is iMessage)
end tell


Just came across this while trying to figure out how to convert my applscript iMessage to Python iMessage.