I'm dumping my direct messages in Slack. I manage to get all the messages one by one. However I don't find any property that tells which message is a parent message and which ones are replies. How can we get this information?
Typical code in C#
ConversationsListResponse conversationListRespons = await slackClient.GetConversationsListAsync("",false,100,types);
foreach (var channel in conversationListRespons.channels)
{
ConversationsMessageHistory messages = await slackClient.GetConversationsHistoryAsync(channel);
Even when I test the api from the slack interface, it's not giving the information. Are there any other apis than the ones I'm using to get the required information?
Api used: https://api.slack.com/methods/conversations.history
Here is an example: This a main Direct Message with 4 replies. conversations.history returns them without any relationship between them.
The query in slack test interface:
and the result:
{
"ok": true,
"messages": [
{
"type": "message",
"text": "voici un log",
"files": [
{
"id": "F04M6EAEXGX",
"created": 1675280228,
"timestamp": 1675280228,
"name": "32x32.ico",
"title": "32x32.ico",
"mimetype": "application/octet-stream",
"filetype": "binary",
"pretty_type": "Binary",
"user": "U0XNQGD0R",
"user_team": "T0XN0RW8H",
"editable": false,
"size": 4286,
"mode": "hosted",
"is_external": false,
"external_type": "",
"is_public": false,
"public_url_shared": false,
"display_as_bot": false,
"username": "",
"url_private": "https://files.slack.com/files-pri/T0XN0RW8H-F04M6EAEXGX/32x32.ico",
"url_private_download": "https://files.slack.com/files-pri/T0XN0RW8H-F04M6EAEXGX/download/32x32.ico",
"media_display_type": "unknown",
"permalink": "https://sanitized.slack.com/files/U0XNQGD0R/F04M6EAEXGX/32x32.ico",
"permalink_public": "https://slack-files.com/T0XN0RW8H-F04M6EAEXGX-bb8c68eec7",
"is_starred": false,
"has_rich_preview": false,
"file_access": "visible",
"media_progress": null
}
],
"upload": false,
"user": "U0XNQGD0R",
"display_as_bot": false,
"ts": "1675280236.783609",
"blocks": [
{
"type": "rich_text",
"block_id": "Twy",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "voici un log"
}
]
}
]
}
],
"client_msg_id": "5bda3f9c-64a8-4c1b-8b5e-f37c3b2e2c5d"
},
{
"client_msg_id": "850f4ecc-59c0-4af0-b13f-e527ed7a88de",
"type": "message",
"text": "<@U0XNQ04JD> test",
"user": "U0XNQGD0R",
"ts": "1675280205.367429",
"blocks": [
{
"type": "rich_text",
"block_id": "qi/vH",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "user",
"user_id": "U0XNQ04JD"
},
{
"type": "text",
"text": " test"
}
]
}
]
}
],
"team": "T0XN0RW8H"
},
{
"client_msg_id": "e249a07d-f887-4edb-859a-1cc38559dc7b",
"type": "message",
"text": ":100:",
"user": "U0XNQGD0R",
"ts": "1675280190.138859",
"blocks": [
{
"type": "rich_text",
"block_id": "rGp",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "emoji",
"name": "100",
"unicode": "1f4af"
}
]
}
]
}
],
"team": "T0XN0RW8H"
},
{
"client_msg_id": "df2a2f63-21b1-42d5-91db-3c66b083ed7c",
"type": "message",
"text": "yes<https://www.google.com|link to google>",
"user": "U0XNQGD0R",
"ts": "1675280183.929889",
"blocks": [
{
"type": "rich_text",
"block_id": "GZV",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "yes"
},
{
"type": "link",
"url": "https://www.google.com",
"text": "link to google"
}
]
}
]
}
],
"team": "T0XN0RW8H",
"reactions": [
{
"name": "+1",
"users": [
"U0XNQGD0R"
],
"count": 1
}
]
},
{
"client_msg_id": "116e4fc3-ef4a-4148-84ad-975ff0f227e6",
"type": "message",
"text": "Salut Christophe,\nthis is a test for Slack",
"user": "U0XNQGD0R",
"ts": "1675254487.545169",
"blocks": [
{
"type": "rich_text",
"block_id": "O2s",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Salut ,\nthis is a test for Slack"
}
]
}
]
}
],
"team": "T0XN0RW8H"
}
],
"has_more": false,
"is_limited": false,
"pin_count": 0,
"channel_actions_ts": null,
"channel_actions_count": 0
}
To start, there might be some confusion as to what constitutes a reply or thread on Slack. Your first screenshot seems like several "normal" messages posted by the same user one after the other. In Slack a thread is a message posted by selecting the thread icon that corresponds to a parent message as seen in the screenshot.
With that established, you can retrieve threaded messages by making a call to conversations.replies.