slack-ruby-bot icon indicating copy to clipboard operation
slack-ruby-bot copied to clipboard

Threaded Messaging

Open jonsgreen opened this issue 7 years ago • 7 comments

This is just a general question. Slack finally added threaded messages this year! Is that something that is currently supported by slack-ruby-bot, something in the works or a feature you would be open to getting help on adding to this project?

My particular use case is having a bot match a message and then ask a question back and then capture the response.

jonsgreen avatar Apr 28 '17 13:04 jonsgreen

There's nothing special in this gem for those, feel free to contribute.

dblock avatar Apr 28 '17 14:04 dblock

I would love to have by default all answers be sent to a thread of the original message (or in the same thread if the original message was itself coming from a thread)

Startouf avatar Oct 12 '17 21:10 Startouf

That makes sense @Startouf, feel free to contribute.

dblock avatar Oct 12 '17 23:10 dblock

So actually it is kinda already supported. However I'm only able to get the first response in thread to work "normally". I'm able to keep sending messages in the same thread but it behaves weirdly. I believe this is what they mentionned there https://github.com/slack-ruby/slack-ruby-client/blob/41539c647ac877400f20aa338aa42d2ebfd2866b/lib/slack/web/api/endpoints/chat.rb#L96

EDIT weirdness fixed with thread_ts: (data.thread_ts || ts) instead of just ts

The following sends a response in a thread

  def self.call(client, data, match)
        client.say(
          channel: data.channel,
          text: 'called',
          thread_ts: (data.thread_ts || data.ts)
        )
      end

Startouf avatar Oct 14 '17 15:10 Startouf

Should this just be a README section? Someone care to PR? Another option is to implement client.reply, but I don't like having to pass data in, so some wrapping should be implemented.

dblock avatar Oct 15 '17 21:10 dblock

It would be nice to have threaded response by default, but indeed seeing the code this seems to require more work. I have started something but I must pause due to a deadline.

I'll be able to resume working on my chatbot chatbot in a while, I will try to have some additional PRs about that.

Startouf avatar Oct 18 '17 19:10 Startouf

Doc added in https://github.com/slack-ruby/slack-ruby-bot/commit/162b9e04dffb52fb45c2ff4118e80c009cbf404f

dblock avatar Dec 02 '17 15:12 dblock