Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slack - Get thread id after posting message using incoming web hook

I am using slack incoming web hook to post message to a channel. Here is my code

curl -X POST \
  https://hooks.slack.com/services/TXXXXXXXX/BXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX \
  -H 'Content-Type: application/json' \
  -d '{
    "text": "Test message"
}'

I am getting ok as response. I need thread id(thread_ts or ts) to reply to that thread.

How can I get thread id while posting message to slack using incoming web hooks

like image 924
Ijas Ahamed N Avatar asked Feb 03 '23 18:02

Ijas Ahamed N


1 Answers

Webhooks will not return IDs for your message. So you don't get the thread_ts and ts, which you both need to reply as thread.

Its technically possible to find your message through calling conversations.history or if you listen to message events. However, you would need some workaround to reliably match them (e.g. add you own IDs).

In summary: webhooks do not support threads. If you want to do threading you need to post your messages via the API (e.g. chat.postMessage) and not use webhooks. Webhooks are just meant to offer an easy and quick way for posting messages, but they dont't offer the full functionality.

Here is the full guide on threads.

like image 75
Erik Kalkoken Avatar answered May 16 '23 08:05

Erik Kalkoken