Skip to content
This repository was archived by the owner on Jan 1, 2023. It is now read-only.

Commit 8417146

Browse files
authored
Merge pull request #59 from dfischer/get-nlp-v2
Get nlp v2
2 parents 19ba0ed + 34895fc commit 8417146

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

message.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package messenger
22

3-
import "time"
3+
import (
4+
"encoding/json"
5+
"time"
6+
)
47

58
// Message represents a Facebook messenger message.
69
type Message struct {
@@ -25,6 +28,9 @@ type Message struct {
2528
Attachments []Attachment `json:"attachments"`
2629
// Selected quick reply
2730
QuickReply *QuickReply `json:"quick_reply,omitempty"`
31+
// Entities for NLP
32+
// https://developers.facebook.com/docs/messenger-platform/built-in-nlp/
33+
NLP json.RawMessage `json:"nlp"`
2834
}
2935

3036
// Delivery represents a the event fired when Facebook delivers a message to the
@@ -84,3 +90,9 @@ func (d Delivery) Watermark() time.Time {
8490
func (r Read) Watermark() time.Time {
8591
return time.Unix(r.RawWatermark/int64(time.Microsecond), 0)
8692
}
93+
94+
// GetNLP simply unmarshals the NLP entities to the given struct and returns
95+
// an error if it's not possible
96+
func (m *Message) GetNLP(i interface{}) error {
97+
return json.Unmarshal(m.NLP, &i)
98+
}

0 commit comments

Comments
 (0)