RocketChat / docs-old

Rocket.Chat's user documentation.
https://docs.rocket.chat
335 stars 769 forks source link

How do you post a message to a thread via API? #2083

Closed albertodiazdorado closed 2 years ago

albertodiazdorado commented 2 years ago

This is nowhere to be found in the documentation, although I would think that it is a very basic feature. Hence, I am wondering whether that feature is not documented, or whether it does not exist.

Is it possible to use the RocketChat API to write messages to a particular thread?

Faria1212 commented 2 years ago

Yes, you just need the ID of the message that started the thread. (https://github.com/RocketChat/Rocket.Chat/blob/develop/apps/meteor/app/lib/server/methods/sendMessage.js) Some lines refer to validations regarding tmid. tmid is the field that refers to the main message ID that opens the thread. Due to some internal reason, we have temporarily removed the documentation of this endpoint. We will soon be adding it to developer.rocket.chat

albertodiazdorado commented 1 year ago

Nice, thanks! :D

albertodiazdorado commented 1 year ago

So, for anyone hitting this thread, I will provide the meaningful information that you are looking for

response=$(curl -d '{"channel":"my-channel","text":"this is the main message"}' -H $user_header -H $token_header $rocketchat_url)

tmid=$(echo $response | jq .message._id)

curl -d '{"channel":"my-channel","text":"this goes to a thread","tmid":$tmid}' -H $user_header -H $token_header $rocketchat_url

I do not get why this is not the first example of the docs, but alas, here you go.