Apple Shortcuts Automation - What’s for Lunch Today?

At my school they have breakfast and lunch. They publish it on their website too. So I basically scrape it, get the lunch info, and at 6:50 AM, it sends me a notification that I can glance at while getting ready.

Now, it’s currently a little off, since we actually had no school Monday and started Tuesday, so they still wanted to give us the same foods in a row each day.

This automation uses my server https://lunchcuts.boston2029.repl.co/__repl to scrape the page using fetch and jsdom.

You can’t send automations I believe. I could send screenshots if someone wants, but a few more months ago I actually made a shortcut version of it that speaks it out in Siri’s voice, which you can check out here.

By the way it says “undefined” on weekends and breaks because, well, there’s no breakfast/lunch for those days. Heres the shortcut link: Shortcuts

Now I gotta get ready for school so bye

3 Likes

And the lunch looks a little scrappy with the comma separation, but that’s simply because they put “stuffed crust ” and “pizza” including the space after crust.

2 Likes

Hi @boston2029 ! How did you make your repl send notifications?

3 Likes

For the Repl, I use fetch to my schools online lunch calendar. I then take a querySelectorAll of all the item elements, which are usually something like [data-v-…] .lunch pre. I then send the response of (whatever lunch is)…(whatever breakfast is) with the dot dot dot to separate them. Back on the shortcuts end, we use Get contents of webpage to get the data. We use split text to get each item in an array (called a “list”). For the shortcut, we simply use the Speak command and make it say “for lunch we have (lunch), for breakfast we have (breakfast)”. As for the notifications, we simply use the Show Notification function. This sends notifications even if my phone is locked or anything

3 Likes

What is the speak command?
(Btw cool project!)

3 Likes

Speaks out provided text in a Siri voice or any voice you choose. You can even do different languages

2 Likes

And on January 4, 2024, it has stopped working entirely.

I am disappointed.

1 Like

This is a cool project, you might want to deploy it.

2 Likes

Yeah, I deployed it for them a while ago. I hope it has been useful, @boston2029 :smile:

2 Likes

It really has! Though today it said undefined for breakfast and lunch, but I reran it and it worked. :thinking: Probably not a deployment error though. And I didn’t code this in:

  • When Monday is a federal holiday, they only set the breakfast to “NO SCHOOL”.
  • So my script thinks that the first lunch (for Tuesday) is actually for Monday.
  • So the breakfast is accurate, but the lunch just says what the next day’s lunch actually is.
  • Then on Friday, the lunch says undefined.

Screenshot for understanding:

2 Likes

Perhaps if you find “NO SCHOOL” in a day’s breakfast, don’t grab lunch for that day?

4 Likes

Well duh. I just never wrote that in

1 Like