I hear a lot from different people who are uncertain how to know what is happening on their n8n instances when they are not there watching them. And even if you are there watching the workflows, you do not see what is happening on the active workflows that are being triggered behind the scenes without digging onto the executions.
I thought I would share with everyone how I have overcome this issue and know what is happening on all of my n8n instances in real time, even when I'm not at my computer using Discord.
In this article, you will learn how to:
- Configure your Discord server to receive n8n notifications
- Create an error workflow in n8n
- Create an event log workflow
- Integrate these workflows into your other workflows
- Check your n8n alerts in Discord
So, let's get to it!
- You already have a Discord server set up
- You are familiar with how Discord works
- You have admin priviledges on the Discord server
- You have n8n available, either on-prem or cloud (if not, you can get a one month free trial for n8n)
What is Discord and Why Are We Using It?
For those of you who are unfamiliar with Discord, it is a popular chat platform that can be set up for free online. If you don't know how to set one up, you can check out the How-To Geek article How to Set Up Your Own Discord Chat Server.
There are several reasons for using Discord:
- Easy to set up
- Node exists in n8n
- Mobile app available
- Clients for most computer platforms
Configuring the Discord Server
Before we start working on n8n, we need to do a number of things on the Discord server.
First, create a new text channel and name it
Next, create a new webhook for the channel:
Name the webhook and give it an icon. Then copy the webhook URL:
Repeat this process to create an
Once you have completed these steps, it is now time to start building the n8n workflows.
Create Event Log Workflow
The first workflow that we are going to create is the event log workflow. This workflow will allow you to test and send information to the Discord event log channel.
The key to this workflow is to set the Discord node webhook URL to the value of the webhook URL created when you made the
text field is the second piece of the puzzle for configuring the node. It is looking for the following inputs:
- Title - the title of the message
- Workflow - name of the workflow sending the alert
- ID - ID number of the workflow sending the alert
- Active - boolean indicating if the workflow is active or not
- RunIndex - run index of the workflow
- Message - message sent by the workflow
Note the information that is pushed to Discord is sent in Markdown format to give the alert a bit more punch.
Make sure that the Testing node is disabled before you launch the workflow in production so that you aren't just sent test data each time it is launched.
Create Error Log Workflow
The next workflow that we are going to be creating is the error log workflow. This is a very special workflow because it uses the Error Trigger node which listens to error events on specified workflows and then responds to them.
The Error Trigger has no input parameters and requires no configuration other than being connected to another node.
The Discord node is configured very similarly to the same node in the event workflow except its webhook points to the
error-log channel in Discord. The text field formats the data that is automatically generated by the error trigger node to generate an error that looks like the following:
You will notice that the error message generates a lot of information pointing not only to where the error occurred in the workflow but also what errors and messages it received and a direct link to the actual workflow execution that created the error. This greatly reduces the troubleshooting effort for the workflow.
Activating the Error Log Workflow
Because the error log workflow is designed to listen to all errors, it can be used by multiple other workflows for error logging.
To enable this error logging facility, open up the workflow you wish to use to the error log and go to the Settings screen. The first entry on the screen is Error Workflow. Set this value to Error Log.
Create Test Workflow
In order to make sure that your workflows are working properly, you can create a test workflow to log an event and then throw an error to log an error event.
You will need to make two changes to this workflow before it will work properly. The first is enter in the workflow ID for the event log workflow in the Send To Event Log node. You can determine the workflow ID by opening up the event log workflow and looking at the number at the end of the URL.
The second configuration change that you need to do is to set the error workflow in the settings to the Error Log workflow. (See above for more details).
Once you have made the configuration changes, save and activate your workflow. In under a minute you should see an event and an error entry in each of the Discord channels.
Note that the Event Log Parameters automatically pulls most of the information sent to the event log automatically by using expression variables. The only two things that you will want to set yourself will be the Title and Message sent to the event log. This can be done manually or programmatically.
We have learned how to create and send event and error log entries to custom Discord channels to give visibility to these events when not monitoring them actively in n8n.
These events can then be seen on the Discord web, native and mobile apps.
Feel free to reach out to me if you have any questions or suggestion about these workflows and I hope you find them to be useful.