Closed mallik30 closed 1 year ago
below is the sample code that executes for all the threads, I tried to use an event.getBotId() but it is null so I can't avoid the response in regular threads.
public void messageEvent() {
app.event(MessageEvent.class, (payload, ctx) -> {
MessageEvent event = payload.getEvent();
// Listen only thread replies, if ThreadTs is present it is a reply
if (event.getThreadTs() != null) {
// my code executes for all thread
}
return ctx.ack();
});
}
Hi @mallik30, thanks for asking the question!
As you've already done, checking the existence of thread_ts in a message is the right way to know if the message is posted in a thread. To know whether your app's bot user is mentioned in the thread, the only feasible way is to call conversations.replies API method and find a string part like <@{your bot's user ID here}>
in the replies' text. To know your bot's user ID, you can call either auth.test API or bots.info API.
I hope this helps.
hi @seratch thank you
bot responding to all threads, I want it to respond only to the thread bot was mentioned
Reproducible in:
The Slack SDK version
attached actual GitHub codebase url above
Java Runtime version
java version "13" 2019-09-17
OS info
(Paste the output of sw_vers && uname -v on macOS/Linux or ver on Windows OS) ProductName: macOS ProductVersion: 13.3.1 ProductVersionExtra: (a) BuildVersion: 22E772610a Darwin Kernel Version 22.4.0: Mon Mar 6 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64
Steps to reproduce:
(Share the commands to run, source code, and project settings (e.g., pom.xml/build.gradle))
Expected result:
respond to only Messages in the thread the bot was mentioned @MyBot create
Actual result:
responds to all thread
Requirements
Please make sure if this topic is specific to this SDK. For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. :bow:
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you agree to those rules.