For Slack, it's easy and built-in but sometimes as I was reminded you may want to send messages elsewhere. Thanks to Brian Stitt for the starting information.
I created a free Discord Server in a few seconds and was ready to send messages.
You then copy the webhook URL and you are ready to call. It's a long SSL link, just past that into the InvokeHTTP processor.
In our flow we need to create an SSL Context for NiFi. If you are using NiFi in a CDP DataHub there's one for you already configured!
The output will not have a body but there will be cool headers if you want to save them or use them for processing. Otherwise wrap this in a process group and you have an alert system of your own.
Before we call the InvokeHTTP we need to set the username of the bot.
Your message must be encoded as JSON like so:
"content": "This is my message"
Let's call the hook with our data every field is important.
HTTP Method: POST
Remote URL: https://discord.com ... our copied webhooks link
SSL Context: Create or use a StandardSSLContextService
Date Header: False
Follow Redirecrs: True
Use Digest: False
Always Output Response: True
Add Response Headers to Request: False
Send Message Body: true
Chunk Encoding: False
Ignore responses content: false
Here are the results:
We can see the output of the call to Discord Webhook HTTPS REST Endpoint:
We can see our bot, Spidey Bot, has posted some exciting test messages from NiFi.
For Source Code: