# RSS Feed - only get the latest entry

**URL:** <https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805>\
**Category:** General\
**Created:** [13 March 2022 16:42 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805 "2022-03-13T16:42:09Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![pitheway](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pitheway](https://discourse.nodered.org/u/pitheway)\
**Post date:** [13 March 2022 16:42 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/1 "2022-03-13T16:42:09Z")

</div>

Noob question. I am using NodeRed to read youtube rss and post the results to chat bot. I have noticed that when the node red server goes offline or gets rebooted the entire feed going back many entries gets reposted.

question:  
Would it be better to somehow record everything posted to the database and then compare new entries with DB? That seems somewhat complex.

Or can I just tune the current setup to only post content posted to RSS feed in the last hour? That way if system does restart the number of duplicates will be low. If so what would be the best way to do it?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 March 2022 17:03 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/2 "2022-03-13T17:03:17Z")

</div>

Welcome to the forum @pitheway

I don't use rss feeds, but would it be enough to record the timestamp of the latest one actioned? If so you could use persistent context in node red to remember that so you can start again from there on restart. There is a node red docs page "Working with Context" that tells you about that.

Have you watched the node red essentials videos (they would have covered context if I remember correctly). [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). Well worth watching if you have not done so.

---

<div class="post-metadata">

**Author:** ![pitheway](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pitheway](https://discourse.nodered.org/u/pitheway)\
**Post date:** [14 March 2022 02:13 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/3 "2022-03-14T02:13:39Z")

</div>

The context is a good idea!

contextStorage: {  
default: "memoryOnly",  
memoryOnly: { module: 'memory' },  
file: { module: 'localfilesystem' }  
},

This is what I have in settings,js. Reset the service but still dont see context in change node. Any clues what I missed?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 March 2022 08:44 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/4 "2022-03-14T08:44:22Z")

</div>

> [@pitheway](#):
>
> Reset the service but still dont see context in change node. Any clues what I missed?

Did you refresh the browser after restarting node-red?

You should see this in a change node...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/1/3198878400e41564742143027e49ac77c2249de0.png)

Your settings entry is slightly different to mine but it should work. You could try what I have which is...

```javascript
    contextStorage: {
        default: { module: "memory" },
        file: { module: "localfilesystem" }
    },

```

PS: what version of node-red are you running?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 March 2022 09:45 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/5 "2022-03-14T09:45:50Z")

</div>

Show us how you are saving the value to context and how you are picking it up again.

---

<div class="post-metadata">

**Author:** ![pitheway](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pitheway](https://discourse.nodered.org/u/pitheway)\
**Post date:** [14 March 2022 19:09 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/6 "2022-03-14T19:09:23Z")

</div>

I rebooted the pi and now I can see the drop down in the change node. Looks like it only appears when flow or global is selected.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 March 2022 20:13 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/7 "2022-03-14T20:13:50Z")

</div>

