Slack Threading Issue: Posting AI Alerts to Dedicated Threads with Dynamic Titles

Hi n8n team,

We’re using the open-source self-hosted version of n8n (v1.98.2) and building a workflow where AI-generated security alerts are pushed into a dedicated Slack channel, and for each alert:

  1. A dedicated thread is created (not grouped under one message).
  2. The parent message in each thread contains a dynamic title — ideally pulled from the summary field of the alert.

We’re using the HTTP Request node to send Slack messages via the Slack API (chat.postMessage and chat.postMessage for replies). Here’s what we observed:


:white_check_mark: What works:

When we use this raw JSON body, the message is sent and threaded correctly:

{
  "channel": "C095H829X96",
  "text": "```\n\nTEST```",
  "thread_ts": "={{ $json.thread_ts }}"
}

:cross_mark: What fails:

When we try using expressions like:

{
  "channel": "C095H829X96",
  "text": "```\n\n{{ $json.text }}```",
  "thread_ts": "={{ $json.thread_ts }}"
}

or

{
  "channel": "C095H829X96",
  "text": "```\n\n" + $json.text + "\n```",
  "thread_ts": $json.thread_ts
}

We get the following error:

JSON parameter needs to be valid JSON [item 0]

:magnifying_glass_tilted_left: What we tried:

  • Escaping special characters like \n, \", and backticks
  • Using both {{ $json.text }} and JS concatenation like + $json.text +
  • Pre-formatting using a Set node
  • Using “Send Body Parameters” (not raw JSON) — but formatting and Markdown don’t render as expected
  • Trying to split alerts correctly into individual messages with Loop Over Items / Split In Batches

:test_tube: Desired Behavior:

  • Post each alert in its own Slack thread
  • Format the thread body using triple backticks (code block) + clean line breaks
  • Dynamically inject the summary field as the top-level parent message in each thread

:red_question_mark: Questions:

  1. How do we pass multi-line Markdown strings inside the JSON body of an HTTP node without causing validation errors?
  2. Is there a safe expression format that allows using {{ $json.text }} inside code blocks (`````) in the JSON body field?
  3. Is there a better node structure to create separate threads with dynamic parent messages, each containing full Markdown output?

Any help or working examples would be amazing. Thank you for supporting the open-source community!

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