Grocery Shortcut – Step-by-Step Creation Guide
This guide walks you through creating an Apple Shortcut that adds grocery items to the family dashboard via Siri.
Trigger: “Hey Siri, grocery” Siri asks: “What would you like to add?” You say: “milk, eggs, and bread” Siri confirms: “Added milk, eggs, bread”
Features: - Multiple items in one command (separated by commas or “and”) - Duplicate items are silently skipped (case-insensitive) - Quantities as part of the name (“2 milk” stays as “2 milk”) - Retries once on network failure, then shows an error
Before You Start
You need your Supabase Project URL and anon key. See README.md for where to find them.
Create the Shortcut
Open the Shortcuts app on your iPhone. Tap + to create a new Shortcut. Tap the name at the top and rename it to Grocery.
Step 1: Ask for Input
- Tap Add Action
- Search for Ask for Input and add it
- Set Type to Text
- Set Prompt to:
What would you like to add?
This captures the user’s voice input. When triggered via Siri, the user speaks their response.
Step 2: Set Up Supabase Configuration Variables
- Add a Text action
- Set the text to your Supabase project URL (e.g.,
[YOUR_SUPABASE_URL]) -
Long-press the action, tap Rename, name it
supabaseUrl -
Add another Text action
- Set the text to your Supabase anon key (e.g.,
[YOUR_ANON_KEY]) - Long-press the action, tap Rename, name it
anonKey
Step 3: Parse Multi-Item Input
- Add a Replace Text action
- Set Find to:
and(with spaces on both sides) - Set Replace with to:
, -
Set Input to:
Provided Input(from Step 1) -
Add a Split Text action
- Set Separator to Custom
- Set the custom separator to:
, - Set Input to:
Updated Text(from Step 12)
This converts “milk, eggs, and bread” into a list: [“milk”, ” eggs”, ” bread”].
Step 4: Initialize the Added Items Tracker
- Add a Set Variable action
- Set Variable Name to:
addedItems - Set Value to an empty Text action (just leave it blank)
Step 5: Begin the Loop
- Add a Repeat with Each action
- Set Input to:
Split Text(from Step 16)
Everything from Step 24 to Step 43 goes INSIDE this Repeat with Each block.
Step 6: Trim Whitespace from Each Item
- Inside the loop, add a Replace Text action
- Set Find to:
^\s+|\s+$(enable Regular Expression) - Set Replace with to: (leave empty)
- Set Input to:
Repeat Item
This trims leading and trailing spaces from each item.
Step 7: Skip Empty Items
- Add an If action
- Set the condition:
Updated Text(from Step 25) has any value
Everything from Step 30 to Step 42 goes inside this If block.
Step 8: URL-Encode the Item Name
- Add a URL Encode action
- Set Input to:
Updated Text(the trimmed item name from Step 25)
This ensures item names with spaces (like “orange juice”) are properly encoded for the URL.
Step 9: Check for Duplicates (with Retry)
- Add a Set Variable action
- Set Variable Name to:
retryCount -
Set Value to:
0 -
Add a Repeat action
-
Set Count to:
2 -
Inside the Repeat, add a Get Contents of URL action
-
Tap the URL field and build it by combining:
- Variable:
supabaseUrl(from Step 6) - Text:
/rest/v1/groceries?name=ilike. - Variable:
URL Encoded Text(from Step 31) - Text:
&checked=eq.false&select=id
The full URL looks like:
[supabaseUrl]/rest/v1/groceries?name=ilike.[encodedItem]&checked=eq.false&select=id - Variable:
-
Set Method to: GET
-
Tap Headers and add:
apikey:[anonKey variable]Authorization: tap the value, typeBearer, then insert theanonKeyvariable
-
Add an If action after Get Contents of URL
- Set the condition:
Contents of URLhas any value -
In the If path (result has value – meaning the request succeeded):
- Add a Text action set to
done - Add a Set Variable action, set
retryCounttodone
- Add a Text action set to
-
In the Otherwise path (request failed):
- Do nothing (the Repeat loop will retry)
-
Add End If
- Add End Repeat
Step 10: Evaluate the Duplicate Check Result
- Add a Count action
- Set Type to: Items
-
Set Input to:
Contents of URL(the response from the GET request) -
Add an If action
- Set the condition:
Countis0
This means no duplicate was found – proceed with inserting the item.
Step 11: Insert the Grocery Item (with Retry)
- Inside the “Count is 0” If block, add a Repeat action
-
Set Count to:
2 -
Inside the Repeat, add a Get Contents of URL action
- Build the URL:
[supabaseUrl]/rest/v1/groceries - Set Method to: POST
- Tap Headers and add:
apikey:[anonKey variable]Authorization:Bearer [anonKey variable]Content-Type:application/json
- Tap Request Body and set to JSON
-
Add these key-value pairs:
name:Updated Text(the trimmed item name from Step 25) – set type to Textchecked:false– set type to Booleanadded_by:siri– set type to Text
-
Add an If action to check for success
- Set the condition:
Contents of URLhas any value - In the If path (success):
- Add a Text action set to
done - This breaks the retry intent (the loop will run its remaining iteration harmlessly)
- Add a Text action set to
- Otherwise (failure):
- Do nothing (retry via loop)
- Add End If
-
Add End Repeat
-
After the POST Repeat block, add an Add to Variable action
- Set Variable Name to:
addedItems - Set Value to:
Updated Text(the trimmed item name)
Step 12: Close All Blocks
- Add End If (closes “Count is 0” from Step 51)
- Add End If (closes “has any value” from Step 29)
- End Repeat (closes the Repeat with Each from Step 23)
Step 13: Handle Network Failure
- Add an If action
- Set the condition: Check if
retryCountis notdone - In the If path:
- Add a Show Result action
- Set the text to:
Couldn't reach the dashboard - Add a Stop This Shortcut action (optional – prevents the confirmation below)
- Add End If
Step 14: Show Confirmation
- Add an If action
-
Set the condition:
addedItemshas any value -
In the If path:
- Add a Show Result action
- Set the text to:
Added [addedItems] - (When Siri speaks this, it reads the list naturally)
-
In the Otherwise path:
- Add a Show Result action
- Set the text to:
Already on the list
-
Add End If
Testing
- Tap the play button in the Shortcuts app to test with typed input
- Type:
milk, eggs, and bread - Verify: Shows “Added milk, eggs, bread”
- Run again with:
milk - Verify: Shows “Already on the list” (duplicate detected)
Then test with Siri: 1. Say “Hey Siri, grocery” 2. When prompted, say “milk and eggs” 3. Verify items appear on the wall display
Troubleshooting
- “Couldn’t reach the dashboard” – Check that
supabaseUrlandanonKeyare correct. Verify your internet connection. - Duplicates not detected – Make sure the GET URL uses
ilike(noteq) for case-insensitive matching. - “orange juice” split into two items – Make sure you are only splitting by commas, not by spaces. The “Replace Text” action should only replace
andwith,. - Items not appearing on wall display – Verify the Supabase realtime publication includes the
groceriestable (it should already be configured).