Skip to content

Commit a1adcdd

Browse files
authored
Merge pull request #415 from iceljc/features/add-secondary-language
Features/add secondary language
2 parents 02be753 + 72c0f06 commit a1adcdd

File tree

20 files changed

+122
-15
lines changed

20 files changed

+122
-15
lines changed

src/Infrastructure/BotSharp.Abstraction/Conversations/Models/Conversation.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,28 @@ public class DialogElement
3434
{
3535
public DialogMetaData MetaData { get; set; }
3636
public string Content { get; set; }
37+
public string? SecondaryContent { get; set; }
3738
public string? RichContent { get; set; }
39+
public string? SecondaryRichContent { get; set; }
3840

3941
public DialogElement()
4042
{
4143

4244
}
4345

44-
public DialogElement(DialogMetaData meta, string content, string? richContent = null)
46+
public DialogElement(DialogMetaData meta, string content, string? richContent = null,
47+
string? secondaryContent = null, string? secondaryRichContent = null)
4548
{
4649
MetaData = meta;
4750
Content = content;
4851
RichContent = richContent;
52+
SecondaryContent = secondaryContent;
53+
SecondaryRichContent = secondaryRichContent;
4954
}
5055

5156
public override string ToString()
5257
{
53-
return $"{MetaData.Role}: {Content} [{MetaData.CreateTime}]";
58+
return $"{MetaData.Role}: {Content} [{MetaData?.CreateTime}]";
5459
}
5560
}
5661

src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class RoleDialogModel : ITrackableMessage
2626

2727
public string Content { get; set; }
2828

29+
public string? SecondaryContent { get; set; }
30+
2931
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
3032
public string CurrentAgentId { get; set; }
3133

@@ -57,6 +59,9 @@ public class RoleDialogModel : ITrackableMessage
5759
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
5860
public RichContent<IRichMessage>? RichContent { get; set; }
5961

62+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
63+
public RichContent<IRichMessage>? SecondaryRichContent { get; set; }
64+
6065
/// <summary>
6166
/// Stop conversation completion
6267
/// </summary>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
using BotSharp.Abstraction.Messaging.Enums;
2+
using Newtonsoft.Json;
23

34
namespace BotSharp.Abstraction.Messaging;
45

56
public interface IRichMessage
67
{
78
[JsonPropertyName("text")]
9+
[JsonProperty("text")]
810
string Text { get; set; }
911

1012
[JsonPropertyName("rich_type")]
13+
[JsonProperty("rich_type")]
1114
string RichType => RichTypeEnum.Text;
1215
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
using Newtonsoft.Json;
2+
13
namespace BotSharp.Abstraction.Messaging;
24

35
public interface ITemplateMessage
46
{
57
[JsonPropertyName("template_type")]
8+
[JsonProperty("template_type")]
69
string TemplateType => string.Empty;
710
}

src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementAction.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
using Newtonsoft.Json;
2+
using JsonIgnoreAttribute = System.Text.Json.Serialization.JsonIgnoreAttribute;
3+
14
namespace BotSharp.Abstraction.Messaging.Models.RichContent;
25

36
public class ElementAction
@@ -8,6 +11,7 @@ public class ElementAction
811
public string Url { get; set; }
912

1013
[JsonPropertyName("webview_height_ratio")]
14+
[JsonProperty("webview_height_ratio")]
1115
public string WebViewHeightRatio { get; set; }
1216

1317
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]

src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
using Newtonsoft.Json;
2+
using JsonIgnoreAttribute = System.Text.Json.Serialization.JsonIgnoreAttribute;
3+
14
namespace BotSharp.Abstraction.Messaging.Models.RichContent;
25

36
/// <summary>
@@ -16,11 +19,14 @@ public class ElementButton
1619
public string Payload { get; set; }
1720

1821
[JsonPropertyName("is_primary")]
22+
[JsonProperty("is_primary")]
1923
public bool IsPrimary { get; set; }
2024

2125
[JsonPropertyName("is_secondary")]
26+
[JsonProperty("is_secondary")]
2227
public bool IsSecondary { get; set; }
2328

2429
[JsonPropertyName("post_action_disclaimer")]
30+
[JsonProperty("post_action_disclaimer")]
2531
public string? PostActionDisclaimer { get; set; }
2632
}

