Sender actions support
This commit is contained in:
parent
243bf4a2b2
commit
5bdc2eb804
17
actions.go
17
actions.go
@ -24,3 +24,20 @@ const (
|
||||
// status.
|
||||
AccountLinkingAction
|
||||
)
|
||||
|
||||
// SenderAction is used to send a specific action (event) to the Facebook.
|
||||
// The result of sending said action is supposed to give more interactivity to the bot.
|
||||
type SenderAction string
|
||||
|
||||
const (
|
||||
// MarkSeen marks message as seen.
|
||||
MarkSeen SenderAction = "MARK_SEEN"
|
||||
// TypingOn turns on "Bot is typing..." indicator.
|
||||
TypingOn SenderAction = "TYPING_ON"
|
||||
// TypingOff turns off typing indicator.
|
||||
TypingOff SenderAction = "TYPING_OFF"
|
||||
// React to the message.
|
||||
React SenderAction = "REACT"
|
||||
// Unreact to the message (remove reaction).
|
||||
Unreact SenderAction = "UNREACT"
|
||||
)
|
||||
|
@ -508,6 +508,15 @@ func (m *Messenger) EnableChatExtension(homeURL HomeURL) error {
|
||||
return checkFacebookError(resp.Body)
|
||||
}
|
||||
|
||||
func (m *Messenger) SenderAction(to Recipient, action SenderAction) (QueryResponse, error) {
|
||||
response := &Response{
|
||||
token: m.token,
|
||||
to: to,
|
||||
sendAPIVersion: m.sendAPIVersion,
|
||||
}
|
||||
return response.SenderAction(action)
|
||||
}
|
||||
|
||||
// classify determines what type of message a webhook event is.
|
||||
func (m *Messenger) classify(info MessageInfo) Action {
|
||||
if info.Message != nil {
|
||||
|
@ -352,8 +352,8 @@ func (r *Response) ListTemplate(elements *[]StructuredMessageElement, messagingT
|
||||
return r.DispatchMessage(&m)
|
||||
}
|
||||
|
||||
// SenderAction sends a info about sender action.
|
||||
func (r *Response) SenderAction(action string) (QueryResponse, error) {
|
||||
// SenderAction sends an info about sender action.
|
||||
func (r *Response) SenderAction(action SenderAction) (QueryResponse, error) {
|
||||
m := SendSenderAction{
|
||||
Recipient: r.to,
|
||||
SenderAction: action,
|
||||
@ -548,5 +548,5 @@ type StructuredMessageButton struct {
|
||||
// SendSenderAction is the information about sender action.
|
||||
type SendSenderAction struct {
|
||||
Recipient Recipient `json:"recipient"`
|
||||
SenderAction string `json:"sender_action"`
|
||||
SenderAction SenderAction `json:"sender_action"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user