Autoposting comment to Slack but it's not replying in thread to the message timestamp provided

I want to have it reply in specific thread and have put the message time stamp, but it doesnt reply in thread, the message just shows up in the channel looking regular (though I have to “remove from channel” first before I can delete the message when this is turned on. Any ideas how to get it to reply within a thread?

Recorded a loom with the issue. Seems that either I am not using the right terminology or slack is confused thinking that the message is in a thread even though its just posted to the main channel as a separate message? ClickUp - NAK: 01.23 - Checkout Abandonment Flow - Email 2 | #86875kdh1 - 23 February 2024 | Loom

Work flow: (cannot post due to limited user ability - less than 5 links and this has to share image url several times)

Slack output:

[
  {
    "ok": true,
    "channel": "C06EZ70UB41",
    "message": {
      "subtype": "thread_broadcast",
      "text": "Design for review",
      "user": "UR53NCJUX",
      "type": "message",
      "ts": "1708731724.941559",
      "bot_id": "B06KP97GG68",
      "app_id": "A016X0AT6QL",
      "blocks": [
        {
          "type": "image",
          "block_id": "image4",
          "image_url": "https://t2203545.p.clickup-attachments.com/t2203545/13c70101-6296-4111-a2a2-8a05ff681cb9/NAK_%20Welcome%20Email%205%20-%2001.26.jpg",
          "alt_text": "An incredibly cute kitten.",
          "title": {
            "type": "plain_text",
            "text": " NAK_ Welcome Email 5 - 01.26.jpg",
            "emoji": true
          },
          "image_width": 600,
          "image_height": 2317,
          "image_bytes": 695242,
          "is_animated": true,
          "fallback": "600x2317px image"
        },
        {
          "type": "section",
          "block_id": "Tk+d+",
          "text": {
            "type": "mrkdwn",
            "text": "Design ready for review",
            "verbatim": false
          }
        },
        {
          "type": "section",
          "block_id": "/1KF2",
          "text": {
            "type": "mrkdwn",
            "text": "_Automated with this <https://wgm.app.n8n.cloud/workflow/aDTpFLdtFBJNkNpl?utm_source=n8n-internal&amp;utm_medium=powered_by&amp;utm_campaign=n8n-nodes-base.slack_ee4930d5742f1c148a271a4710fd3569d128eec3a3d6ceb11c3bf1009d614884|n8n workflow>_",
            "verbatim": false
          }
        }
      ]
    },
    "message_timestamp": "1708731724.941559"
  }
]```


## Information on your n8n setup
- **n8n version:**
- **Database (default: SQLite):**
- **n8n EXECUTIONS_PROCESS setting (default: own, main):**
- **Running n8n via (Docker, npm, n8n cloud, desktop app):**
- **Operating system:**

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:

Hey @crwarren06,

This is something we are aware of and we were able to reproduce the issue as well, We have an internal dev ticket to have this fixed which we are tracking as NODE-1192

@n8n @Jon any chance this can be fixed? Its been almost a month

I looked into this and it’s fairly simple to implement this using the HTTP node and the Slack API. Here’s a mini-howto:

Lookup the Slack API Documentation

I looked at Slack’s documentation and found the chat.postMessage documentation.

Key elements from this page:

  1. Method access: POST https://slack.com/api/chat.postMessage
  2. Required scopes: we’ll re-use our existing Slack authentication, so this has already been taken care of.
  3. Content types: application/x-www-form-urlencoded - this defines how to structure the POST request - we’ll see this in our HTTP node settings below.

Arguments:

  1. token - this is listed as required, but I found that when using the oAuth2 authentication you can skip it.
  2. channel - you may already have this as output from your previous nodes. If not, you can get it from the Slack client by right-clicking on the channel name and selecting ‘Copy Link’. This link will look something like https://domain.slack.com/archives/C12345678D - your channel ID would be C12345678D.

image

  1. thread_ts - this contains the timestamp of the message that you want to reply to in-thread. Again, you probably already have this. If not, right-click on a message’s timestamp to copy the link. This link will look like https://domain.slack.com/archives/CHANNEL_ID/p1712219522769369. The numerical part is the timestamp, and it needs to be slightly reformatted to 1712219522.769369 for it to work in the API.

image

Set up the HTTP node

Add an HTTP node and set the fields as shown in the screenshot below!

And it worked!

image

I hope you’ll find this workaround is useful - we realize this is a good feature to add and hope to be able to add this soon-ish.

Also, I’d like to plug our upcoming Community Hangout of April 12 here as this is exactly the kind of thing that we’ll be covering there :slight_smile:

3 Likes

With your settings I get an error from Slack: Parameter “Message Text” is required. How to fix it?

Are you sure you set the ‘text’ field?

{
  "name": "My workflow 2",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "id": "c08d379e-1d25-43a7-ba98-1f5e9290b50a",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "position": [
        1020,
        420
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://slack.com/api/chat.postMessage",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "slackOAuth2Api",
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "name": "channel",
              "value": "C05P9248Z9A"
            },
            {
              "name": "text",
              "value": "test slack threads"
            },
            {
              "name": "thread_ts",
              "value": "1712236600.228599"
            }
          ]
        },
        "options": {}
      },
      "id": "fc478a23-92d8-4f3e-8816-2a029e1d97aa",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        1200,
        420
      ],
      "credentials": {
        "slackOAuth2Api": {
          "id": "Edczc8tWjpgPyn29",
          "name": "Slack account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3d331cb3-4dad-4ef7-8bd5-9c50439d6305",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "2b267d6b882b0c505c5d3101943404470fd73f57d8a82343f52e8e73ae094b21"
  },
  "id": "RQkwquyVwPlqq7uV",
  "tags": []
}```

Oh, sorry, it didn’t work when I tried to test just one module, but it worked when I ran the whole workflow. Thank you very much!!!

1 Like

Awesome, glad to hear it!

1 Like

Awesome thanks @bartv

1 Like

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