Skip to content

Add thread reply support with optional thread-ts parameter#10

Merged
alexec merged 7 commits intomainfrom
copilot/add-reply-functionality
Oct 31, 2025
Merged

Add thread reply support with optional thread-ts parameter#10
alexec merged 7 commits intomainfrom
copilot/add-reply-functionality

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 31, 2025

Enables replying to messages in Slack threads using an optional thread-ts parameter on the send-message command. When sending a new message, the thread-ts is printed in the output to enable thread continuation.

Changes

  • CLI: Extended send-message <channel|email> <message> [thread-ts] with optional thread-ts parameter

    • When thread-ts is provided, message is sent as a threaded reply to the parent message
    • Uses slack.MsgOptionTS() to set thread timestamp
    • Reuses email resolution and Markdown conversion logic
    • Prints the thread-ts only when sending a new message (not when replying to a thread)
  • MCP Server: Updated send_message tool with optional thread_ts parameter

    • Returns the thread-ts in the response text for new messages only
  • Tests: Added validation for missing arguments and token handling

Usage

# Send a new message (thread-ts is printed)
slack send-message user@example.com "Hello!"
# Output:
# Message sent to user@example.com (U12345678)
# thread-ts: 1234567890.123456

# Reply to a message in a thread (no thread-ts printed)
slack send-message user@example.com "Thanks for the feedback!" "1234567890.123456"
# Output:
# Reply sent to user@example.com (U12345678) in thread 1234567890.123456
# MCP tool - new message
{
  "identifier": "user@example.com",
  "message": "Hello!"
}
# Response: "Message sent successfully to user@example.com\nthread-ts: 1234567890.123456"

# MCP tool - thread reply
{
  "identifier": "user@example.com",
  "message": "Thanks for the feedback!",
  "thread_ts": "1234567890.123456"
}
# Response: "Reply sent successfully to user@example.com in thread 1234567890.123456"

The thread-ts is Slack's unique message identifier (timestamp). When omitted as a parameter, a new message is sent and the thread-ts is printed; when provided, the message becomes a threaded reply to that parent message.

Original prompt

We need a way to reply to a message sent from a user. How might we do that?


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 31, 2025 03:31
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copilot AI changed the title [WIP] Add reply functionality to user messages Add reply-message command for Slack thread support Oct 31, 2025
Copilot AI requested a review from alexec October 31, 2025 03:34
@alexec
Copy link
Copy Markdown
Contributor

alexec commented Oct 31, 2025

@copilot what about send-message <email|channel> message [reply-to-timestamp]?

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 31, 2025

@copilot what about send-message <email|channel> message [reply-to-timestamp]?

Refactored to use send-message <channel|email> <message> [timestamp] as suggested. The timestamp is now an optional third parameter, making the interface simpler. Changes in commit e54e51a:

  • Removed separate reply-message command
  • Consolidated sendMessage() and replyMessage() into single function
  • Updated MCP server to use single send_message tool with optional timestamp parameter
  • Updated tests and documentation

CLI Usage:

# Send a message
slack send-message user@example.com "Hello!"

# Reply to a message
slack send-message user@example.com "Thanks!" "1234567890.123456"

Help output:

Usage:
  slack configure                                          - configure Slack token (reads from stdin)
  slack send-message <channel|email> <message> [timestamp] - send a message to a user (optionally as a reply)
  slack mcp-server                                         - start MCP server (Model Context Protocol)

Copilot AI changed the title Add reply-message command for Slack thread support Add thread reply support with optional timestamp parameter Oct 31, 2025
Copy link
Copy Markdown
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it clear, lets call it [thread-ts]. Make it clear in the docs this is for replying to message thread. @copilot

@alexec
Copy link
Copy Markdown
Contributor

alexec commented Oct 31, 2025

@copilot please address my comment above.

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 31, 2025

To make it clear, lets call it [thread-ts]. Make it clear in the docs this is for replying to message thread. @copilot

Updated in commit efc3a49. Changed parameter name to [thread-ts] and clarified in documentation that it's for replying to message threads.

CLI Usage:

Usage:
  slack configure                                            - configure Slack token (reads from stdin)
  slack send-message <channel|email> <message> [thread-ts]   - send a message (optionally reply to a thread)
  slack mcp-server                                           - start MCP server (Model Context Protocol)

MCP Tool Parameter:

  • thread_ts - Optional: The thread timestamp of the parent message to reply to (e.g., '1234567890.123456'). When provided, the message will be sent as a threaded reply.

Example:

# Reply to a message in a thread (thread-ts is the timestamp of the parent message)
slack send-message user@example.com "Thanks for the feedback!" "1234567890.123456"

@copilot please address my comment above.

Done in commit efc3a49. The parameter is now called [thread-ts] and the documentation clearly states it's for replying to message threads.

Copilot AI changed the title Add thread reply support with optional timestamp parameter Add thread reply support with optional thread-ts parameter Oct 31, 2025
Copilot AI requested a review from alexec October 31, 2025 03:57
@alexec
Copy link
Copy Markdown
Contributor

alexec commented Oct 31, 2025

@copilot please print the of the message once sent so that the the user can note the and reply to it.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 31, 2025

@copilot please print the of the message once sent so that the the user can note the and reply to it.

The comment appears to be incomplete. Could you please clarify what you'd like me to print?

@alexec
Copy link
Copy Markdown
Contributor

alexec commented Oct 31, 2025

@copilot when the message has been sent, print the thread-ts from the response, no the next send-message can continue the thread.

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 31, 2025

@copilot when the message has been sent, print the thread-ts from the response, no the next send-message can continue the thread.

Implemented in commit f067cda. The thread-ts is now printed after every message is sent, allowing you to use it to continue the conversation in a thread.

CLI Output:

$ slack send-message user@example.com "Hello!"
Message sent to user@example.com (U12345678)
thread-ts: 1234567890.123456

$ slack send-message user@example.com "Reply!" "1234567890.123456"
Reply sent to user@example.com (U12345678) in thread 1234567890.123456
thread-ts: 1234567890.654321

MCP Server:
The MCP tool also returns the thread-ts in its response:

Message sent successfully to user@example.com
thread-ts: 1234567890.123456

This allows subsequent messages to continue the thread by using the returned thread-ts.

@alexec
Copy link
Copy Markdown
Contributor

alexec commented Oct 31, 2025

@copilot this is a bit more complex that I'd like. When sending a message without the thread-ts, you must print the thread-ts. However, if you reply to a thread, do not print the timestamp as it will not change.

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 31, 2025

@copilot this is a bit more complex that I'd like. When sending a message without the thread-ts, you must print the thread-ts. However, if you reply to a thread, do not print the timestamp as it will ...

Simplified in commit 07b1b1a. The thread-ts is now only printed when sending a new message (without thread-ts parameter), not when replying to a thread.

New message output:

$ slack send-message user@example.com "Hello!"
Message sent to user@example.com (U12345678)
thread-ts: 1234567890.123456

Thread reply output (no thread-ts printed):

$ slack send-message user@example.com "Reply!" "1234567890.123456"
Reply sent to user@example.com (U12345678) in thread 1234567890.123456

MCP Server:

  • New message: includes thread-ts in response
  • Thread reply: no thread-ts in response

@alexec alexec marked this pull request as ready for review October 31, 2025 04:25
@alexec alexec merged commit 81125da into main Oct 31, 2025
1 check passed
@alexec alexec deleted the copilot/add-reply-functionality branch October 31, 2025 04:25
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

Successfully merging this pull request may close these issues.

2 participants