fbmsg

package
v0.0.0-...-2c63f42 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
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 NewClient

func NewClient(cfg Config) (*Client, error)

func (*Client) CallSendAPI

func (c *Client) CallSendAPI(ctx context.Context, req *SendRequest) error

type Config

type Config struct {
	VerifyToken     string
	PageAccessToken string
}

func (*Config) Verify

func (c *Config) Verify() 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 IntID

type IntID = dot.IntID

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 PostbackReferralData struct {
	Ref         string `json:"ref"`
	Source      string `json:"source"`
	Type        string `json:"type"`
	RefererURI  string `json:"referer_uri"`
	IsGuestUser string `json:"is_guest_user"`
}

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 ReactionData struct {
	MID      StrID  `json:"mid,omitempty"`
	Action   string `json:"action,omitempty"`
	Emoji    string `json:"emoji,omitempty"`
	Reaction string `json:"reaction,omitempty"`
}

type ReadData

type ReadData struct {
	Watermark IntID `json:"watermark,omitempty"`
}

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 SendRecipientData struct {
	ID        IntID  `json:"id,omitempty"`
	UserRef   string `json:"user_ref,omitempty"`
	PostId    string `json:"post_id,omitempty"`
	CommentID string `json:"comment_id,omitempty"`
}

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 SendResponse struct {
	RecipientID IntID  `json:"recipient_id,omitempty"`
	MessageID   string `json:"message_id,omitempty"`
}

type SenderAction

type SenderAction string

type SenderID

type SenderID struct {
	ID      IntID  `json:"id,omitempty"`
	UserRef string `json:"user_ref,omitempty"`
}

type StrID

type StrID string

type TemplateType

type TemplateType string

type Timestamp

type Timestamp = dot.Timestamp

type URL

type URL 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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL