Every morning, merges headlines on your topic from two news services, drops the duplicates and sends one digest to Telegram.
Uses
GNews
Google TranslateNews API
Telegram
Morning news digest in Telegram
newsTopic to blank.Set newsTopic to blank.digestChatId to blank.Set digestChatId to blank.translateInto to blank.Set translateInto to blank.headlineLanguage to en.Set headlineLanguage to en.headlinesPerSource to 8.Set headlinesPerSource to 8.maxHeadlines to 10.Set maxHeadlines to 10.sourceNotes.Start an empty list and save it as sourceNotes.gnewsArticles.Start an empty list and save it as gnewsArticles.sourceErrorIf a step below fails, save the error as sourceErrorTry
newsTopic coverage. Save it as response.Search for recent newsTopic coverage. Save it as response.response.articles into one list and save it as gnewsArticles.Combine a list of [] and response.articles into one list and save it as gnewsArticles.On error
GNews could not be read this morning. to the end of sourceNotes and save it as sourceNotes.Add GNews could not be read this morning. to the end of sourceNotes and save it as sourceNotes.sourceError as text.Show in the output: GNews search failed: sourceError as text.newsApiArticles.Start an empty list and save it as newsApiArticles.sourceErrorIf a step below fails, save the error as sourceErrorTry
newsTopic coverage. Save it as response.Search for recent newsTopic coverage. Save it as response.response.articles into one list and save it as newsApiArticles.Combine a list of [] and response.articles into one list and save it as newsApiArticles.On error
News API could not be read this morning. to the end of sourceNotes and save it as sourceNotes.Add News API could not be read this morning. to the end of sourceNotes and save it as sourceNotes.sourceError as text.Show in the output: News API search failed: sourceError as text.gnewsArticles and newsApiArticles into one list and save it as allArticles.Combine gnewsArticles and newsApiArticles into one list and save it as allArticles.seenHeadlines.Start an empty list and save it as seenHeadlines.digestLines.Start an empty list and save it as digestLines.article in allArticles:For each article in allArticles:digestLines is greater than or equal to maxHeadlines multiplied…If the length of digestLines is greater than or equal to maxHeadlines multiplied…Yes
No
No steps
articleErrorIf a step below fails, save the error as articleErrorTry
article.title and save it as headline.Trim article.title and save it as headline.headline lowercase and save it as headlineKey.Make headline lowercase and save it as headlineKey.headline isn't empty and seenHeadlines doesn't contain headlineKeyIf headline isn't empty and seenHeadlines doesn't contain headlineKeyYes
headlineKey to the end of seenHeadlines and save it as seenHeadlines.Add headlineKey to the end of seenHeadlines and save it as seenHeadlines.shownHeadline to headline.Set shownHeadline to headline.translateInto isn't emptyIf translateInto isn't emptyYes
translateErrorIf a step below fails, save the error as translateErrorTry
headline into translateInto. Save it as translation.Translate headline into translateInto. Save it as translation.translation.translated_text and save it as translatedText.Trim translation.translated_text and save it as translatedText.translatedText isn't emptyIf translatedText isn't emptyYes
shownHeadline to translatedText.Change shownHeadline to translatedText.' with ' in shownHeadline and save it as shownHeadline.Replace ' with ' in shownHeadline and save it as shownHeadline." with " in shownHeadline and save it as shownHeadline.Replace " with " in shownHeadline and save it as shownHeadline.& with & in shownHeadline and save it as shownHeadline.Replace & with & in shownHeadline and save it as shownHeadline.No
No steps
On error
translateError as text.Show in the output: Could not translate a headline, keeping the original: translateError as text.No
No steps
publisherPart to blank.Set publisherPart to blank.missingFieldIf a step below fails, save the error as missingFieldTry
article.source_name and save it as fieldValue.Trim article.source_name and save it as fieldValue.fieldValue isn't emptyIf fieldValue isn't emptyYes
publisherPart to - fieldValue.Change publisherPart to - fieldValue.No
No steps
On error
No steps
linkPart to blank.Set linkPart to blank.missingFieldIf a step below fails, save the error as missingFieldTry
article.url and save it as fieldValue.Trim article.url and save it as fieldValue.fieldValue isn't emptyIf fieldValue isn't emptyYes
linkPart to Change linkPart to
fieldValue.No
No steps
On error
No steps
shownHeadline plus publisherPart plus linkPart to the end of digestLines and save it as digestLines.Add shownHeadline plus publisherPart plus linkPart to the end of digestLines and save it as digestLines.No
No steps
On error
articleError as text.Show in the output: Skipped an article with no headline: articleError as text.heading to Morning news - newsTopic.Set heading to Morning news - newsTopic.digestLines with a blank line and save it as digestBody.Join digestLines with a blank line and save it as digestBody.digestLines is emptyIf digestLines is emptyYes
digestBody to Nothing new in the last 24 hours on this topic..Change digestBody to Nothing new in the last 24 hours on this topic..No
No steps
sourceNotes with a space and save it as sourceNotice.Join sourceNotes with a space and save it as sourceNotice.message to headingSet message to heading
digestBody.sourceNotice isn't emptyIf sourceNotice isn't emptyYes
message to messageChange message to message
sourceNotice.No
No steps
message to 3900 characters and save it as message.Shorten message to 3900 characters and save it as message.digestChatId.Send a message to chat digestChatId.message