Przejdź do treści
Biblioteka skilli
Produktywność osobista · Automatyzacja

automating-messages

/automating-messages

Automatyzuje Wiadomości macOS (iMessage i SMS) przez JXA z rozpoznawaniem usługi i rozmówcy: obejścia błędów wysyłki, załączniki przez UI, chat.db i boty launchd.

Licencja
MIT
Ostatnia zmiana repozytorium
22.08.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
5
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 22.08.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Automatyzuje Wiadomości macOS (iMessage i SMS) przez JXA z rozpoznawaniem usługi i rozmówcy: obejścia błędów wysyłki, załączniki przez UI, chat.db i boty launchd.

Wyzwalacze z opisu

automate iMessagesend Messages via scriptJXA Messages automationread Messages history
Oryginalny opis (EN)

Automates macOS Messages (iMessage/SMS) via JXA with reliable service→buddy resolution. Use when asked to "automate iMessage", "send Messages via script", "JXA Messages automation", or "read Messages history". Covers send-bug workarounds, UI scripting for attachments, chat.db forensics, and launchd polling bots.

Jak działa

  1. Contents
  2. Permissions and scope
  3. Default workflow (happy path)
  4. Quick recipe (defensive send)
  5. Attachments and UI fallback
  6. Data access and forensics
  7. Bots and monitoring
  8. Validation Checklist
  9. When Not to Use
  10. What to load
Sekcje z nagłówków SKILL.md, w oryginale · 95 linii, 667 słów
Podgląd SKILL.md
---
name: automating-messages
description: Automates macOS Messages (iMessage/SMS) via JXA with reliable service→buddy resolution. Use when asked to "automate iMessage", "send Messages via script", "JXA Messages automation", or "read Messages history". Covers send-bug workarounds, UI scripting for attachments, chat.db forensics, and launchd polling bots.
allowed-tools:
  - Bash
  - Read
  - Write
---

# Automating Messages (JXA-first with UI/DB fallbacks)

