Skip to main content
Solved

Help: RSS Feed Format does not allow for dot notation access.


Forum|alt.badge.img+1

Hi there,

I’m trying to use an RSS feed from my Webflow Collections for ‘Events’ to populate email flows.

My RSS link is here:

www.farrago.club/event/rss.xml

The converted JSON format (previewed within Klaviyo Web Feed settings):

{
  "rss": {
    "@version": "2.0",
    "@xmlns:atom": "http://www.w3.org/2005/Atom",
    "@xmlns:media": "http://search.yahoo.com/mrss/",
    "channel": {
      "title": "Farrago: Events",
      "link": "https://www.farrago.club",
      "description": "A fusion of of art, music and performance.",
      "pubDate": "Sun, 13 Aug 2023 16:35:13 GMT",
      "ttl": "60",
      "generator": "Webflow",
      "atom:link": {
        "@href": "https://www.farrago.club/event/rss.xml",
        "@rel": "self",
        "@type": "application/rss+xml"
      },
      "item": [
        {
          "title": "Event | Sound of London | Sep 12, 2023",
          "link": "https://www.farrago.club/event/sound-of-london",
          "guid": "https://www.farrago.club/event/sound-of-london",
          "description": "Sound of London is more than a festival, its a story: a first-of-its-kind 4-day event highlighting various corners of the underground music.",
          "pubDate": "Tue, 12 Sep 2023 18:00:00 GMT",
          "media:content": {
            "@url": "https://uploads-ssl.webflow.com/6358e991f1dde90847825b5d/64d66001ad155316398b921c_sol-dp.png",
            "@medium": "image"
          },
          "media:thumbnail": {
            "@url": "https://uploads-ssl.webflow.com/6358e991f1dde90847825b5d/64d66001ad155316398b921c_sol-dp.png"
          }
        },
        [INSERT ALL EVENTS - OMMITTED FOR SIMPLICITY]...
        }
      ]
    }
  }
}


As you can see, the Image media which I need to access is under:

> item
    > media:thumbnail
        >@url


However, Klaviyo’s explicit need for dot notation when referencing means that this is an innaccessible field.

I would expect to do: `item.media:thumbnail.@url` but this presents syntax errors.

Is there another way to access sub-items within an item? More like dictionary searching, for example:
item[‘media:thumbnail’][‘@url’]

The only alternative I can think of is creating my own microservice which regularly checks the above RSS feed, changes the keys to plain text, and re-publishes the RSS feed under a different link. However, this doesn’t seem ideal nor extensible if I ever want to use RSS feeds from other collections on my site (e.g. Blog Posts, Artists, etc.)

Thanks!
Pat

Best answer by Brian Turcotte

Hi @Farrago!

My apologies for the delay in my response here!
 

It may be more appropriate to use lookup notation here, like so:

 item|lookup:'media:thumbnail'|lookup:'@url' 

 

This notation is also referenced more robustly in this Help Center article:


Best,

Brian

View original
Did this topic or the replies in the thread help you find an answer to your question?

5 replies

Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 3 replies
  • August 13, 2023

Update:

I tried to create a microservice, in Python, which serves a JSON file:

The endpoint looks like this:

@anvil.server.http_endpoint("/rss/events")
def get_events_rss_feed():
    events_rss_url = "https://www.farrago.club/event/rss.xml"
    try:
        req = requests.get(events_rss_url)
        print(f"req: {req}")
    except Exception as e:
        print(f"Error: {e}")
        return
    dict = xmltodict.parse(req.content)
    # pprint(dict)

    items = dict.get('rss').get('channel').get('item')

    pprint(items)
    for item in items:
        item['mediaThumbnailUrl'] = item['media:thumbnail']['@url']

    return json.dumps({"items":items}, indent=4)


It is accessible here: https://farrago-admin.anvil.app/_/api/rss/events

And returns a JSON file formatted as follows:

{
    "items": [
        {
            "title": "Event | Sound of London | Sep 12, 2023",
            "link": "https://www.farrago.club/event/sound-of-london",
            "guid": "https://www.farrago.club/event/sound-of-london",
            "description": "Sound of London is more than a festival, its a story: a first-of-its-kind 4-day event highlighting various corners of the underground music.",
            "pubDate": "Tue, 12 Sep 2023 18:00:00 GMT",
            "media:content": {
                "@url": "https://uploads-ssl.webflow.com/6358e991f1dde90847825b5d/64d66001ad155316398b921c_sol-dp.png",
                "@medium": "image"
            },
            "media:thumbnail": {
                "@url": "https://uploads-ssl.webflow.com/6358e991f1dde90847825b5d/64d66001ad155316398b921c_sol-dp.png"
            },
            "mediaThumbnailUrl": "https://uploads-ssl.webflow.com/6358e991f1dde90847825b5d/64d66001ad155316398b921c_sol-dp.png"
        },
        [......]
}



I’m getting the following error when trying to add the web feed in Klaviyo, without any further explanation as to what the issue is.


I can see that there was a HTTP request made from Klaviyo when trying to add the feed, but this didn’t throw any errors on my server, and looks like the response was a 200

The only issue may be that the server is a little slow, what is the built in timeout from Klaviyo’s side?
 


best,

Pat


Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 3 replies
  • August 14, 2023

SOLVED (Partially)

The issue turned out to be improper formatting on the returned JSON from my endpoint.

The Klaviyo engine expects the RSS metadata not just any JSON blob.
Here is my updated endpoint for anyone wondering:

```
 

@anvil.server.http_endpoint("/rss/events")
def get_events_rss_feed():
    events_rss_url = "https://www.farrago.club/event/rss.xml"
    try:
        req = requests.get(events_rss_url)
        print(f"req: {req}")
    except Exception as e:
        print(f"Error: {e}")
        return
    dict = xmltodict.parse(req.content)

    for item in dict['rss']['channel']['item']:
        item['mediaThumbnailUrl'] = item['media:thumbnail']['@url']

    return json.dumps(dict, indent=4)

```

However, I would still like to avoid doing this if possible - is there any way to index the items in Klaviyo without using dot notation?

best,
Pat


Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 3 replies
  • August 14, 2023

UPDATE #3

The web feed was added to Klaviyo but doesn’t work within the actual templated emails.
Likely because the server is too slow in returning the JSON blob.

This is starting to become a problem now, I don’t know why Klaviyo’s web feed integration is so limited.

Any help is appreciated


Brian Turcotte
Forum|alt.badge.img+37

Hi @Farrago!

I’m going to run this by Engineering and I’ll get back to the thread ASAP!
 

Best,

Brian


Brian Turcotte
Forum|alt.badge.img+37
  • Klaviyo Alum
  • 1393 replies
  • Answer
  • August 31, 2023

Hi @Farrago!

My apologies for the delay in my response here!
 

It may be more appropriate to use lookup notation here, like so:

 item|lookup:'media:thumbnail'|lookup:'@url' 

 

This notation is also referenced more robustly in this Help Center article:


Best,

Brian