1
0
mirror of synced 2024-11-24 13:56:06 +03:00

Sender actions support

This commit is contained in:
Pavel 2022-07-29 15:40:30 +03:00
parent 243bf4a2b2
commit 5bdc2eb804
3 changed files with 30 additions and 4 deletions

View File

@ -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"
)

View File

@ -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 {

View File

@ -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,
@ -547,6 +547,6 @@ type StructuredMessageButton struct {
// SendSenderAction is the information about sender action.
type SendSenderAction struct {
Recipient Recipient `json:"recipient"`
SenderAction string `json:"sender_action"`
Recipient Recipient `json:"recipient"`
SenderAction SenderAction `json:"sender_action"`
}