Discord Integration with Apache NiFi
Tags: messaging
Published: 2020-06-09 20:29:36

---
title: Discord Integration with Apache NiFi
published: true
date: 2020-06-08 20:04:00 UTC
tags: messaging
canonical_url: 
---

 **<font size="6">Discord Integration with Apache NiFi</font>**
  

  

[![](https://1.bp.blogspot.com/-Z8MB173kfDg/Xt6YDq3X6gI/AAAAAAAAanQ/Zw3PuiqkyCoQ5RgbKpfC3TlHoZeNOSsIQCK4BGAsYHg/w630-h640/SendToDiscordWebhook.png)](https://1.bp.blogspot.com/-Z8MB173kfDg/Xt6YDq3X6gI/AAAAAAAAanQ/Zw3PuiqkyCoQ5RgbKpfC3TlHoZeNOSsIQCK4BGAsYHg/s1486/SendToDiscordWebhook.png)

  

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.

  

[https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks)

  

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.
  

[![](https://1.bp.blogspot.com/-prBgF9Hc2Sc/Xt6YDx660LI/AAAAAAAAanU/--8QiAzrqXwF7i2c26JEXIfYnxqMFvOVACK4BGAsYHg/w640-h278/setBotUserNameDiscord.png)](https://1.bp.blogspot.com/-prBgF9Hc2Sc/Xt6YDx660LI/AAAAAAAAanU/--8QiAzrqXwF7i2c26JEXIfYnxqMFvOVACK4BGAsYHg/s1576/setBotUserNameDiscord.png)

  

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**

Content-Type:    **application/json**

Send Message Body: **true**

Chunk Encoding:  **False**

Ignore responses content: **false**

  

  

[![](https://1.bp.blogspot.com/-uONY6pQdoCM/Xt6YC4In-gI/AAAAAAAAanI/y7ecKToGicokVA1OfHOwKUiSqnohYpA0ACK4BGAsYHg/w640-h534/invokehttpdiscord1.png)](https://1.bp.blogspot.com/-uONY6pQdoCM/Xt6YC4In-gI/AAAAAAAAanI/y7ecKToGicokVA1OfHOwKUiSqnohYpA0ACK4BGAsYHg/s1179/invokehttpdiscord1.png)
  

[![](https://1.bp.blogspot.com/-RmqOAIh-HS0/Xt6YDARAnDI/AAAAAAAAanM/OtGSfvodlloLGQE6th3SJrxrTJTKsHYVQCK4BGAsYHg/w624-h640/Invokehttp2discord.png)](https://1.bp.blogspot.com/-RmqOAIh-HS0/Xt6YDARAnDI/AAAAAAAAanM/OtGSfvodlloLGQE6th3SJrxrTJTKsHYVQCK4BGAsYHg/s993/Invokehttp2discord.png)

  

Here are the results:

  

We can see the output of the call to Discord Webhook HTTPS REST Endpoint:
  

[![](https://1.bp.blogspot.com/-9ZkmZuAVIOE/Xt6YEerVG0I/AAAAAAAAanY/aRw_s7jhgZMbCMiL8eM3os1h1tofvLkKQCK4BGAsYHg/w640-h396/discordoutput.png)](https://1.bp.blogspot.com/-9ZkmZuAVIOE/Xt6YEerVG0I/AAAAAAAAanY/aRw_s7jhgZMbCMiL8eM3os1h1tofvLkKQCK4BGAsYHg/s1510/discordoutput.png)

  

[![](https://1.bp.blogspot.com/-ZZnyNJnoX0A/Xt6YCEf-dXI/AAAAAAAAanA/skCd-cUi-qIraxlxe3XEiXHMcvgrQCXBwCK4BGAsYHg/w640-h340/DiscordNiFi.png)](https://1.bp.blogspot.com/-ZZnyNJnoX0A/Xt6YCEf-dXI/AAAAAAAAanA/skCd-cUi-qIraxlxe3XEiXHMcvgrQCXBwCK4BGAsYHg/s2747/DiscordNiFi.png)

  

  

We can see our bot, **Spidey Bo** t, has posted some exciting test messages from NiFi.

  

**For Source Code:**

[https://github.com/tspannhw/NiFiToDiscord](https://github.com/tspannhw/NiFiToDiscord)

  

**References:**

- [https://www.datainmotion.dev/2019/08/find-cacerts-from-java-jre-lib-security.html](https://www.datainmotion.dev/2019/08/find-cacerts-from-java-jre-lib-security.html)
- [https://dzone.com/articles/lets-build-a-simple-ingest-to-cloud-data-warehouse](https://dzone.com/articles/lets-build-a-simple-ingest-to-cloud-data-warehouse)