An incoming webhook can run a script on each article it receives.
This script gives control over a set of features:
setTitle(string)
)setText(string)
)setCategory(string)
)markAsRead()
)markAsToRead()
)sendNotification()
)triggerWebhook(string)
)disableGlobalNotification()
)The script expects a boolean value in return. This value decides the fate of the article:
return true;
: the article will be integratedreturn false;
: the article will be ignoredNote that if the article is ignored then the above features have no effect.
You are free to implement the orchestration logic of these actions with a simple syntax.
You can access the following attributes within your script:
Title
: the title of the articleText
: the text of the articleHTML
: the HTML content of the articleURL
: the URL of the articleOrigin
: the article originTags
: the tags and hashtags of the article (string array)Note that hashtags are extracted from the article title and text, while tags come with the input article. Only hashtags are kept (because they are part of the title and text). Input tags are not kept and are only used by the script. If you want to keep the tags, it’s recommended to include them as hashtags in the title or text.
Here are some examples to illustrate the possibilities:
if ("news" in Tags) {
setCategory("News");
}
return true;
setTitle(sprintf("[From my awesome webhook] %s", Title));
return true;
if ("news" in Tags) {
setCategory("News");
if (Title ~= /breaking|important/i) {
sendNotification();
}
}
return true;
if (Title ~= /boring|stupid/i) {
return false;
}
return true;
if (Origin == "johndoe@example.com") {
setTitle(sprintf("[From %s] %s", Origin, Title));
return true;
}
return false;