Scripting & Automation

Pockity supports powerful automation on iPhone, iPad, and Mac through Apple Shortcuts, plus deeper scripting on macOS through AppleScript. This lets you connect your financial data to your own workflows, whether that's turning a bank text message into a draft expense automatically, or scripting Pockity directly from the terminal.

Looking to connect an AI assistant like Claude or Codex instead? See the MCP Server Guide.

Automation via Apple Shortcuts

The easiest way to automate expense creation, on any of your devices. A great use case is turning a bank SMS or email into a draft expense automatically, with no manual entry required.

Pockity includes a Smart Add Expense action for the Shortcuts app, available on iPhone, iPad, and Mac. Give it the raw text of a message and it does the rest: Apple Intelligence reads the amount, currency, date, and transaction details — preferring Private Cloud Compute for the most accurate results, and falling back to the on-device model automatically if Private Cloud Compute isn't available — and Pockity saves the result as a draft for you to review.

The Smart Add Expense Shortcut action, configured with a Ledger, the Shortcut Input as Text, and a required Account

1. Add the "Smart Add Expense" action

In the Shortcuts app, search for Smart Add Expense (or just Pockity) in the actions library and add it to your Shortcut. Configure it with:

  • Text: the message content you want parsed, usually the Shortcut Input token.
  • Ledger: which ledger the draft should be saved to.
  • Account: the account to save the draft against. This is required when you build the Shortcut.

Pockity also reads the message for a category and applies it automatically when it can confidently match one of your ledger's existing category names, and detects the transaction's currency (from a symbol or ISO code next to the amount) and applies that to the draft as well. Review both on the draft before confirming it, in case the message was ambiguous.

That's the whole Shortcut. No "Use Model" step and no AppleScript required, and it works the same way whether the automation runs on your iPhone or your Mac.

2. Set up the trigger

  1. Open the Shortcuts app and go to the Automation tab.
  2. Tap or click the + button to create a new automation.
  3. Choose Message (or Email) as the trigger.
Shortcuts Automation Tab
  1. Configure the trigger:
    • Sender: a specific sender, or "Any Sender".
    • Message Contains (or Subject Contains for email): a unique identifier from your bank's messages, for example the last 4 digits of your account or card.
Message Trigger Configuration
  1. Turn on Run Immediately so the automation runs in the background without asking for confirmation.
  2. Choose the Shortcut you built in step 1.

On iPhone and iPad, an Email trigger may prompt you with a notification to run rather than running silently in the background. This is a Shortcuts behavior on those platforms, not something Pockity controls. Message triggers can run fully in the background once Run Immediately is on.

Advanced: AppleScript Guide (macOS only)

Prefer more control, or want to script Pockity directly from the terminal? Pockity for macOS also supports AppleScript, giving you direct, scriptable access to your ledgers, accounts, and entries.

You can run these scripts using the Script Editor app on your Mac, or directly from your terminal using the osascript command.

1. List All Your Ledgers

Find out which ledgers you have configured in Pockity.

AppleScript:

tell application "Pockity"
    return name of every ledger
end tell

Terminal:

osascript -e 'tell application "Pockity" to return name of every ledger'

2. Check Your Primary Ledger Balance

Get a quick summary of the accounts in your primary ledger.

AppleScript:

tell application "Pockity"
    tell primary ledger
        repeat with anAccount in every account
            log (get name of anAccount) & ": " & (get balance of anAccount)
        end repeat
    end tell
end tell

Terminal:

osascript -e 'tell application "Pockity" to tell primary ledger to get name of every account'

3. Log a New Expense (Fast Entry)

Add a new transaction instantly without manually opening the entry editor.

AppleScript:

tell application "Pockity"
    tell primary ledger
        make new entry with properties {title:"Morning Coffee", amount:4.50, account name:"Pocket", category name:"Food"}
    end tell
end tell

Terminal:

osascript -e 'tell application "Pockity" to tell primary ledger to make new entry with properties {title:"Lunch", amount:12.00, account name:"Debit Card", category name:"Food"}'

4. Create a Quick Draft

Not sure which category to use yet? Create a draft entry to categorize later in the app.

AppleScript:

tell application "Pockity"
    tell primary ledger
        make new entry with properties {amount:25.00, is draft:true}
    end tell
end tell

Terminal:

osascript -e 'tell application "Pockity" to tell primary ledger to make new entry with properties {amount:25.00, is draft:true}'

Advanced: Custom SMS Parsing via AppleScript (macOS only)

