diff --git a/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailSenderFn.cs b/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailSenderFn.cs index f4be0628a..a459295cd 100644 --- a/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailSenderFn.cs +++ b/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailSenderFn.cs @@ -29,7 +29,7 @@ public HandleEmailSenderFn( public async Task Execute(RoleDialogModel message) { var args = JsonSerializer.Deserialize(message.FunctionArgs, _options.JsonSerializerOptions); - var recipient = args?.ToAddress; + var recipients = args?.ToAddresses?.Where(x => !string.IsNullOrWhiteSpace(x)) ?? []; var body = args?.Content; var subject = args?.Subject; var isNeedAttachments = args?.IsNeedAttachemnts ?? false; @@ -39,7 +39,12 @@ public async Task Execute(RoleDialogModel message) { var mailMessage = new MimeMessage(); mailMessage.From.Add(new MailboxAddress(_emailSettings.Name, _emailSettings.EmailAddress)); - mailMessage.To.Add(new MailboxAddress("", recipient)); + + foreach (var recipient in recipients) + { + mailMessage.To.Add(new MailboxAddress("", recipient)); + } + mailMessage.Subject = subject; bodyBuilder.TextBody = body; @@ -53,7 +58,7 @@ public async Task Execute(RoleDialogModel message) var response = await SendEmailBySMTP(mailMessage); message.Content = response; - _logger.LogWarning($"Email successfully send over to {recipient}. Email Subject: {subject} [{response}]"); + _logger.LogWarning($"Email successfully send over to {string.Join(",", recipients)}. Email Subject: {subject} [{response}]"); return true; } catch (Exception ex) diff --git a/src/Plugins/BotSharp.Plugin.EmailHandler/LlmContexts/LlmContextIn.cs b/src/Plugins/BotSharp.Plugin.EmailHandler/LlmContexts/LlmContextIn.cs index ce040597b..68f77c8c3 100644 --- a/src/Plugins/BotSharp.Plugin.EmailHandler/LlmContexts/LlmContextIn.cs +++ b/src/Plugins/BotSharp.Plugin.EmailHandler/LlmContexts/LlmContextIn.cs @@ -4,8 +4,8 @@ namespace BotSharp.Plugin.EmailHandler.LlmContexts; public class LlmContextIn { - [JsonPropertyName("to_address")] - public string? ToAddress { get; set; } + [JsonPropertyName("to_address_list")] + public IEnumerable? ToAddresses { get; set; } [JsonPropertyName("email_content")] public string? Content { get; set; } diff --git a/src/Plugins/BotSharp.Plugin.EmailHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/util-email-handle_email_sender.json b/src/Plugins/BotSharp.Plugin.EmailHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/util-email-handle_email_sender.json index b1ebfb730..709927ad8 100644 --- a/src/Plugins/BotSharp.Plugin.EmailHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/util-email-handle_email_sender.json +++ b/src/Plugins/BotSharp.Plugin.EmailHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/util-email-handle_email_sender.json @@ -4,9 +4,12 @@ "parameters": { "type": "object", "properties": { - "to_address": { - "type": "string", - "description": "The email address to which the email should be sent to. It needs to be a valid email address in the correct string format." + "to_address_list": { + "type": "array", + "description": "The email addresses to which the email should be sent. Each item needs to be a valid and unique email address in the correct string format.", + "items": { + "type": "string" + } }, "email_content": { "type": "string", @@ -21,6 +24,6 @@ "description": "If the user request to send email with attachemnt(s) or file(s), then this value should be True. Otherwise, this value should be False." } }, - "required": [ "to_address", "email_content", "subject", "is_need_attachments" ] + "required": [ "to_address_list", "email_content", "subject", "is_need_attachments" ] } } \ No newline at end of file