src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
using Newtonsoft.Json;
2+
using JsonIgnoreAttribute = System.Text.Json.Serialization.JsonIgnoreAttribute;
3+
14
namespace BotSharp.Abstraction.Messaging.Models.RichContent;
25

36
public class QuickReplyElement
@@ -9,6 +12,7 @@ public class QuickReplyElement
912
public string? Payload { get; set; }
1013

1114
[JsonPropertyName("image_url")]
15+
[JsonProperty("image_url")]
1216
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1317
public string? ImageUrl { get; set; }
1418
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
using BotSharp.Abstraction.Messaging.Enums;
2+
using Newtonsoft.Json;
23

34
namespace BotSharp.Abstraction.Messaging.Models.RichContent;
45

56
public class QuickReplyMessage : IRichMessage
67
{
78
[JsonPropertyName("rich_type")]
9+
[JsonProperty("rich_type")]
810
public string RichType => RichTypeEnum.QuickReply;
911
public string Text { get; set; } = string.Empty;
1012

1113
[JsonPropertyName("quick_replies")]
14+
[JsonProperty("quick_replies")]
1215
public List<QuickReplyElement> QuickReplies { get; set; } = new List<QuickReplyElement>();
1316
}

src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplateMessage.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using BotSharp.Abstraction.Messaging.Enums;
2+
using Newtonsoft.Json;
23

34
namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template;
45

@@ -8,17 +9,22 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template;
89
public class ButtonTemplateMessage : IRichMessage, ITemplateMessage
910
{
1011
[JsonPropertyName("rich_type")]
12+
[JsonProperty("rich_type")]
1113
public string RichType => RichTypeEnum.ButtonTemplate;
1214

1315
[JsonPropertyName("text")]
16+
[JsonProperty("text")]
1417
public string Text { get; set; } = string.Empty;
1518

1619
[JsonPropertyName("template_type")]
20+
[JsonProperty("template_type")]
1721
public string TemplateType => TemplateTypeEnum.Button;
1822

1923
[JsonPropertyName("buttons")]
24+
[JsonProperty("buttons")]
2025
public ElementButton[] Buttons { get; set; } = new ElementButton[0];
2126

2227
[JsonPropertyName("is_horizontal")]
28+
[JsonProperty("is_horizontal")]
2329
public bool IsHorizontal { get; set; }
2430
}

src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/CouponTemplateMessage.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using BotSharp.Abstraction.Messaging.Enums;
2+
using Newtonsoft.Json;
23

34
namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template;
45

@@ -9,30 +10,40 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template;
910
public class CouponTemplateMessage : IRichMessage, ITemplateMessage
1011
{
1112
[JsonPropertyName("rich_type")]
13+
[JsonProperty("rich_type")]
1214
public string RichType => RichTypeEnum.CouponTemplate;
15+
1316
[JsonPropertyName("text")]
17+
[JsonProperty("text")]
1418
public string Text { get; set; }
1519
public string Title { get; set; }
1620
public string Subtitle { get; set; }
1721

1822
[JsonPropertyName("template_type")]
23+
[JsonProperty("template_type")]
1924
public string TemplateType => TemplateTypeEnum.Coupon;
2025

2126
[JsonPropertyName("coupon_code")]
27+
[JsonProperty("coupon_code")]
2228
public string CouponCode { get; set; }
2329

2430
[JsonPropertyName("coupon_url")]
31+
[JsonProperty("coupon_url")]
2532
public string CouponUrl { get; set; }
2633

2734
[JsonPropertyName("coupon_url_button_title")]
35+
[JsonProperty("coupon_url_button_title")]
2836
public string CouponUrlButtonTitle { get; set; } = "Shop now";
2937

3038
[JsonPropertyName("coupon_pre_message")]
39+
[JsonProperty("coupon_pre_message")]
3140
public string CouponPreMessage { get; set; } = "Here's a deal just for you!";
3241

3342
[JsonPropertyName("image_url")]
43+
[JsonProperty("image_url")]
3444
public string ImageUrl { get; set; }
3545

3646
[JsonPropertyName("payload")]
47+
[JsonProperty("payload")]
3748
public string Payload { get; set; }
3849
}

0 commit comments

Comments
 (0)