1
0
mirror of synced 2024-11-25 14:26:09 +03:00

Merge pull request #59 from dfischer/get-nlp-v2

Get nlp v2
This commit is contained in:
Harrison Shoebridge 2019-04-25 09:23:14 +10:00 committed by GitHub
commit 841714601c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,9 @@
package messenger
import "time"
import (
"encoding/json"
"time"
)
// Message represents a Facebook messenger message.
type Message struct {
@ -25,6 +28,9 @@ type Message struct {
Attachments []Attachment `json:"attachments"`
// Selected quick reply
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
@ -84,3 +90,9 @@ func (d Delivery) Watermark() time.Time {
func (r Read) Watermark() time.Time {
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)
}