os / slacker

Full-featured Python interface for the Slack API
Apache License 2.0
1.6k stars 245 forks source link

How to add a thread message if using slacker #158

Open as3379 opened 5 years ago

as3379 commented 5 years ago

How to find ts_id from a given response. I'm trying to send a message to slack and add a thread to original message. To do so I need the ts_id of the original message. The code looks like:

response = client.chat.post_message(channel=channel, text=message) ts = response['ts'] text = 'Copy into https://codebeautify.org/jsonviewer.' client.chat.post_message( channel=channel, thread_ts=ts, text=text )

However, code fails to retrieve the ts value from response.

GregHilston commented 4 years ago

@as3379 I know this is a very late reply, but I tested out sending a message in a public channel and got this reply:

{'client_msg_id': '6ed12f32-c9fa-4c6f-9bb5-9c5993a78bfa', 'suppress_notification': False, 'type': 'message', 'text': 'test', 'user': 'U389XUHT2', 'team': 'T38AP97Q9', 'blocks': [{'type': 'rich_text', 'block_id': 'N4y3', 'elements': [{'type': 'rich_text_section', 'elements': [{'type': 'text', 'text': 'test'}]}]}], 'source_team': 'T38AP97Q9', 'user_team': 'T38AP97Q9', 'channel': 'C3FAX3UCV', 'event_ts': '1591450995.006800', 'ts': '1591450995.006800'}

Which has your ts as expected