Can a Slack bot get the thread id that a slash command was sent from?
Asked Answered
D

1

11

Suppose a user types a slash command inside a thread, as opposed to inside the main channel.

Is it possible for to include this information in the request sent to the bot? I want the bot to know where exactly the message came from so that it can reply in the same location (i.e. inside the thread and not in the main channel)

Judging by the docs, it seems information about threads is not sent. Here is the POST object that the docs say is sent:

token=gIkuvaNzQIHg97ATvDxqgjtO
&team_id=T0001
&team_domain=example
&enterprise_id=E0001
&enterprise_name=Globular%20Construct%20Inc
&channel_id=C2147483705
&channel_name=test
&user_id=U2147483697
&user_name=Steve
&command=/weather
&text=94070
&response_url=https://hooks.slack.com/commands/1234/5678
&trigger_id=13345224609.738474920.8088930838d88f008e0

Does anyone know if there is a way to do this?

Diao answered 21/8, 2018 at 20:19 Comment(2)
Not sure if slash commands work in threads. Looking at twitter.com/SlackHQ/status/977264888392413186, they didn't work in threads at least a few months ago...Rosiorosita
I believe it is still not possible, but these docs are promising. Just appears custom slash commands are still no welcome inside threads :(Solfatara
G
1

Custom slash commands are not supported within threads. From the documentation:

Limitations on use: Slash Commands cannot be used in message threads. Consider using app shortcuts for this purpose instead.

While the documentation lists app shortcuts as an alternative, you sadly won't receive thread id in the payload from shortcuts, so it's not useful for your issue. You can, however, do some other things based on app shortcuts, such as open a modal, and so on, so there's at least that.

Guanine answered 10/11, 2022 at 9:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.