1
0
mirror of synced 2024-11-24 22:06:06 +03:00
This commit is contained in:
Daniel Fischer 2019-03-25 11:48:35 -07:00
parent faf2432c8f
commit 6d0aa90aae

View File

@ -1,6 +1,9 @@
package messenger package messenger
import "time" import (
"encoding/json"
"time"
)
// Message represents a Facebook messenger message. // Message represents a Facebook messenger message.
type Message struct { type Message struct {
@ -25,6 +28,9 @@ type Message struct {
Attachments []Attachment `json:"attachments"` Attachments []Attachment `json:"attachments"`
// Selected quick reply // Selected quick reply
QuickReply *QuickReply `json:"quick_reply,omitempty"` QuickReply *QuickReply `json:"quick_reply,omitempty"`
// Entities for NLP
// https://developers.facebook.com/docs/messenger-platform/built-in-nlp/
NLP json.RawMessage `json:"nlp"`
} }
// Delivery represents a the event fired when Facebook delivers a message to the // Delivery represents a the event fired when Facebook delivers a message to the
@ -84,3 +90,9 @@ func (d Delivery) Watermark() time.Time {
func (r Read) Watermark() time.Time { func (r Read) Watermark() time.Time {
return time.Unix(r.RawWatermark/int64(time.Microsecond), 0) return time.Unix(r.RawWatermark/int64(time.Microsecond), 0)
} }
// GetNLP simply unmarshals the NLP entities to the given struct and returns
// an error if it's not possible
func (m *Message) GetNLP(i interface{}) error {
return json.Unmarshal(m.NLP, &i)
}