-
Notifications
You must be signed in to change notification settings - Fork 177
/
FacebookMessage.cs
157 lines (139 loc) · 7.26 KB
/
FacebookMessage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
using Bot.Builder.Community.Adapters.Facebook.FacebookEvents;
using Bot.Builder.Community.Adapters.Facebook.FacebookEvents.Handover;
using Newtonsoft.Json;
namespace Bot.Builder.Community.Adapters.Facebook
{
/// <summary>
/// Represents information associated with a Facebook webhook event. For more information, see the Facebook
/// [Webhook Events Reference](https://developers.facebook.com/docs/messenger-platform/reference/webhook-events).
/// </summary>
public class FacebookMessage
{
/// <summary>
/// Initializes a new instance of the <see cref="FacebookMessage"/> class.
/// </summary>
/// <param name="recipientId">Contents of the recipient ID field.</param>
/// <param name="message">Contents of the message field.</param>
/// <param name="messagingType">The type of webhook event. For more information, see the Facebook
/// [List of Webhook Events](https://developers.facebook.com/docs/messenger-platform/reference/webhook-events#event_list).</param>
/// <param name="tag">The optional message tag string. See https://developers.facebook.com/docs/messenger-platform/send-messages/message-tags.</param>
/// <param name="notificationType">The optional notification type: REGULAR (default value), SILENT_PUSH, NO_PUSH.</param>
/// <param name="personaId">The persona ID.</param>
/// <param name="senderAction">Message state to display to the user: typing_on, typing_off, mark_seen. Cannot be sent with 'message'. When used, 'recipient' should be the only other property set in the request.</param>
/// <param name="senderId">The sender ID.</param>
public FacebookMessage(string recipientId, Message message, string messagingType, string tag = null, string notificationType = null, string personaId = null, string senderAction = null, string senderId = null)
{
Recipient.Id = recipientId;
Message = message;
MessagingType = messagingType;
Tag = tag;
NotificationType = notificationType;
PersonaId = personaId;
SenderAction = senderAction;
Sender.Id = senderId;
}
/// <summary>
/// Gets or sets the ID of the recipient.
/// </summary>
/// <value>The ID of the recipient.</value>
[JsonProperty(PropertyName = "recipient")]
public FacebookBotUser Recipient { get; set; } = new FacebookBotUser();
/// <summary>
/// Gets or sets the ID of the sender.
/// </summary>
/// <value>The ID of the sender.</value>
[JsonProperty(PropertyName = "sender")]
public FacebookBotUser Sender { get; set; } = new FacebookBotUser();
/// <summary>
/// Gets or sets the message to be sent.
/// </summary>
/// <value>The message.</value>
[JsonProperty(PropertyName = "message")]
public Message Message { get; set; }
/// <summary>
/// Gets or sets the messaging type.
/// </summary>
/// <value>The messaging type.</value>
[JsonProperty(PropertyName = "messaging_type")]
public string MessagingType { get; set; }
/// <summary>
/// Gets or sets a tag to the message.
/// </summary>
/// <value>The tag.</value>
[JsonProperty(PropertyName = "tag")]
public string Tag { get; set; }
/// <summary>
/// Gets or sets the notification type.
/// </summary>
/// <value>The notification type.</value>
[JsonProperty(PropertyName = "notification_type")]
public string NotificationType { get; set; }
/// <summary>
/// Gets or sets the persona ID.
/// </summary>
/// <value>The persona ID.</value>
[JsonProperty(PropertyName = "persona_id")]
public string PersonaId { get; set; }
/// <summary>
/// Gets or sets the sender action.
/// </summary>
/// <value>The sender action (typing_on, typing_off, mark_seen).</value>
[JsonProperty(PropertyName = "sender_action")]
public string SenderAction { get; set; }
/// <summary>
/// Gets or sets the time-stamp.
/// </summary>
/// <value>Time-stamp.</value>
[JsonProperty(PropertyName = "timestamp")]
public long TimeStamp { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the message was received while in Standby mode.
/// </summary>
/// <value>Value indicating whether the message was received while in Standby mode.</value>
[JsonIgnore]
public bool IsStandby { get; set; }
/// <summary>
/// Gets or sets the value of the postback property.
/// </summary>
/// <value>The postback payload. A postback occurs when a postback button, **Get Started** button, or persistent menu item is tapped.</value>
[JsonProperty(PropertyName = "postback")]
public FacebookPostBack PostBack { get; set; }
/// <summary>
/// Gets or sets the value of the optin property.
/// </summary>
/// <value>The optin field. See https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messaging_optins. </value>
[JsonProperty(PropertyName = "optin")]
public FacebookRecipient OptIn { get; set; }
/// <summary>
/// Gets or sets the contents of the pass_thread_control property.
/// </summary>
/// <value>A <see cref="FacebookPassThreadControl"/> holding the contents of the pass_thread_control property.</value>.
[JsonProperty(PropertyName = "pass_thread_control")]
public FacebookPassThreadControl PassThreadControl { get; set; }
/// <summary>
/// Gets or sets the contents of the take_thread_control property.
/// </summary>
/// <value>A <see cref="FacebookTakeThreadControl"/> holding the contents of the pass_thread_control property.</value>.
[JsonProperty(PropertyName = "take_thread_control")]
public FacebookTakeThreadControl TakeThreadControl { get; set; }
/// <summary>
/// Gets or sets the contents of the request_thread_control property.
/// </summary>
/// <value>A <see cref="FacebookRequestThreadControl"/> holding the contents of the pass_thread_control property.</value>.
[JsonProperty(PropertyName = "request_thread_control")]
public FacebookRequestThreadControl RequestThreadControl { get; set; }
/// <summary>
/// Gets or sets the contents of the message_reads property.
/// </summary>
/// <value>A <see cref="FacebookRead"/> holding the contents of the message_reads property.
/// See https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/message-reads. </value>.
[JsonProperty(PropertyName = "read")]
public FacebookRead Reads { get; set; }
/// <summary>
/// Gets or sets the value of the referral property in an messaging_referrals event.
/// </summary>
/// <value>See https://developers.facebook.com/docs/messenger-platform/discovery/m-me-links/#reading_parameter. </value>
[JsonProperty(PropertyName = "referral")]
public FacebookReferral Referral { get; set; }
}
}