# Automate iMessages with AppleScript

Surge publishes a public search API over its indexed pages; the guide is at https://surge.app/agents/agent-access.

Source: https://surge.app/articles/automate-imessages-with-applescript/
Source observed: 2026-11-19T20:06:26.365Z
Last checked: 2026-11-26T20:54:17.199+00:00
Indexed: 2026-11-19T20:35:14.89+00:00

---

# Automate iMessages with AppleScript

**Published by Dennis Beatty — 2025-05-22**

![Automate iMessages with AppleScript](https://surge.app/_astro/automate-imessages-with-applescript.DRdFA7HO.jpg)

For a long party guest list, manually texting invitations can be tedious. If you have an iPhone and a Mac, AppleScript can automate personal iMessage sending. Our Surge platform is designed for A2P (application-to-person) messaging, not P2P (person-to-person) messaging, so this article uses AppleScript for the personal-use case.

## AppleScript

AppleScript controls Mac applications, including Messages. Create a file named `sendMessage.applescript` (or another filename) and add this sample script:

```applescript
property buddyList : { "8015551234", "8015554567" }
property targetMessage : "Hello from AppleScript!"

tell application "Messages"
  set targetService to 1st service whose service type = iMessage

  repeat with aBuddy in buddyList
    set targetBuddy to buddy aBuddy of targetService
    send targetMessage to targetBuddy
  end repeat
end tell

log "Message sent"
```

Update the first two properties for your own use:

- `buddyList` is the list of phone numbers or email addresses to message.
- `targetMessage` is the message text.

## Run the script

After saving the file, run it from a terminal with:

```bash
osascript sendMessage.applescript
```

The script loops through `buddyList` and sends `targetMessage` to each recipient. Sending may take about a minute for all messages; when complete, the terminal should show a message, and the Messages app may play its send sound if sound is enabled.

This approach is intended for personal uses such as party invitations, reminders, or a quick group message, and is not expected to scale for business needs. For more information, see [the official AppleScript documentation](https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html). For questions about text messaging, contact [@dnsbty](https://x.com/dnsbty) on Twitter/X.

[All articles](https://surge.app/articles/)

---

[Read this page’s summary](https://surge.app/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fsurge.app%2Farticles%2Fautomate-imessages-with-applescript%2F&trace=t_96494d7d69f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Surge’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://surge.app/agents/agent/faq?q={question}&trace=t_96494d7d69f3`

[Tool guide and examples](https://surge.app/agents/agent-access) · [OpenAPI](https://surge.app/agents/api/public/v1/openapi.json) · [Page TLDR form](https://surge.app/agents/agent-tools/page-tldr?url=https%3A%2F%2Fsurge.app%2Farticles%2Fautomate-imessages-with-applescript%2F). Opening a form does not execute a tool.