Skip to content

Add file_ids to ChatUpdateMessageParams - #475

Merged
kbasutkar-hubspot merged 2 commits into
masterfrom
kbasutkar/chat-update-file-ids
Sep 28, 2026
Merged

kbasutkar-hubspot merged 2 commits into
masterfrom
kbasutkar/chat-update-file-ids

Conversation

@kbasutkar-hubspot

Copy link
Copy Markdown
Contributor

What

Adds file_ids to ChatUpdateMessageParams, matching the chat.update argument ("Array of new file ids that will be sent with this message").

Why

To attach a file to an existing bot message instead of posting it as a separate message:

  1. Upload with files.getUploadURLExternal + files.completeUploadExternal without channel_id. The file stays private and no message is posted.
  2. chat.update the target message with file_ids.

Verified against the Slack API: the file renders inside the updated message with its inline preview, and other channel members can open it. Note that Slack replaces the message's blocks on update, so callers must re-send the existing blocks along with file_ids (sending only text + file_ids drops them). This is documented on the getter.

Compatibility

chat.update is JSON-encoded, so the list serializes as a JSON array. The class uses @JsonInclude(NON_EMPTY), so an empty list is omitted and existing callers send the same payload as before.

Tests

ChatUpdateMessageParamsSerializationTest covers the array serialization and the omitted-when-empty case. MessageParamsTest still passes.

🤖 Generated with Claude Code

chat.update accepts file_ids to attach already-uploaded files to an
existing message. Files uploaded via files.completeUploadExternal with
no channel_id stay private and post no message, so this lets callers
attach a file to a bot response in place instead of posting a separate
file message. Empty lists are omitted, so existing callers are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* IDs of already-uploaded files to attach to the message. Upload them without a channel
* (files.completeUploadExternal with no channel_id) so Slack doesn't post a separate file
* message. Slack replaces the message's blocks on update, so re-send the existing blocks too.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: check() still requires text/attachments/blocks even when only file_ids is set, but Slack doesn’t require that for file_ids alone. Probably fine in practice since callers already have to re-send blocks (per the javadoc above), just flagging in case a file_ids-only update is a valid use case you want to support.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good flag. I left it as is on purpose. When I tested chat.update with just text + file_ids, Slack replaced the message's blocks with a plain rich_text block (buttons and context gone), so a files-only update would wipe the rest of the message. Keeping the check nudges callers to re-send blocks, which the Javadoc says is required. I haven't tried a file_ids-only update with no text, but it isn't a use case we need. Happy to relax it if you think it's worth supporting.

Matches newer params (StreamParams.getChunks, ChatStopStreamParams).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kbasutkar-hubspot
kbasutkar-hubspot merged commit f2b3829 into master Sep 28, 2026
2 checks passed
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