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

Commit

Permalink
Merge pull request #59 from dfischer/get-nlp-v2
Browse files Browse the repository at this point in the history
Get nlp v2
  • Loading branch information
paked authored Apr 24, 2019
2 parents 19ba0ed + 34895fc commit 8417146
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion message.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package messenger

import "time"
import (
"encoding/json"
"time"
)

// Message represents a Facebook messenger message.
type Message struct {
Expand All @@ -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
Expand Down Expand Up @@ -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)
}

0 comments on commit 8417146

Please sign in to comment.