How to split and post several messages without exceeding a certain character limit. e.g Discord

I would like to do the same exact thing as what the following documentation says. How would I reproduce this?

How to split and post several messages without exceeding a certain character limit. e.g Discord

What I have right now to get emails into a discord channel with webhook.

Hey @Norkz, welcome to the community!

In your Discord node you would reference data from your IMAP node through an expression like this:

Under the hood, these expressions just execute JavaScript, meaning to shorten a string you could use a method like .substring():

The {{ $json["textPlain"].substring(0, 100) }} expression used here would read the incoming textPlain value and then shorten the text down to 100 characters. So a possible workflow could look like so:

1 Like

Is there a way to do it like the following?

You can generally run custom code in n8n using the Function and Function Item nodes, but the post you have shared refers to a discord.js library which isn’t included in n8n.

To include external node modules you’d need to install them along with n8n and then allow their usage in the aforementioned nodes using the NODE_FUNCTION_ALLOW_EXTERNAL environment variable. This would only work if you host n8n yourself.

Alternatively you might want to raise a feature request for adding an “auto-split long messages” option to the n8n Discord node.

1 Like

Understood, thank you!

In the discord node, how would I add embeds that I recieve from the email to be posted with the discord webhook.


I get a notification from Traefik Pilot that tells me if one of my machines connected to it is down and it will send an image that I would like to see in discord in a more smaller format, any way this is possible?

Hi @Norkz, I don’t think that’s currently supported but there’s an open feature request for this on which you might want to vote:

1 Like

Understood mate, thanks again!

No worries. If your images have a public URL you could just include that URL in your text for the time being. Discord will preview the picture automatically:

1 Like

What you just said reminded me of another question, since the attachment/images aren’t currently supported, then is it possible that once the email is recieved through IMAP and it contains an image, that would be saved in a certain place and posted in a place like: imgur as private, then something would take the URL of that image and post it along side of the email that is recieved?


IMAP = Recieves email with Image

$Example node takes the email image and saves it somewhere.

$Imgur node or something else posts it as private

$Another example node would take the post URL and add it at the bottom of the email text_plain

$Discord Node would take both of these and add them together, then post it.