question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't send a thread_ts using RTM sendMessage

See original GitHub issue
  • I’ve read and understood the Contributing guidelines and have done my best effort to follow them.
  • I’ve read and agree to the Code of Conduct.
  • I’ve searched for any related issues and avoided creating a duplicate issue.

Hey with the recent threading feature, the docs say you should send the thread_ts through the RTM however you do not allow sending any options through your sendMessage function.

RTMClient.prototype.sendMessage = function sendMessage(text, channelId, optCb) {
  return this.send({
    text: text,
    channel: channelId,
    type: RTM_API_EVENTS.MESSAGE
  }, optCb);
};

I will use the API in the meantime to respond to thread_ts messages however allowing us to send a thread_ts through this function would be ideal.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
aoberoicommented, Aug 3, 2018

@bastienrobert I’m glad you asked! I overlooked the fact that the API of RTMClient has changed quite a bit since the messages above, specifically the v3.x to v4.x transition. That guidance is no longer valid, so allow me to provide a working example:

// Before: sending a simple text message
rtm
  .sendMessage('Poke', conversationId)
  .then(res => console.log(`Message sent: ${res}`)
  .catch(console.error);

// After: sending a simple text message in a specific thread
rtm
  .addOutgoingEvent(true, 'message', { text: 'Poke', channel: conversationId, thread_ts: parent_ts })
  .then(res => console.log(`Message sent: ${res}`)
  .catch(console.error);

In the above example, parent_ts is the ts of the root message of the thread.

3reactions
jasonTheNorriscommented, Jan 26, 2017

Hello @Js41637!

You are correct that sendMessage does not support additional options. sendMessage is intended to be a dead simple wrapper for the most common use case of send.

But there is still hope! You can use send to reply to a thread via the RTM. Porting your current code over to something like this should take care of business:

var RTM_EVENTS = require('@slack/client').RTM_EVENTS;

client.send({
    text:      text,
    channel:   channelId,
    thread_ts: thread_ts,
    type:      RTM_EVENTS.MESSAGE,
});

Give that a try and let us know if you run in to any more issues!

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - TypeError: Cannot read property 'sendMessage' of null
I found my error, I had rtm as a const and then a let. So I removed the const from rtm = new...
Read more >
Signaling Release notes - Agora Documentation
The getServerReceivedTs method of the RtmMessage object supports both peer-to-peer and channel messages. Timeout for sending a peer-to-peer message is 10 ...
Read more >
Real Time Messaging API - Slack Platform Developer Tools
Apps typically connect to the RTM API using a bot token, which start with xoxb . ... sendMessage(text, conversationId) method for sending messages...
Read more >
Real Time Messaging — python-slackclient 1.0.1 documentation
See Threading messages for more details on using threads. The RTM API only supports posting messages with basic formatting. It does not support...
Read more >
slack - Go Packages
This is the original Slack library for Go created by Norberto Lopes, transferred to a GitHub organization. You can also chat with us...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found