diff --git a/src/Infrastructure/BotSharp.Abstraction/Conversations/ConversationHookBase.cs b/src/Infrastructure/BotSharp.Abstraction/Conversations/ConversationHookBase.cs
index 1592aa8f..5bceefaf 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Conversations/ConversationHookBase.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Conversations/ConversationHookBase.cs
@@ -67,4 +67,7 @@ public abstract class ConversationHookBase : IConversationHook
public virtual Task OnUserAgentConnectedInitially(Conversation conversation)
=> Task.CompletedTask;
+
+ public virtual Task OnMessageDeleted(string conversationId, string messageId)
+ => Task.CompletedTask;
}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationHook.cs b/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationHook.cs
index 95afaab4..8552aa20 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationHook.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationHook.cs
@@ -84,4 +84,12 @@ public interface IConversationHook
///
///
Task OnHumanInterventionNeeded(RoleDialogModel message);
+
+ ///
+ /// Delete message in a conversation
+ ///
+ ///
+ ///
+ ///
+ Task OnMessageDeleted(string conversationId, string messageId);
}
diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.TruncateMessage.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.TruncateMessage.cs
index 1f1cc8fd..8c82eb1f 100644
--- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.TruncateMessage.cs
+++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.TruncateMessage.cs
@@ -8,6 +8,11 @@ public partial class ConversationService : IConversationService
{
var db = _services.GetRequiredService();
var isSaved = db.TruncateConversation(conversationId, messageId, true);
+ var hooks = _services.GetServices().ToList();
+ foreach (var hook in hooks)
+ {
+ await hook.OnMessageDeleted(conversationId, messageId);
+ }
return await Task.FromResult(isSaved);
}
}
diff --git a/src/Infrastructure/BotSharp.OpenAPI/BotSharpOpenApiExtensions.cs b/src/Infrastructure/BotSharp.OpenAPI/BotSharpOpenApiExtensions.cs
index 0434976e..1ebe6ea5 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/BotSharpOpenApiExtensions.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/BotSharpOpenApiExtensions.cs
@@ -30,7 +30,7 @@ public static class BotSharpOpenApiExtensions
bool enableValidation)
{
services.AddScoped();
- services.AddHostedService();
+ //services.AddHostedService();
// Add bearer authentication
var schema = "MIXED_SCHEME";
diff --git a/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/ChatHubConversationHook.cs b/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/ChatHubConversationHook.cs
index 187c2bf4..045a707a 100644
--- a/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/ChatHubConversationHook.cs
+++ b/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/ChatHubConversationHook.cs
@@ -96,4 +96,14 @@ public class ChatHubConversationHook : ConversationHookBase
await base.OnResponseGenerated(message);
}
+
+ public override async Task OnMessageDeleted(string conversationId, string messageId)
+ {
+ await _chatHub.Clients.User(_user.Id).SendAsync("OnMessageDeleted", new ChatResponseModel
+ {
+ ConversationId = conversationId,
+ MessageId = messageId
+ });
+ await base.OnMessageDeleted(conversationId, messageId);
+ }
}