From 0bb98a19e51564e8dbdad5fb58c7f994258d2405 Mon Sep 17 00:00:00 2001
From: 103048 <103048@MJ0AJ7XO-LNPC>
Date: Wed, 31 Jul 2024 15:54:39 -0500
Subject: [PATCH] code improvement
---
.../BotSharp.Plugin.EmailHandler.csproj | 5 ++++-
.../Functions/HandleEmailReaderFn.cs | 16 ++++++++++++++--
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/Plugins/BotSharp.Plugin.EmailHandler/BotSharp.Plugin.EmailHandler.csproj b/src/Plugins/BotSharp.Plugin.EmailHandler/BotSharp.Plugin.EmailHandler.csproj
index fb241175..f5926a53 100644
--- a/src/Plugins/BotSharp.Plugin.EmailHandler/BotSharp.Plugin.EmailHandler.csproj
+++ b/src/Plugins/BotSharp.Plugin.EmailHandler/BotSharp.Plugin.EmailHandler.csproj
@@ -14,6 +14,7 @@
+
@@ -30,6 +31,9 @@
PreserveNewest
+
+ PreserveNewest
+
@@ -37,7 +41,6 @@
-
diff --git a/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailReaderFn.cs b/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailReaderFn.cs
index 964ce028..121638e7 100644
--- a/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailReaderFn.cs
+++ b/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailReaderFn.cs
@@ -5,7 +5,6 @@ using BotSharp.Abstraction.MLTasks;
using BotSharp.Core.Infrastructures;
using BotSharp.Plugin.EmailHandler.Models;
using BotSharp.Plugin.EmailHandler.Providers;
-using BusinessCore.Utils;
using MailKit;
using MailKit.Net.Imap;
using MailKit.Search;
@@ -85,7 +84,7 @@ public class HandleEmailReaderFn : IFunctionCallback
var response = await completion.GetChatCompletions(agent, dialogs);
var content = response?.Content ?? string.Empty;
message.Content = content;
- message.RichContent = BuildRichContent.TextPostBackRichContent(_state.GetConversationId(), message.Content);
+ message.RichContent = BuildRichContentForSummary(_state.GetConversationId(), message.Content);
return true;
}
UniqueId.TryParse(messageId, out UniqueId uid);
@@ -105,6 +104,19 @@ public class HandleEmailReaderFn : IFunctionCallback
return false;
}
}
+ public RichContent BuildRichContentForSummary(string conversationId, string content, string editorType = EditorTypeEnum.Text)
+ {
+ return new RichContent()
+ {
+ FillPostback = true,
+ Editor = editorType,
+ Recipient = new Recipient() { Id = conversationId },
+ Message = new ButtonTemplateMessage()
+ {
+ Text = content,
+ }
+ };
+ }
private RichContent BuildRichContentForSubject(List emailSubjects)
{
var text = "Please let me know which message I need to read?";