Skip to content

Commit 89c62bf

Browse files
author
Yanan Wang
committed
Default RichContent
1 parent e43b3e6 commit 89c62bf

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using BotSharp.Abstraction.Agents.Models;
2+
using BotSharp.Abstraction.Messaging.Models.RichContent;
23
using BotSharp.Abstraction.Routing;
34
using BotSharp.Abstraction.Routing.Settings;
45
using System.Drawing;
@@ -100,6 +101,15 @@ private async Task HandleAssistantMessage(RoleDialogModel message, Func<RoleDial
100101
_logger.LogInformation(text);
101102
#endif
102103

104+
// Only read content from RichContent for UI rendering. When richContent is null, create a basic text message for richContent.
105+
var state = _services.GetRequiredService<IConversationStateService>();
106+
message.RichContent = message.RichContent ?? new RichContent<TextMessage>
107+
{
108+
Recipient = new Recipient { Id = state.GetConversationId() },
109+
MessageingType = "RESPONSE",
110+
Message = new TextMessage { Text = message.Content }
111+
};
112+
103113
var hooks = _services.GetServices<IConversationHook>().ToList();
104114
foreach (var hook in hooks)
105115
{

0 commit comments

Comments
 (0)