Skip to content

Commit d156a6f

Browse files
authored
Merge pull request #1334 from iceljc/master
add embedding template
2 parents 846fc54 + 3833e5a commit d156a6f

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/Infrastructure/BotSharp.Abstraction/Messaging/BotSharpMessageParser.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public static class BotSharpMessageParser
4242
{
4343
targetType = typeof(ProgramCodeTemplateMessage);
4444
}
45+
else if (richType == RichTypeEnum.EmbeddingTemplate)
46+
{
47+
targetType = typeof(EmbeddingTemplateMessage);
48+
}
4549
else if (richType == RichTypeEnum.GenericTemplate)
4650
{
4751
if (root.TryGetProperty("element_type", out element))
@@ -92,6 +96,10 @@ public static class BotSharpMessageParser
9296
{
9397
targetType = typeof(ProgramCodeTemplateMessage);
9498
}
99+
else if (templateType == TemplateTypeEnum.Embedding)
100+
{
101+
targetType = typeof(EmbeddingTemplateMessage);
102+
}
95103
else if (templateType == TemplateTypeEnum.Generic)
96104
{
97105
if (root.TryGetProperty("element_type", out element))

src/Infrastructure/BotSharp.Abstraction/Messaging/Enums/RichTypeEnum.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public static class RichTypeEnum
66
public const string MultiSelectTemplate = "multi-select_template";
77
public const string CouponTemplate = "coupon_template";
88
public const string GenericTemplate = "generic_template";
9+
public const string EmbeddingTemplate = "embedding_template";
910
public const string QuickReply = "quick_reply";
1011
public const string Text = "text";
1112
public const string Attachment = "attachment";

src/Infrastructure/BotSharp.Abstraction/Messaging/Enums/TemplateTypeEnum.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ public static class TemplateTypeEnum
77
public const string Generic = "generic";
88
public const string MultiSelect = "multi-select";
99
public const string ProgramCode = "program_code";
10+
public const string Embedding = "embedding";
1011
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template;
2+
3+
public class EmbeddingTemplateMessage : IRichMessage, ITemplateMessage
4+
{
5+
[JsonPropertyName("rich_type")]
6+
public string RichType => RichTypeEnum.EmbeddingTemplate;
7+
8+
[JsonPropertyName("title")]
9+
public string Title { get; set; } = string.Empty;
10+
11+
[JsonPropertyName("text")]
12+
public string Text { get; set; } = string.Empty;
13+
14+
[JsonPropertyName("html_tag")]
15+
public string HtmlTag { get; set; } = "iframe";
16+
17+
[JsonPropertyName("template_type")]
18+
public virtual string TemplateType { get; set; } = TemplateTypeEnum.Embedding;
19+
20+
[JsonPropertyName("url")]
21+
public string Url { get; set; } = string.Empty;
22+
}

0 commit comments

Comments
 (0)