using BotSharp.Abstraction.Messaging; using BotSharp.Abstraction.Messaging.Models.RichContent; namespace BotSharp.Core.Messaging; public class RichContentService : IRichContentService { public List ConvertToMessages(string content) { var messages = new List(); var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; var tempMessages = JsonSerializer.Deserialize(content, options); foreach (var m in tempMessages) { var richType = "text"; if (m.RootElement.TryGetProperty("rich_type", out var element)) { richType = element.GetString(); } if (richType == "text") { messages.Add(JsonSerializer.Deserialize(m.RootElement.ToString(), options)); } else if (richType == "quick_reply") { messages.Add(JsonSerializer.Deserialize(m.RootElement.ToString(), options)); } } return messages.ToList(); } }