## Contents
- [Permissions and scope](#permissions-and-scope)
- [Default workflow](#default-workflow-happy-path)
- [Quick recipe](#quick-recipe-defensive-send)
- [Attachments and UI fallback](#attachments-and-ui-fallback)
- [Data access and forensics](#data-access-and-forensics)
- [Validation Checklist](#validation-checklist)
- [When Not to Use](#when-not-to-use)
- [What to load](#what-to-load)

## Permissions and scope
- Grants needed: Automation + Accessibility; Full Disk Access for any `chat.db` reads.
- Keep automation scoped and auditable; avoid unsolicited sends and DB writes.
- Pairs with `automating-mac-apps` for common setup (permissions, osascript invocation, UI scripting basics).

## Default workflow (happy path)
1) [ ] Resolve transport: pick `serviceType` (`iMessage` or `SMS`) before targeting a buddy.
2) [ ] Identify recipient: filter buddies by `handle` (phone/email). Avoid ambiguous names.
3) [ ] Send via app-level `send`: pass Buddy object to `Messages.send()`.
4) [ ] Verify window context: activate Messages when mixing with UI steps.
5) [ ] Fallbacks: if send/attachments fail, use UI scripting; for history, use SQL.

## Quick recipe (defensive send)
```javascript
const Messages = Application('Messages');
Messages.includeStandardAdditions = true;

function safeSend(text, handle, svcType = 'iMessage') {
  const svc = Messages.services.whose({ serviceType: svcType })[0];
  if (!svc) throw new Error(`Service ${svcType} missing`);
  const buddy = svc.buddies.whose({ handle })[0];
  if (!buddy) throw new Error(`Buddy ${handle} missing on ${svcType}`);
  Messages.send(text, { to: buddy });
}
```
- Wrap with `try/catch` and log; add small delays when activating UI.
- For groups, target an existing chat by GUID or fall back to UI scripting; array sends are unreliable.

## Attachments and UI fallback
- Messages lacks a stable JXA attachment API; use clipboard + System Events paste/send.
- Ensure Accessibility permission, bring app forward, paste file, press Enter.
- See `references/ui-scripting-attachments.md` for the full flow and ObjC pasteboard snippet.

## Data access and forensics

**Reading messages limitation:** The AppleScript/JXA API for Messages is effectively **write-only**. While `send()` works reliably, reading messages via `chat.messages()` or similar methods is broken/unsupported in modern macOS. The only reliable way to read message history is via direct SQLite access to `~/Library/Messages/chat.db`.

**Security consideration:** Reading `chat.db` requires **Full Disk Access** permission, which grants broad filesystem access beyond just Messages. This is a significant security trade-off - granting Full Disk Access to scripts or applications exposes all user data. Consider whether reading message history is truly necessary before enabling this permission.

- Use SQL against `chat.db` for history; JXA `chat.messages()` is unreliable/non-functional.
- Requires: **System Settings > Privacy & Security > Full Disk Access** for your terminal/script.
- Remember Cocoa epoch conversion (nanoseconds since 2001-01-01); use `sqlite3 -json` for structured results.
- See `references/database-forensics.md` for schema notes, typedstream handling, and export tooling.

**Example read query (requires Full Disk Access):**
```sql
sqlite3 ~/Library/Messages/chat.db "SELECT
  CASE WHEN m.is_from_me = 1 THEN 'Me' ELSE 'Them' END as sender,
  m.text,
  datetime(m.date/1000000000 + 978307200, 'unixepoch', 'localtime') as date
FROM message m
JOIN handle h ON m.handle_id = h.rowid
WHERE h.id LIKE '%PHONE_NUMBER%'
ORDER BY m.date DESC LIMIT 10;"
```

## Bots and monitoring
- Implement polling daemons with `launchd` now that on-receive handlers are gone.
- Track `rowid`, query diffs, dispatch actions, and persist state.
- See `references/monitoring-daemons.md` for the polling pattern and plist notes.

## Validation Checklist
- [ ] Automation + Accessibility permissions granted
- [ ] Service resolves: `Messages.services.whose({ serviceType: 'iMessage' })[0]` returns object
- [ ] Buddy lookup works: `svc.buddies.whose({ handle })[0]` returns target
- [ ] Test send completes without errors
- [ ] Full Disk Access granted if using `chat.db` reads

## When Not to Use
- For reading message history without Full Disk Access (AppleScript/JXA cannot read messages)
- For cross-platform messaging (use platform APIs or third-party services)
- For business SMS automation (use Twilio or similar APIs)
- When iMessage/SMS features are not available on the target system
- For bulk messaging (rate limits and security restrictions apply)
- When security policy prohibits Full Disk Access grants (required for any read operations)

## What to load
- Control plane and send reliability: `references/control-plane.md`
- UI scripting + attachments fallback: `references/ui-scripting-attachments.md`
- SQL/history access: `references/database-forensics.md`
- Polling bots/launchd: `references/monitoring-daemons.md`
Pliki w paczce (5)
  • SKILL.md 5 KB
  • references/control-plane.md 3 KB
  • references/database-forensics.md 2 KB
  • references/monitoring-daemons.md 1 KB
  • references/ui-scripting-attachments.md 2 KB

Wersje

W bazie nie ma innych skilli o nazwie automating-messages.

Migawka bazy z 13.11.2026 · wersja paczki e2e53d5f2b21 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 1 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100automating-notes
    Automatyzuje Apple Notes przez JXA: konta, foldery, notatki, treści HTML, zapytania, przenoszenie oraz zapasowe mosty Objective-C i UI.
  • 100automating-mail
    Automatyzuje Apple Mail przez JXA: konta, skrzynki, wsadowe filtrowanie wiadomości, tworzenie wiadomości, załączniki i zapasowe skryptowanie UI.
  • 86imessage
    Wysyła i odbiera iMessage przez usługę Linq, gdy użytkownik chce napisać do kogoś lub sprawdzić wiadomości.
  • 100imessage
    Czyta i wysyła iMessage lokalnymi mechanizmami macOS bez API firm trzecich: tryb wysyłania przez AppleScript po wyraźnym poleceniu oraz opcjonalny tryb odczytu z bazy chat.db wymagający pełnego dostępu do dysku.
  • 90export-messages
    Eksportuje rozmowy z aplikacji Wiadomości do plików Markdown, po jednym na rozmowę z załącznikami, przez narzędzie Exporter.
  • 100applescript
    Automatyzuje macOS przez AppleScript i JXA: sterowanie aplikacjami i systemem, osascript i integracja z aplikacjami macOS.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.