From 46710c14cc5fda5d1a7e4836e7e00762dbe94a0f Mon Sep 17 00:00:00 2001
From: Yanan Wang <103942@smsassist.com>
Date: Fri, 27 Oct 2023 14:05:18 -0500
Subject: [PATCH 01/10] Add richContent for future UI rendering
---
.../BotSharp.Abstraction.csproj | 4 ----
.../Conversations/IConversationStateService.cs | 1 +
.../Conversations/Models/RoleDialogModel.cs | 2 ++
.../Models/RichContent/QuickReplyElement.cs | 13 +++++++++++++
.../Models/RichContent/QuickReplyMessage.cs | 9 +++++++++
.../Messaging/Models/RichContent/Recipient.cs | 8 ++++++++
.../Messaging/Models/RichContent/RichContent.cs | 13 +++++++++++++
.../RichContent/Template/AttachmentTemplate.cs | 9 +++++++++
.../RichContent/Template/ButtonTemplate.cs | 16 ++++++++++++++++
.../RichContent/Template/CommonTemplate.cs | 9 +++++++++
.../RichContent/Template/TemplateMessage.cs | 11 +++++++++++
.../Messaging/Models/RichContent/TextMessage.cs | 8 ++++++++
.../Services/ConversationStateService.cs | 2 ++
.../Controllers/ConversationController.cs | 2 ++
.../Conversations/MessageResponseModel.cs | 1 +
15 files changed, 104 insertions(+), 4 deletions(-)
create mode 100644 src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs
create mode 100644 src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyMessage.cs
create mode 100644 src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Recipient.cs
create mode 100644 src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs
create mode 100644 src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/AttachmentTemplate.cs
create mode 100644 src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplate.cs
create mode 100644 src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/CommonTemplate.cs
create mode 100644 src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/TemplateMessage.cs
create mode 100644 src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/TextMessage.cs
diff --git a/src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj b/src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj
index 18ddee55..ba1ea69d 100644
--- a/src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj
+++ b/src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj
@@ -31,8 +31,4 @@
-
-
-
-
diff --git a/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationStateService.cs b/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationStateService.cs
index 26655e2b..07b713c9 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationStateService.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationStateService.cs
@@ -5,6 +5,7 @@ namespace BotSharp.Abstraction.Conversations;
///
public interface IConversationStateService
{
+ string GetConversationId();
ConversationState Load(string conversationId);
string GetState(string name, string defaultValue = "");
bool ContainsState(string name);
diff --git a/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs b/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs
index ae798160..fcfada99 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs
@@ -27,6 +27,8 @@ public class RoleDialogModel
///
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public object Data { get; set; }
+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
+ public object? RichContent { get; set; }
///
/// Stop conversation completion
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs
new file mode 100644
index 00000000..15a07d23
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs
@@ -0,0 +1,13 @@
+
+namespace BotSharp.Abstraction.Messaging.Models.RichContent
+{
+ public class QuickReplyElement
+ {
+ [JsonPropertyName("content_type")]
+ public string ContentType { get; set; } = string.Empty;
+ public string Title { get; set; } = string.Empty;
+ public string? Payload { get; set; }
+ [JsonPropertyName("image_url")]
+ public string? ImageUrl { get; set; }
+ }
+}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyMessage.cs
new file mode 100644
index 00000000..b14b27e1
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyMessage.cs
@@ -0,0 +1,9 @@
+
+namespace BotSharp.Abstraction.Messaging.Models.RichContent
+{
+ public class QuickReplyMessage : TextMessage
+ {
+ [JsonPropertyName("quick_replies")]
+ public List QuickReplies { get; set; } = new List();
+ }
+}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Recipient.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Recipient.cs
new file mode 100644
index 00000000..7bfbba8e
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Recipient.cs
@@ -0,0 +1,8 @@
+
+namespace BotSharp.Abstraction.Messaging.Models.RichContent
+{
+ public class Recipient
+ {
+ public string? Id { get; set; }
+ }
+}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs
new file mode 100644
index 00000000..69224e42
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs
@@ -0,0 +1,13 @@
+namespace BotSharp.Abstraction.Messaging.Models.RichContent
+{
+ public class RichContent
+ {
+ public Recipient? Recipient { get; set; }
+ ///
+ /// RESPONSE
+ ///
+ [JsonPropertyName("messaging_type")]
+ public string MessageingType { get; set; } = string.Empty;
+ public T Message { get; set; }
+ }
+}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/AttachmentTemplate.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/AttachmentTemplate.cs
new file mode 100644
index 00000000..89f2137e
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/AttachmentTemplate.cs
@@ -0,0 +1,9 @@
+
+namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template
+{
+ public class AttachmentTemplate
+ {
+ public string Type => "template";
+ public T Payload { get; set; }
+ }
+}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplate.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplate.cs
new file mode 100644
index 00000000..e9817729
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplate.cs
@@ -0,0 +1,16 @@
+
+namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template
+{
+ public class ButtonTemplate : TextMessage
+ {
+ public string TemplateType => "button";
+ public List Buttons { get; set; } = new List();
+ }
+
+ public class ButtonElement
+ {
+ public string? Type { get; set; }
+ public string? Url { get; set; }
+ public string? Title { get; set; }
+ }
+}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/CommonTemplate.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/CommonTemplate.cs
new file mode 100644
index 00000000..ace1daac
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/CommonTemplate.cs
@@ -0,0 +1,9 @@
+
+namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template
+{
+ public class CommonTemplate
+ {
+ public string TemplateType { get; set; } = string.Empty;
+ public T Elements { get; set; }
+ }
+}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/TemplateMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/TemplateMessage.cs
new file mode 100644
index 00000000..21b8d339
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/TemplateMessage.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template
+{
+ public class TemplateMessage
+ {
+ public AttachmentTemplate Attachment { get; set; }
+ }
+}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/TextMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/TextMessage.cs
new file mode 100644
index 00000000..bed603a2
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/TextMessage.cs
@@ -0,0 +1,8 @@
+
+namespace BotSharp.Abstraction.Messaging.Models.RichContent
+{
+ public class TextMessage
+ {
+ public string? Text { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs
index 1f0fe199..7004b929 100644
--- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs
+++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs
@@ -28,6 +28,8 @@ public class ConversationStateService : IConversationStateService, IDisposable
_states = new ConversationState();
}
+ public string GetConversationId() => _conversationId;
+
public IConversationStateService SetState(string name, T value)
{
if (value == null)
diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs
index 3ca6ca9c..fb73fdf6 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs
@@ -66,11 +66,13 @@ public class ConversationController : ControllerBase, IApiAdapter
{
response.Function = fnExecuted.FunctionName;
response.Data = fnExecuted.Data;
+ response.RichContent = fnExecuted.RichContent;
});
response.Text = string.Join("\r\n", stackMsg.Select(x => x.Content));
response.Data = response.Data ?? stackMsg.Last().Data;
response.Function = stackMsg.Last().FunctionName;
+ response.RichContent = response.RichContent ?? stackMsg.Last().RichContent;
return response;
}
diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Conversations/MessageResponseModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Conversations/MessageResponseModel.cs
index 5f7241c0..f5045ed1 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Conversations/MessageResponseModel.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Conversations/MessageResponseModel.cs
@@ -5,4 +5,5 @@ public class MessageResponseModel
public string Text { get; set; }
public string Function { get; set; }
public object Data { get; set; }
+ public object? RichContent { get; set; }
}
From 8f7b4c792584a4c2bc073912f11f5b92eba5dc15 Mon Sep 17 00:00:00 2001
From: Yanan Wang <103942@smsassist.com>
Date: Fri, 27 Oct 2023 15:13:58 -0500
Subject: [PATCH 02/10] Correct TemplateMessage Model
---
.../Messaging/Models/RichContent/Template/TemplateMessage.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/TemplateMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/TemplateMessage.cs
index 21b8d339..77b4a55f 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/TemplateMessage.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/TemplateMessage.cs
@@ -6,6 +6,6 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template
{
public class TemplateMessage
{
- public AttachmentTemplate Attachment { get; set; }
+ public T Attachment { get; set; }
}
}
From d26d8308d554ab818bfd16f56ff8b051e2467b90 Mon Sep 17 00:00:00 2001
From: Yanan Wang <103942@smsassist.com>
Date: Fri, 27 Oct 2023 15:25:16 -0500
Subject: [PATCH 03/10] Allow MessageingType Nullable
---
.../Messaging/Models/RichContent/RichContent.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs
index 69224e42..c2b027cd 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs
@@ -7,7 +7,7 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent
/// RESPONSE
///
[JsonPropertyName("messaging_type")]
- public string MessageingType { get; set; } = string.Empty;
+ public string? MessageingType { get; set; }
public T Message { get; set; }
}
}
From f709bb1795625f09264e2740fbc0e6fee90c502d Mon Sep 17 00:00:00 2001
From: Yanan Wang <103942@smsassist.com>
Date: Fri, 27 Oct 2023 15:38:37 -0500
Subject: [PATCH 04/10] Add SenderActionModel
---
.../Models/RichContent/SenderActionModel.cs | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/SenderActionModel.cs
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/SenderActionModel.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/SenderActionModel.cs
new file mode 100644
index 00000000..17830812
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/SenderActionModel.cs
@@ -0,0 +1,15 @@
+
+namespace BotSharp.Abstraction.Messaging.Models.RichContent
+{
+ public class SenderActionModel
+ {
+ /*
+ * Requests to display sender action should only include the sender_action parameter and the recipient object.
+ * All other Send API properties, such as text and templates, should be sent in a separate request.
+ */
+ public Recipient Recipient { get; set; } = new Recipient();
+
+ [JsonPropertyName("sender_action")]
+ public string SenderAction { get; set; } = string.Empty;
+ }
+}
From 35cbc90e60481826334d8221b93d757091878f57 Mon Sep 17 00:00:00 2001
From: Yanan Wang <103942@smsassist.com>
Date: Fri, 27 Oct 2023 15:54:16 -0500
Subject: [PATCH 05/10] Add JsonPropertyName
---
.../Messaging/Models/RichContent/Template/ButtonTemplate.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplate.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplate.cs
index e9817729..bdd1149d 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplate.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplate.cs
@@ -3,6 +3,7 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template
{
public class ButtonTemplate : TextMessage
{
+ [JsonPropertyName("template_type")]
public string TemplateType => "button";
public List Buttons { get; set; } = new List();
}
From e43b3e6fa1b91ab468a06e18a68e1979c342a109 Mon Sep 17 00:00:00 2001
From: Yanan Wang <103942@smsassist.com>
Date: Fri, 27 Oct 2023 17:16:53 -0500
Subject: [PATCH 06/10] Add RichContent field and PostBackUrl for QuickReplies
---
.../Messaging/Models/RichContent/QuickReplyElement.cs | 1 +
.../BotSharp.OpenAPI/Controllers/ConversationController.cs | 7 ++++---
.../ViewModels/Conversations/MessageResponseModel.cs | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs
index 15a07d23..cea110f1 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs
@@ -9,5 +9,6 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent
public string? Payload { get; set; }
[JsonPropertyName("image_url")]
public string? ImageUrl { get; set; }
+ public string? PostBackUrl { get; set; }
}
}
diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs
index 5fb5cd7c..80692bc9 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs
@@ -12,7 +12,7 @@ public class ConversationController : ControllerBase, IApiAdapter
private readonly IServiceProvider _services;
private readonly IUserIdentity _user;
- public ConversationController(IServiceProvider services,
+ public ConversationController(IServiceProvider services,
IUserIdentity user)
{
_services = services;
@@ -40,8 +40,8 @@ public class ConversationController : ControllerBase, IApiAdapter
}
[HttpPost("/conversation/{agentId}/{conversationId}")]
- public async Task SendMessage([FromRoute] string agentId,
- [FromRoute] string conversationId,
+ public async Task SendMessage([FromRoute] string agentId,
+ [FromRoute] string conversationId,
[FromBody] NewMessageModel input)
{
var conv = _services.GetRequiredService();
@@ -73,6 +73,7 @@ public class ConversationController : ControllerBase, IApiAdapter
response.Data = inputMsg.Data;
response.Function = inputMsg.FunctionName;
response.Instruction = inputMsg.Instruction;
+ response.RichContent = inputMsg.RichContent;
return response;
}
diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Conversations/MessageResponseModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Conversations/MessageResponseModel.cs
index 4dcf0c58..4fe7781c 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Conversations/MessageResponseModel.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Conversations/MessageResponseModel.cs
@@ -1,6 +1,5 @@
using BotSharp.Abstraction.Functions.Models;
using BotSharp.Abstraction.Models;
-using BotSharp.Abstraction.Routing.Models;
namespace BotSharp.OpenAPI.ViewModels.Conversations;
@@ -11,4 +10,5 @@ public class MessageResponseModel : ITrackableMessage
public string Function { get; set; }
public object Data { get; set; }
public FunctionCallFromLlm Instruction { get; set; }
+ public object? RichContent { get; set; }
}
From 89c62bf4969227b479922bcea02a774a65c858d8 Mon Sep 17 00:00:00 2001
From: Yanan Wang <103942@smsassist.com>
Date: Fri, 27 Oct 2023 17:55:28 -0500
Subject: [PATCH 07/10] Default RichContent
---
.../Services/ConversationService.SendMessage.cs | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs
index 387a18e7..5a291e8f 100644
--- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs
+++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs
@@ -1,4 +1,5 @@
using BotSharp.Abstraction.Agents.Models;
+using BotSharp.Abstraction.Messaging.Models.RichContent;
using BotSharp.Abstraction.Routing;
using BotSharp.Abstraction.Routing.Settings;
using System.Drawing;
@@ -100,6 +101,15 @@ public partial class ConversationService
_logger.LogInformation(text);
#endif
+ // Only read content from RichContent for UI rendering. When richContent is null, create a basic text message for richContent.
+ var state = _services.GetRequiredService();
+ message.RichContent = message.RichContent ?? new RichContent
+ {
+ Recipient = new Recipient { Id = state.GetConversationId() },
+ MessageingType = "RESPONSE",
+ Message = new TextMessage { Text = message.Content }
+ };
+
var hooks = _services.GetServices().ToList();
foreach (var hook in hooks)
{
From 801fda473fbb81fde7cd082f0ae9792d3744058a Mon Sep 17 00:00:00 2001
From: Yanan Wang <103942@smsassist.com>
Date: Sat, 28 Oct 2023 20:56:21 -0500
Subject: [PATCH 08/10] Fixed issues related to comments.
---
.../Messaging/Models/RichContent/QuickReplyElement.cs | 1 +
.../Messaging/Models/RichContent/Recipient.cs | 2 +-
.../Messaging/Models/RichContent/RichContent.cs | 4 ++--
.../{SenderActionModel.cs => SenderActionMessage.cs} | 2 +-
.../Messaging/Models/RichContent/Template/ButtonTemplate.cs | 4 ++--
.../Messaging/Models/RichContent/Template/CommonTemplate.cs | 1 +
.../Messaging/Models/RichContent/TextMessage.cs | 2 +-
7 files changed, 9 insertions(+), 7 deletions(-)
rename src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/{SenderActionModel.cs => SenderActionMessage.cs} (93%)
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs
index cea110f1..1be8f208 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs
@@ -9,6 +9,7 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent
public string? Payload { get; set; }
[JsonPropertyName("image_url")]
public string? ImageUrl { get; set; }
+ [JsonPropertyName("postback_url")]
public string? PostBackUrl { get; set; }
}
}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Recipient.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Recipient.cs
index 7bfbba8e..5c77924a 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Recipient.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Recipient.cs
@@ -3,6 +3,6 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent
{
public class Recipient
{
- public string? Id { get; set; }
+ public string Id { get; set; } = string.Empty;
}
}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs
index c2b027cd..fb6a121f 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs
@@ -2,12 +2,12 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent
{
public class RichContent
{
- public Recipient? Recipient { get; set; }
+ public Recipient Recipient { get; set; } = new Recipient();
///
/// RESPONSE
///
[JsonPropertyName("messaging_type")]
- public string? MessageingType { get; set; }
+ public string? MessagingType { get; set; }
public T Message { get; set; }
}
}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/SenderActionModel.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/SenderActionMessage.cs
similarity index 93%
rename from src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/SenderActionModel.cs
rename to src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/SenderActionMessage.cs
index 17830812..6b652e4e 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/SenderActionModel.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/SenderActionMessage.cs
@@ -1,7 +1,7 @@
namespace BotSharp.Abstraction.Messaging.Models.RichContent
{
- public class SenderActionModel
+ public class SenderActionMessage
{
/*
* Requests to display sender action should only include the sender_action parameter and the recipient object.
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplate.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplate.cs
index bdd1149d..f610a682 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplate.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplate.cs
@@ -10,8 +10,8 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template
public class ButtonElement
{
- public string? Type { get; set; }
+ public string Type { get; set; } = string.Empty;
public string? Url { get; set; }
- public string? Title { get; set; }
+ public string Title { get; set; } = string.Empty;
}
}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/CommonTemplate.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/CommonTemplate.cs
index ace1daac..e4b3ea8c 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/CommonTemplate.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/CommonTemplate.cs
@@ -3,6 +3,7 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template
{
public class CommonTemplate
{
+ [JsonPropertyName("template_type")]
public string TemplateType { get; set; } = string.Empty;
public T Elements { get; set; }
}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/TextMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/TextMessage.cs
index bed603a2..94d85894 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/TextMessage.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/TextMessage.cs
@@ -3,6 +3,6 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent
{
public class TextMessage
{
- public string? Text { get; set; }
+ public string Text { get; set; } = string.Empty;
}
}
\ No newline at end of file
From bca0403fe983dbbeba5b62f97276e2c8c3183621 Mon Sep 17 00:00:00 2001
From: Yanan Wang <103942@smsassist.com>
Date: Sat, 28 Oct 2023 21:03:28 -0500
Subject: [PATCH 09/10] Default messaging_type in RichContent as "RESPONSE"
---
.../Messaging/Models/RichContent/RichContent.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs
index fb6a121f..221dc96d 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/RichContent.cs
@@ -7,7 +7,7 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent
/// RESPONSE
///
[JsonPropertyName("messaging_type")]
- public string? MessagingType { get; set; }
+ public string MessagingType => "RESPONSE";
public T Message { get; set; }
}
}
From 0ca92c03286481e2683823afbf294106861cc3eb Mon Sep 17 00:00:00 2001
From: Yanan Wang <103942@smsassist.com>
Date: Sat, 28 Oct 2023 21:15:41 -0500
Subject: [PATCH 10/10] Fix the bugs due to the MessageingType typo correct
---
.../Conversations/Services/ConversationService.SendMessage.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs
index 5a291e8f..482857d9 100644
--- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs
+++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs
@@ -106,7 +106,6 @@ public partial class ConversationService
message.RichContent = message.RichContent ?? new RichContent
{
Recipient = new Recipient { Id = state.GetConversationId() },
- MessageingType = "RESPONSE",
Message = new TextMessage { Text = message.Content }
};