How to send message using message app?

How can I send message using message app? I couldn’t find any function to do this in KM.

As far as I can tell there is no function in KM dedicated to this, but off the top of my head it can be accomplished one of two ways: through simulated UI interactions (keystrokes, mouse clicks, etc.) or through AppleScript, either on its own or in combination with KM, which is much more precise and less likely to fail than the UI interaction solution.

What exactly is it that you’re trying to accomplish by automating Messages? For example, do you want to be able to pick from a list of pre-written messages and send them to a predefined contact? Do you want to be able to schedule messages to be sent later? Do you want to write and send messages to any given contact without needing to actually open The more precise you can be about the goal you’re trying to achieve and/or the actions you want to automate, the more we can help.

The KM will prompt for the message and I’ll type it.

Then it should be sent as the message to a predefined number in km’s step.

In that case, this should get you started:

Send iMessage in Background.kmmacros (2.3 KB)

All you need to do is replace the [REPLACE WITH BUDDY NAME] part in the second action (making sure to leave the quotation marks intact) with the name of the contact you wish to send messages to (specifically, the exact same name that's displayed on top of their chat window). For example, if you were to replace that part with your own forum handle, the last line of text in the "Execute an AppleScript" action would read

tell application "Messages" to send MessageText to buddy "nexgen"

Feel free to ask if you have any follow-up questions.

1 Like

Thanks a lot gglick. It’s exactly what I wanted but with a small tweak.

Instead of contact name can I put the mobile number directly?

Happy to help, @nexgen. Unfortunately, as far as I can tell, there isn’t any way to send messages directly to a mobile number instead of a contact name. The only workaround I can think of off the top of my head is to use the contact’s phone number as their name, or perhaps make a new contact with just the desired mobile number and use that as the contact name.

You should be able to use a script like this.
I just tested it with my phone# and it worked.

set phoneNumStr to "+11231231234" ## REPLACE with phone# you want to use

tell application "Messages"
  set serviceID to get id of first service
  send "Test send to phone number" to buddy phoneNumStr of service id serviceID
end tell


Thanks @JMichaelTX. I tested it but it tries to send the message using imessage and if the recipient doesn’t have imessage then it doesn’t try with a normal text message. Any workaround?

The Messages app is very tricky. You might try each of these:

  • In Messages>Preferences>Accounts, make sure "Start new converstions from:" is set to your iPhone phone#.


  • Try using the "SMS" service directly:
--- INSTEAD OF: ---
send "Test send to phone number" to buddy phoneNumStr of service id serviceID

--- TRY ---
send "Test send to phone number" to buddy phoneNumStr of service "SMS"


You may also want to review these articles:

And from the Messages Online Help System:
Get and send SMS messages - Messages Help

If I understand you correctly, I do what you are asking all the time. I use a program called mySMS. I use KM to access mySMS and automate it where possible.

This is done for the next version.