Documentation ¶
Index ¶
- Constants
- type AttachmentItem
- type AttachmentPayloadData
- type AttachmentType
- type ButtonItem
- type ButtonType
- type Client
- type Config
- type ContentType
- type DefaultActionData
- type DeliveryData
- type ElementItem
- type EntryMessaging
- type IntID
- type MessageData
- type MessageReferralData
- type ObjectType
- type PayloadData
- type PostbackButtonData
- type PostbackData
- type PostbackReferralData
- type QuickReplyData
- type QuickReplyItem
- type ReactionData
- type ReadData
- type RecipientID
- type ReplyToData
- type SendAttachmentData
- type SendAttachmentType
- type SendMessageData
- type SendRecipientData
- type SendRequest
- type SendResponse
- type SenderAction
- type SenderID
- type StrID
- type TemplateType
- type Timestamp
- type URL
- type URLButtonData
- type WebhookEntry
- type WebhookMessage
Constants ¶
const ( ObjectTypePage ObjectType = "page" SenderActionTypingOn SenderAction = "typing_on" SenderActionTypingOff SenderAction = "typing_off" SenderActionMarkSeen SenderAction = "mark_seen" ContentTypeText ContentType = "text" ContentTypePhone ContentType = "user_phone_number" ContentTypeEmail ContentType = "user_email" AttachmentTypeAudio AttachmentType = "audio" AttachmentTypeFile AttachmentType = "file" AttachmentTypeImage AttachmentType = "image" AttachmentTypeLocation AttachmentType = "location" AttachmentTypeVideo AttachmentType = "video" AttachmentTypeFallback AttachmentType = "fallback" SendAttachmentTypeImage SendAttachmentType = "image" SendAttachmentTypeAudio SendAttachmentType = "audio" SendAttachmentTypeVideo SendAttachmentType = "video" SendAttachmentTypeFile SendAttachmentType = "file" SendAttachmentTypeTemplate SendAttachmentType = "template" TemplateTypeGeneric TemplateType = "generic" TemplateTypeButton TemplateType = "button" ButtonTypeURL ButtonType = "web_url" ButtonTypePostback ButtonType = "postback" )
const EndpointURL = "https://graph.facebook.com/v2.6/me/messages"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttachmentItem ¶
type AttachmentItem struct { Type AttachmentType `json:"type,omitempty"` Payload *AttachmentPayloadData `json:"payload,omitempty"` }
type AttachmentPayloadData ¶
type AttachmentPayloadData struct {
URL string `json:"url,omitempty"`
}
type AttachmentType ¶
type AttachmentType string
type ButtonItem ¶
type ButtonItem struct { URLButton *URLButtonData PostbackButton *PostbackButtonData }
func (ButtonItem) MarshalJSON ¶
func (b ButtonItem) MarshalJSON() ([]byte, error)
func (*ButtonItem) UnmarshalJSON ¶
func (b *ButtonItem) UnmarshalJSON(data []byte) error
type ButtonType ¶
type ButtonType string
type Client ¶
type Client struct { Config HTTP *resty.Client }
func (*Client) CallSendAPI ¶
func (c *Client) CallSendAPI(ctx context.Context, req *SendRequest) error
type ContentType ¶
type ContentType string
type DefaultActionData ¶
type DefaultActionData URLButtonData
DefaultActionData accepts the same properties as URL button, except title.
type DeliveryData ¶
type DeliveryData struct {
MIDs []StrID `json:"mids"`
}
type ElementItem ¶
type ElementItem struct { Title string `json:"title,omitempty"` Subtitle string `json:"subtitle,omitempty"` ImageURL string `json:"image_url,omitempty"` DefaultAction *DefaultActionData `json:"default_action,omitempty"` Buttons []*ButtonItem `json:"buttons,omitempty"` }
type EntryMessaging ¶
type EntryMessaging struct { Sender SenderID `json:"sender"` Recipient RecipientID `json:"recipient"` Timestamp Timestamp `json:"timestamp"` Message *MessageData `json:"message,omitempty"` Postback *PostbackData `json:"postback,omitempty"` Reaction *ReactionData `json:"reaction,omitempty"` Read *ReadData `json:"read,omitempty"` Delivery *DeliveryData `json:"delivery,omitempty"` }
type MessageData ¶
type MessageData struct { MID StrID `json:"mid,omitempty"` AppID IntID `json:"app_id,omitempty"` Text string `json:"text,omitempty"` IsEcho bool `json:"is_echo,omitempty"` QuickReply *QuickReplyData `json:"quick_reply,omitempty"` ReplyTo *ReplyToData `json:"reply_to,omitempty"` Attachments []*AttachmentItem `json:"attachments,omitempty"` Referral *MessageReferralData `json:"referral,omitempty"` }
type MessageReferralData ¶
type MessageReferralData struct { }
type ObjectType ¶
type ObjectType string
type PayloadData ¶
type PayloadData struct { TemplateType TemplateType `json:"template_type"` Elements []*ElementItem `json:"elements"` }
PayloadData can be template or file attachment. We only implement 2 templates here.
Template: generic, button, ...
https://developers.facebook.com/docs/messenger-platform/reference/templates#available_templates https://developers.facebook.com/docs/messenger-platform/reference/templates/generic https://developers.facebook.com/docs/messenger-platform/reference/templates/button
type PostbackButtonData ¶
type PostbackButtonData struct { Type ButtonType `json:"type"` Title string `json:"title"` Payload string `json:"payload"` }
PostbackButtonData https://developers.facebook.com/docs/messenger-platform/reference/buttons/postback
func (PostbackButtonData) Wrap ¶
func (d PostbackButtonData) Wrap() *ButtonItem
type PostbackData ¶
type PostbackData struct { MID StrID `json:"mid,omitempty"` Title string `json:"title,omitempty"` Payload string `json:"payload,omitempty"` Referral *PostbackReferralData `json:"referral,omitempty"` }
type PostbackReferralData ¶
type QuickReplyData ¶
type QuickReplyData struct {
Payload string `json:"payload,omitempty"`
}
type QuickReplyItem ¶
type QuickReplyItem struct { ContentType string `json:"content_type,omitempty"` Title string `json:"title,omitempty"` Payload *PayloadData `json:"payload,omitempty"` ImageURL string `json:"image_url,omitempty"` }
type ReactionData ¶
type RecipientID ¶
type RecipientID struct {
ID IntID `json:"id"`
}
type ReplyToData ¶
type ReplyToData struct {
MID StrID `json:"mid,omitempty"`
}
type SendAttachmentData ¶
type SendAttachmentData struct { Type SendAttachmentType `json:"type,omitempty"` Payload *PayloadData `json:"payload,omitempty"` }
type SendAttachmentType ¶
type SendAttachmentType string
type SendMessageData ¶
type SendMessageData struct { Text string `json:"text,omitempty"` Attachment *SendAttachmentData `json:"attachment,omitempty"` QuickReplies []*QuickReplyItem `json:"quick_replies,omitempty"` Metadata string `json:"metadata,omitempty"` }
type SendRecipientData ¶
type SendRequest ¶
type SendRequest struct { MessagingType string `json:"messaging_type,omitempty"` Recipient *SendRecipientData `json:"recipient,omitempty"` Message *SendMessageData `json:"message,omitempty"` SenderAction string `json:"sender_action,omitempty"` NotificationType string `json:"notification_type,omitempty"` Tag string `json:"tag,omitempty"` }
SendRequest implements Messenger API
type SendResponse ¶
type SenderAction ¶
type SenderAction string
type TemplateType ¶
type TemplateType string
type URLButtonData ¶
type URLButtonData struct { Type ButtonType `json:"type"` Title string `json:"title"` URL string `json:"url"` }
URLButtonData https://developers.facebook.com/docs/messenger-platform/reference/buttons/url
func (URLButtonData) Wrap ¶
func (d URLButtonData) Wrap() *ButtonItem
type WebhookEntry ¶
type WebhookEntry struct { ID IntID `json:"id"` Time Timestamp `json:"time"` Messaging []*EntryMessaging `json:"messaging"` }
type WebhookMessage ¶
type WebhookMessage struct { Object string `json:"object"` Entry []*WebhookEntry `json:"entry"` }