MESSAGING
task on the Pagepages_messaging
and pages_manage_metadata
permissionsPOST
request to the /PAGE-ID/nlp_configs
endpoint with the nlp_enabled
parameter set to true
to enable NLP for the Page. You can also include the model
parameter to set a language other than the default, English. curl -i -X POST "https://graph.facebook.com/v25.0/me/nlp_configs
?nlp_enabled=true
&model=PORTUGUESE
&access_token=PAGE-ACCESS-TOKEN"
custom_token
parameter to use your custom Wit.ai app, and update NLP parameters with POST
requests. To disable NLP, send a POST
request with the nlp_enabled
parameter set to false
.nlp
and nlpv2
. The nlp
field is a legacy field using a deprecated naming convention for entity and trait names. The nlpv2
field uses simplified names for entities and traits, as shown below.nlp
field will be removed on June 18, 2024.message
webhooks notification for each message object.| Information | Entity |
|---|---|
| Amount of money
|
amount_of_money
|
| Date/Time
|
datetime
|
| Distance
|
distance
|
| Duration
|
duration
|
| Email address
|
email
|
| Location
|
location
|
| Phone number
|
phone_number
|
| Quantity
|
quantity
|
| Temperature
|
temperature
|
| URL
|
url
|
| Volume
|
volume
|
| Information | Trait |
|---|---|
| Bye (English only)
|
bye
|
| Greetings (English only)
|
greetings
|
| Sentiment
|
sentiment
|
| Thanks (English only)
|
thanks
|
datetime
and sentiment
entities after parsing: {...,
"entities": {
"datetime:datetime": [
{
"id": "340464963587159",
"name": "datetime",
"role": "datetime",
"start": 8,
"end": 23,
"body": "tomorrow at 4pm",
"confidence": 0.9704,
"entities": [],
"type": "value",
"grain": "hour",
"value": "2020-06-16T16:00:00.000-07:00",
"values": [
{
"type": "value",
"grain": "hour",
"value": "2020-06-16T16:00:00.000-07:00"
}
]
}
]
},
"traits": {
"sentiment": [
{
"id": "5ac2b50a-44e4-466e-9d49-bad6bd40092c",
"value": "neutral",
"confidence": 0.6162
}
]
}
messages
Webhooks, you can respond to a message by taking advantage of Default NLP. For example, if you have a handleMessage()
function that responds to each message received, you can use the greetings
entity to send an appropriate response: function firstTrait(nlp, name) {
return nlp && nlp.entities && nlp.traits[name] && nlp.traits[name][0];
}
function handleMessage(message) {
// check greeting is here and is confident
const greeting = firstTrait(message.nlp, 'greetings');
if (greeting && greeting.confidence > 0.8) {
sendResponse('Hi there!');
} else {
// default logic
}
}