Difficulty retrieving Dictionary Values

Hi everyone!

I am trying to create a Shortcut to grab 5 news headlines from the Yahoo US news RSS feed and read them to me as part of a “wake up” shortcut that will run when I stop my alarm using the new iOS 13 shortcuts automations.

I am able to create a dictionary for these 5 headlines using the “Repeat with Each” action and iterating through the list. A Quick Look action (screenshot below) verifies that the Dictionary is created in JSON and the key-value pairs are the index number (1 through 5) and the corresponding headline as the value for each.

So far so good!

The problem comes when I am trying to retrieve each value individually to insert it in a Text action that will be the “script” for my “newscast”. I want the Text action to read like so: “Today’s first story is [Dictionary Value #1]. Up next, [Dictionary Value #2]” and so on, all the way through headline 5.

For “Dictionary Value #1” in my example above (and I’ve inserted screenshots below, along with an iCloud link to my shortcut) I use a Magic Variable to grab the Repeat Results from the End Repeat marker. I set the type to Dictionary and, when prompted, insert the key number as “1”. If I run the shortcut, this works and the headline associated with key #1 is inserted just fine in my Text action. However, if I repeat this process, and add a second Magic Variable, grabbing key value “2”, in addition to key value “1” nothing is inserted for 2 (but #1 still does insert the value for Key #1))

So, I’m not sure what is going on here: The Dictionary clearly exists (the Quick Look proves this) but I seem to be limited to grabbing only 1 value in the Text action.

Any help or ideas here would be very much appreciated!


Link to Shortcut: https://www.icloud.com/shortcuts/697de43ad18144e5ade2648baab9209e

There doesn’t exist one dictionary, but 5 as you can see by the title 2 of 5. This means, each article is packed inside their own dictionaries, without any connection.

To fix this:

Get RSS items
Repeat with each
  Get variable (dict)
  Set dictionary value (Repeat index, repeat item)
  Set variable (dict)
End repeat
Text (Todays first story is (dict#1). Following up, (dict#2). ...)

This way, you assign the common dictionary dict each feed.

Thank you for reply! I think follow what you are saying. I may have to modify it a bit as I am using the Shortcuts 3.0 syntax, which no longer has the “Get Variable” action.

I’ll post back as to how this works out.

Thanks again!

Ok. Got it working! Had to do a (very) little bit of modification from your suggested method (as indicated, due to there no longer being a “Get Variable” action.

Final product below.

Thanks again!

Nice! Glad I could help :wink:

1 Like