diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs index 91422eaeb..30206aa72 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs @@ -17,6 +17,7 @@ public class ElementButton public string Title { get; set; } = string.Empty; [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [Translate] public string Payload { get; set; } [JsonPropertyName("is_primary")] @@ -30,5 +31,6 @@ public class ElementButton [JsonPropertyName("post_action_disclaimer")] [JsonProperty("post_action_disclaimer")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [Translate] public string? PostActionDisclaimer { get; set; } } diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs index 015ca81a2..0306ccafa 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs @@ -130,7 +130,7 @@ private async Task HandleAssistantMessage(RoleDialogModel response, Func template && string.IsNullOrEmpty(template.Message.Text)) { - template.Message.Text = response.Content; + template.Message.Text = response.SecondaryContent ?? response.Content; } // Only read content from RichContent for UI rendering. When richContent is null, create a basic text message for richContent. @@ -138,7 +138,7 @@ response.RichContent is RichContent template && response.RichContent = response.RichContent ?? new RichContent { Recipient = new Recipient { Id = state.GetConversationId() }, - Message = new TextMessage(response.Content) + Message = new TextMessage(response.SecondaryContent ?? response.Content) }; // Patch return function name diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs index a1f61fb6c..36fb21be6 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs @@ -162,7 +162,7 @@ await hook.OnRoutingInstructionReceived(inst, message) } else { - response.Content = await translator.Translate(_router, + response.SecondaryContent = await translator.Translate(_router, message.MessageId, response.Content, language: inst.Language);