Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get ts of posted message, so it is possible to reply to it #91

Open
bence-nagy opened this issue Feb 8, 2021 · 6 comments
Open

Get ts of posted message, so it is possible to reply to it #91

bence-nagy opened this issue Feb 8, 2021 · 6 comments

Comments

@bence-nagy
Copy link

bence-nagy commented Feb 8, 2021

Consider the following use case:
A bot wants to post subsequent messages into a single thread within a slack channel.
So the first message would be a normal message, further messages would be thread replies to that message.

For this to work - as far as I can tell - you would need to get the identifier (which seems to be the ts property) of the first posted message. The slack API returns this information (see the documentation) in the form of "ts": "1503435956.000247".

If I had the value of that property then I could construct message objects with theirThreadId property set to the value returned by the first posted message, but this wrapper does not seems to expose that returned property.

The Post methods only seem to return with a bool (or a Task<bool>) and it seems that they do not modify the passed SlackMessage object, so the returned ts value is simply discarded. Is it so or am I missing something?

Would it be possible to somehow expose the ts property of a message once posted? Either via returning it from the Post methods or maybe storing it in the message object passed to the methods - so mutating the passed argument?

Or is there any workaround I can use? (Apart from using the slack API directly - which is of course a solution to my problem.)

Thanks in advance.

@mrb0nj
Copy link
Owner

mrb0nj commented Feb 8, 2021

Hey, you can get if you copy the link to the message and extract the ID from the end of the URL. example:

https://[yourdomain].slack.com/archives/C6JPLL60L/p1582740873000100
------------------------------------------------------------------------^^^^^^^^^^^^^^^^^^^

becomes: 1582740873.000100

hope that helps.

@mrb0nj
Copy link
Owner

mrb0nj commented Feb 8, 2021

Sorry, I only really addressed part of your question here...

chat.postMessage that you've linked to is not the API method that is being called as part of SlackClient.Post.

Posting to the webhook URL, sadly, does not return the ThreadId in the same way.

I started some time ago implementing the API https://github.com/mrb0nj/Slack.Webhooks/blob/feature/api/src/Slack.Webhooks/Chat/ChatClient.cs but this branch is massively different to the current implementation of this library.

@bence-nagy
Copy link
Author

Thanks for the replies and for clarifying that the webhook's post uses a different API method, now I get why this property is not returned.

Do you have a rough estimation about when the mentioned branch will be ready? Or is already in a state that I could try it out? Do you plan to create a (beta) nuget package from it?

Either way, thanks for the great package 👍

@danilobassi8
Copy link

Any updates?

@givanytska
Copy link

we need this too!

@gergokee
Copy link

we also need this functionality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants