slack-ruby-bot
slack-ruby-bot copied to clipboard
Threaded Messaging
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.
There's nothing special in this gem for those, feel free to contribute.
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)
That makes sense @Startouf, feel free to contribute.
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
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.
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.
Doc added in https://github.com/slack-ruby/slack-ruby-bot/commit/162b9e04dffb52fb45c2ff4118e80c009cbf404f