> [@pitheway](#):
>
> Looks like it only appears when flow or global is selected.

Context stores only apply to context.

---

<div class="post-metadata">

**Author:** ![pitheway](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pitheway](https://discourse.nodered.org/u/pitheway)\
**Post date:** [14 March 2022 23:17 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/8 "2022-03-14T23:17:15Z")

</div>

Thats good to know. I now see the youtube link that should be the payload in context window.

So how would this work in practice?

I have a function node that translates payload to telegram message:

var content = msg.payload  
msg.payload = {}  
msg.payload.chatId = 11111111  
msg.payload.type = "message"  
msg.payload.content = content  
return msg;

However when I use flow.payload the content part of the message is null. Are there some other changes I need to make?

Here is the flow:

[{"id":"e7aba38c.4139d","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"9481a6af.3aa9d8","type":"function","z":"e7aba38c.4139d","name":"","func":"var content = flow.payload\nmsg.payload = {}\nmsg.payload.chatId = 11111111\nmsg.payload.type = "message"\nmsg.payload.content = content\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":840,"y":360,"wires":[["6bcefcbc.f42cf4"]]},{"id":"6bcefcbc.f42cf4","type":"debug","z":"e7aba38c.4139d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1090,"y":360,"wires":},{"id":"a7d9d8db.481e58","type":"change","z":"e7aba38c.4139d","name":"","rules":[{"t":"move","p":"topic","pt":"msg","to":"#:(file)::payload","tot":"flow"},{"t":"set","p":"topic","pt":"msg","to":"article.author & " - " & article.title","tot":"jsonata"},{"t":"set","p":"image","pt":"msg","to":"article.image.url","tot":"msg"},{"t":"delete","p":"article","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":360,"wires":[["fac2988.672b568"]]},{"id":"fac2988.672b568","type":"rbe","z":"e7aba38c.4139d","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":590,"y":360,"wires":[["9481a6af.3aa9d8"]]},{"id":"e5347985.f13dc8","type":"feedparse","z":"e7aba38c.4139d","name":"feed","url":"[https://www.youtube.com/feeds/videos.xml?channel\_id=UCu94OHbBYVUXLYPh4NBu10w","interval":"2","x":110,"y":360,"wires":[["a7d9d8db.481e58](https://www.youtube.com/feeds/videos.xml?channel_id=UCu94OHbBYVUXLYPh4NBu10w%22,%22interval%22:%222%22,%22x%22:110,%22y%22:360,%22wires%22:%5B%5B%22a7d9d8db.481e58)"]]}]

Thank you all for taking time to answer my ridiculous questions.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 March 2022 09:34 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/9 "2022-03-15T09:34:48Z")

</div>

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 March 2022 10:30 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/11 "2022-03-15T10:30:28Z")

</div>

Even without it being correctly formatted, I can see that the function is not the same as you showed above. The code you posted says  
`var content = msg.payload`  
but in the function you have  
`var content = flow.payload`  
That is not how to fetch context data in a function node, you have to use `flow.get()`. In [Working with context : Node-RED](https://nodered.org/docs/user-guide/context) it has a section Using context in a function node, which links to [Writing Functions : Node-RED](https://nodered.org/docs/user-guide/writing-functions) where it shows you how to do that.

Also, though, the value it picks up will be the value it wrote there a in the Change node earlier in the flow. I thought you wanted to remember something each time through, then the first time on restart pick that up and use that to know where to start, and I don't see how your flow does that. What is it that you are writing to context?

---

<div class="post-metadata">

**Author:** ![pitheway](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pitheway](https://discourse.nodered.org/u/pitheway)\
**Post date:** [15 March 2022 15:09 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/12 "2022-03-15T15:09:13Z")

</div>

var content = flow.payload - this was me trying to get the payload into telegram message. And yes I do want to remember the entire history of rss.  
Like I said I am very new to this. Hence was hoping for some assistance. Perhaps not just functional but also logical as well.  
maybe context is the way to do it.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 March 2022 17:12 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/13 "2022-03-15T17:12:46Z")

</div>

> [@pitheway](#):
>
> I do want to remember the entire history of rss

Exactly what do you need to remember? Not in vague terms, but exactly what data.

---

<div class="post-metadata">

**Author:** ![pitheway](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pitheway](https://discourse.nodered.org/u/pitheway)\
**Post date:** [15 March 2022 17:53 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/14 "2022-03-15T17:53:18Z")

</div>

I would like to remember the payload from the change that follows RSS node that in this case contains the link to you tube video. And then potentially use the RBE or some other method to prevent repeat messages.

I now see how this may become complicated quickly since I will need to pull only that part in the subsequent telegram node...

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 March 2022 20:15 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/15 "2022-03-15T20:15:32Z")

</div>

Do you need to record all of them since the beginning or just the latest one? When fetching from a feed how does it know which ones you have already got? Do they not have a timestamp or a sequence number or something?

---

<div class="post-metadata">

**Author:** ![pitheway](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pitheway](https://discourse.nodered.org/u/pitheway)\
**Post date:** [15 March 2022 20:55 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/16 "2022-03-15T20:55:03Z")

</div>

I would like to keep at least a few days worth to verify against. The feed gets everything but the RBE node prevents duplicates. And that works well until the reboot

I have not looked at pulling the timestamp though its a good idea.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 March 2022 21:06 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/17 "2022-03-15T21:06:33Z")

</div>

> [@pitheway](#):
>
> I have not looked at pulling the timestamp though its a good idea.

If this is possible then it is a good way to do it, so I suggest you investigate that.

---

<div class="post-metadata">

**Author:** ![pitheway](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pitheway](https://discourse.nodered.org/u/pitheway)\
**Post date:** [15 March 2022 22:06 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/18 "2022-03-15T22:06:07Z")

</div>

OK and then somehow pull the link from context using the timestamp?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 March 2022 07:44 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/19 "2022-03-16T07:44:09Z")

</div>

Is it possible to ask for videos posted after a certain time?  
Does each video you receive have a timestamp with it?  
Which RSS node are you using?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 May 2022 07:44 UTC](https://discourse.nodered.org/t/rss-feed-only-get-the-latest-entry/59805/20 "2022-05-15T07:44:28Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