Smart Add Expense (above) covers this for most people. If you'd rather build the parsing step yourself, for example to use a different AI model, target a specific account name directly, or create a final entry instead of a draft, you can still wire this up with Shortcuts' Use Model action and AppleScript.

A Shortcut using the on-device model to parse an SMS, guarded by an If condition checking for amount and currency, then passing the result to a Run AppleScript action

1. Private Cloud Compute (Apple Intelligence)

If you are using a model like Private Cloud Compute to parse the SMS, you can use the following prompt:

Parse the following SMS and extract the following information: currency, amount, date, transactionID (optional), title.

1. The date should be an ISO8601 date.
2. The transactionID could be prefixed with items like: UPI, CC, DEBIT, CREDIT. If it has a prefix, remove the prefix.
3. The title or location could be anywhere in this message. The title or location could be in all caps. If it is capitalised, normalise the string.

Message: Shortcut Input

Note: Shortcut Input should be replaced with the input token in the Shortcuts editor.

  • Set the Use Model action's Output to Dictionary. If you reference the response elsewhere first, for example in an If condition checking amount has any value, tap that inserted variable to open its settings and set Type to Dictionary there too, with Get left on Dictionary (not a specific key) wherever you're passing the whole response along, such as into the Run AppleScript action below. Left as Text, the script's NSDictionary's dictionaryWithDictionary: call has nothing to parse and the action produces no result.
A variable's settings popover with Type set to Dictionary, Get set to Dictionary, and an optional Get Value for Key field

2. AppleScript Integration

To send the parsed data to Pockity, use the Run AppleScript action with the following code:

use framework "Foundation"
use scripting additions

-- MARK: Helper — safe nil/NSNull check
on isMissingOrNull(val)
	if val is missing value then return true
	-- isKindOfClass: handles NSNull without touching the reserved 'null' word
	return (val's isKindOfClass:(current application's NSNull)) as boolean
end isMissingOrNull

on run {input, parameters}
	set dict to item 1 of input
	set objCDict to current application's NSDictionary's dictionaryWithDictionary:dict
	
	-- MARK: Required — amount
	set amountNS to objCDict's valueForKey:"amount"
	set entryAmount to amountNS's doubleValue() as real
	
	-- MARK: Optional — title
	set titleVal to objCDict's objectForKey:"title"
	if my isMissingOrNull(titleVal) then
		set entryTitle to "Untitled"
	else
		set entryTitle to titleVal as string
	end if
	
	-- MARK: Optional — transactionID
	set txnVal to objCDict's objectForKey:"transactionID"
	if my isMissingOrNull(txnVal) then
		set entryNotes to ""
	else
		set entryNotes to "Transaction ID: " & (txnVal as string)
	end if
	
	-- MARK: Optional — date
	set entryDate to current date
	set dateVal to objCDict's objectForKey:"date"
	if not my isMissingOrNull(dateVal) then
		set formatter to current application's NSDateFormatter's new()
		repeat with fmt in {"yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss", "yyyy-MM-dd"}
			(formatter's setDateFormat:fmt)
			set parsed to (formatter's dateFromString:(dateVal as string))
			if parsed is not missing value then
				set entryDate to parsed as date
				exit repeat
			end if
		end repeat
	end if
	
	-- MARK: Create entry in Pockity
	tell application "Pockity"
		tell primary ledger
			if entryNotes is "" then
				make new entry with properties {title:entryTitle, amount:entryAmount, date:entryDate, account name:"Savings", is draft:true}
			else
				make new entry with properties {title:entryTitle, amount:entryAmount, date:entryDate, notes:entryNotes, account name:"Savings", is draft:true}
			end if
		end tell
	end tell
	
end run

Note: In the AppleScript code above, ensure you replace "Savings" with the actual name of the account you wish to use, and ensure you are targeting the correct ledger (e.g., primary ledger or a specific ledger by name).

3. Message Automation

Set up the trigger the same way described in Set up the trigger above, choosing Message or Email, then point the automation's final action at this AppleScript step instead of Smart Add Expense.

Permissions & Security

AppleScript controls Pockity through Apple Events, so macOS requires an explicit permission grant before it will work.

For AppleScript to work, you must grant Automation permissions to the process running the script (e.g., your Terminal, Shortcuts, or AI application).

  1. Open System Settings on your Mac.
  2. Navigate to Privacy & Security → Automation.
  3. Ensure that the relevant application has permission to control Pockity.

Get started in seconds.

Pockity is free to download and start tracking. Unlock everything with Pockity+, one purchase, no subscriptions.

Contents