From aaeea6c9bf0aa2ed280e755a6d5e1ee957396658 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Wed, 28 Jan 2026 16:47:04 +0400 Subject: [PATCH] feat: Display story replies with attachment and context label (#13356) Fixes https://github.com/chatwoot/chatwoot/issues/13354 Fixes https://linear.app/chatwoot/issue/CW-6394/story-responses-are-not-being-shown-in-the-ui When someone replies to your Instagram story, agents in Chatwoot only see the reply text with no story image and no indication that it was a story reply. This makes it impossible to understand what the customer is responding to the message looks like a random text with no context. For example, if a customer replies "Love this!" to your story, the agent just sees "Love this!" with no way to know which story triggered the conversation. This PR fixes the issue by storing the story attachment and adding a context label. CleanShot 2026-01-27 at 19 19
38@2x --- .../instagram/base_message_builder.rb | 19 ++++++++++++++++ .../components-next/message/Message.vue | 1 + .../message/bubbles/InstagramStory.vue | 14 ++++++++++-- .../components-next/message/constants.js | 1 + .../dashboard/i18n/locale/en/settings.json | 3 ++- .../instagram/message_builder_spec.rb | 22 +++++-------------- .../messenger/message_builder_spec.rb | 8 ++++++- 7 files changed, 48 insertions(+), 20 deletions(-) diff --git a/app/builders/messages/instagram/base_message_builder.rb b/app/builders/messages/instagram/base_message_builder.rb index 8b40ba3c9..818c217ca 100644 --- a/app/builders/messages/instagram/base_message_builder.rb +++ b/app/builders/messages/instagram/base_message_builder.rb @@ -112,6 +112,25 @@ class Messages::Instagram::BaseMessageBuilder < Messages::Messenger::MessageBuil return if story_reply_attributes.blank? @message.save_story_info(story_reply_attributes) + create_story_reply_attachment(story_reply_attributes['url']) + end + + def create_story_reply_attachment(story_url) + return if story_url.blank? + + attachment = @message.attachments.new( + file_type: :ig_story, + account_id: @message.account_id, + external_url: story_url + ) + attachment.save! + begin + attach_file(attachment, story_url) + rescue Down::Error, StandardError => e + Rails.logger.warn "Failed to download Instagram story attachment: #{e.message}" + end + @message.content_attributes[:image_type] = 'ig_story_reply' + @message.save! end def build_conversation diff --git a/app/javascript/dashboard/components-next/message/Message.vue b/app/javascript/dashboard/components-next/message/Message.vue index 6fa7ff2b2..c4ae45fef 100644 --- a/app/javascript/dashboard/components-next/message/Message.vue +++ b/app/javascript/dashboard/components-next/message/Message.vue @@ -303,6 +303,7 @@ const componentToRender = computed(() => { const instagramSharedTypes = [ ATTACHMENT_TYPES.STORY_MENTION, ATTACHMENT_TYPES.IG_STORY, + ATTACHMENT_TYPES.IG_STORY_REPLY, ATTACHMENT_TYPES.IG_POST, ]; if (instagramSharedTypes.includes(props.contentAttributes.imageType)) { diff --git a/app/javascript/dashboard/components-next/message/bubbles/InstagramStory.vue b/app/javascript/dashboard/components-next/message/bubbles/InstagramStory.vue index f167d6501..5c3bfc2f6 100644 --- a/app/javascript/dashboard/components-next/message/bubbles/InstagramStory.vue +++ b/app/javascript/dashboard/components-next/message/bubbles/InstagramStory.vue @@ -1,19 +1,26 @@