At OpenFn we wanted to get alerts on Slack whenever new posts came into this forum. Thanks to discourse’s “API → Webhook” feature it took me 2-minutes to automate. Thanks, Discourse, for being awesome.
Here’s my OpenFn job code. I used the language-http@6.1.0
adaptor:
post(
'https://hooks.slack.com/services/shhhhhhhhh-secret-slack-hook-URL-here',
state => ({
body: {
"text": `🧑🤝🧑 New Forum Activity! Let's go be helpful!`,
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": `Yay for the community! 🧑🤝🧑`
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": `*${state.data.topic.created_by.name}* (${state.data.topic.created_by.username}) created a new topic, "<https://community.openfn.org/t/${state.data.topic.id}|${state.data.topic.title}>", let's go help!`
}
}
]
}
})
);