auths
objectEnter the URL for the RSS feed.
Enter the field name that contains the unique ID for each RSS item. The field name can vary for each feed. Common field names include id
and guid
.
return
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
const Parser = require('rss-parser')
const parser = new Parser()
const feed = await parser.parseURL(params.rss_url)
// assumes only care about remembering last fetch instead of all previous
const checkpoint = this.$checkpoint || {}
const nextCheckpoint = {}
this.newItems = []
for (const item of feed.items || []) {
const id = item[params.id_field_name]
nextCheckpoint[id] = true
if (!checkpoint[id]) this.newItems.push(item)
}
// checkpoint the items so we don't export them on the next workflow execution
this.$checkpoint = nextCheckpoint
// end the workflow execution if no new items were detected
if (!this.newItems.length) $end('No new items found')
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
// generate mail subject and body text based on new items
this.subject = 'New items (' + steps.rss.newItems.length + ') from the LEAP feed'
const headlines = []
steps.rss.newItems.forEach(function(item) {
const headline = '* ' + item.title + ' ' + item.link + ' '
console.log(headline)
headlines.push(headline)
})
this.body = headlines.join('\n')
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
const options = {
subject: steps.generate_mail.subject,
text: steps.generate_mail.body,
}
if (params.html) {
options.html = params.html
}
if (params.include_collaborators) {
options.include_collaborators = params.include_collaborators
}
$send.email(options)