Skip to content

Commit

Permalink
added TagType enum for MESSAGE_TAG messaging type
Browse files Browse the repository at this point in the history
  • Loading branch information
sSimuSs committed Dec 30, 2022
1 parent 183e689 commit 7d230df
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type NotificationType string
type TopElementStyle string
type ImageAspectRatio string
type SenderAction string
type TagType string

const (
// SendMessageURL is API endpoint for sending messages.
Expand Down Expand Up @@ -70,6 +71,17 @@ const (
SenderActionMarkSeen SenderAction = "mark_seen"
SenderActionTypingOn SenderAction = "typing_on"
SenderActionTypingOff SenderAction = "typing_off"

// TagAccountUpdateType Tags the message you are sending to your customer as a non-recurring update to their application or account. Not available for Instagram Messaging API
TagAccountUpdateType TagType = "ACCOUNT_UPDATE"
// TagConfirmedEventUpdateType Tags the message you are sending to your customer as a reminder fo an upcoming event or an update for an event in procgres for which the customer is registered. Not available for Instagram Messaging API
TagConfirmedEventUpdateType TagType = "CONFIRMED_EVENT_UPDATE"
// TagCustomerFeedbackType Tags the message you are sending to your customer as a Customer Feedback Survey. Customer feedback messages must be sent within 7 days of the customer's last message. Not available for Instagram Messaging API
TagCustomerFeedbackType TagType = "CUSTOMER_FEEDBACK"
// TagHumanAgentType When this tag is added to a message to a customer, it allows a human agent to respond to a person's message. Messages can be sent within 7 days of the person's. Human agent support is for issues that cannot be resolved within the standard 24 hour messaging window
TagHumanAgentType TagType = "HUMAN_AGENT"
// TagPostPurchaseUpdateType Tags the message you are sending to your customer as an update for a recent purchase made by the customer. Not available for Instagram Messaging API.
TagPostPurchaseUpdateType TagType = "POST_PURCHASE_UPDATE"
)

// QueryResponse is the response sent back by Facebook when setting up things
Expand Down Expand Up @@ -120,16 +132,16 @@ func (r *Response) SetToken(token string) {
}

// Text sends a textual message.
func (r *Response) Text(message string, messagingType MessagingType, notificationType NotificationType, tags ...string) error {
func (r *Response) Text(message string, messagingType MessagingType, notificationType NotificationType, tags ...TagType) error {
return r.TextWithReplies(message, nil, messagingType, notificationType, tags...)
}

// TextWithReplies sends a textual message with some replies
// messagingType should be one of the following: "RESPONSE","UPDATE","MESSAGE_TAG","NON_PROMOTIONAL_SUBSCRIPTION"
// notificationType should be one of the following: "NO_PUSH","REGULAR" (default),"SILENT_PUSH"
// only supply tags when messagingType == "MESSAGE_TAG" (see https://developers.facebook.com/docs/messenger-platform/send-messages#messaging_types for more)
func (r *Response) TextWithReplies(message string, replies []QuickReply, messagingType MessagingType, notificationType NotificationType, tags ...string) error {
var tag string
func (r *Response) TextWithReplies(message string, replies []QuickReply, messagingType MessagingType, notificationType NotificationType, tags ...TagType) error {
var tag TagType
if len(tags) > 0 {
tag = tags[0]
}
Expand All @@ -149,8 +161,8 @@ func (r *Response) TextWithReplies(message string, replies []QuickReply, messagi
}

// AttachmentWithReplies sends a attachment message with some replies
func (r *Response) AttachmentWithReplies(attachment *StructuredMessageAttachment, replies []QuickReply, messagingType MessagingType, notificationType NotificationType, tags ...string) error {
var tag string
func (r *Response) AttachmentWithReplies(attachment *StructuredMessageAttachment, replies []QuickReply, messagingType MessagingType, notificationType NotificationType, tags ...TagType) error {
var tag TagType
if len(tags) > 0 {
tag = tags[0]
}
Expand Down Expand Up @@ -413,7 +425,7 @@ type SendMessage struct {
MessagingType MessagingType `json:"messaging_type"`
Recipient Recipient `json:"recipient"`
Message MessageData `json:"message"`
Tag string `json:"tag,omitempty"`
Tag TagType `json:"tag,omitempty"`
NotificationType NotificationType `json:"notification_type,omitempty"`
}

Expand Down

0 comments on commit 7d230df

Please sign in to comment.