SOLVED: Limit the input to {{ $json.textPlain }}

Hi there, I am new to n8n and have no idea of json.

I created a Workflow, where all my emails are checked via IMAP Email trigger, if they are addressed to me directly (not cc) and if they are from certain domains (customers). After that they are sent

  • via telegram bot to my phone
  • transalted via text to speech and also sent via telegram
  • a out of office reply is sent.

My problem now is that I had the case of long emails with all the long texts from the whole conversation and now I got an error that the input is to long and can not sent via Telegram.

At the moment my Telegram Output looks like that:
Email von: {{ $json.from }}
Betreff: {{ $json.subject }}
Inhalt:
{{ $json.textPlain }}

Is it possible to limit the output of the textPlain to perhaps 2,500 Characters? This would also be cheaper on my OpenAI Budget for Text to speech :smiley:

Thanks a lot!
Greetings from Germany,
Josef

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

It is a docker Installation, self hosted on a Synology. Version 1.56.2. Not sure about the database.

If anybody finds this and has the same question. The code is

$json.textPlain.substring(0,500)

2 Likes

Welcome to the community @josef_hajda !

Tip for sharing information

Pasting your n8n workflow


Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.

```
<your workflow>
```

That implies to any JSON output you would like to share with us.


Thank you for your contribution. Indeed, utilizing the JavaScript methods (like substring or slice ) in your expression is the easiest and best approach.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.