Here is my json:
var messageData = {
"recipient" : {
"id": recipientId
},
"message": [
{
"text": 'Text 1'
},
{
"text": 'Text2!'
}
]
}
I send it through this function:
function callSendAPI(messageData) {
request({
uri: 'https://graph.facebook.com/v2.10/me/messages',
qs: { access_token: my_PAGE_ACCESS_TOKEN },
method: 'POST',
json: messageData
}, function (error, response, body) {
if (!error && response.statusCode == 200) {
var recipientId = body.recipient_id;
var messageId = body.message_id;
console.log("Successfully sent the message with id %s to recipient %s",
messageId, recipientId);
} else {
console.error("Unable to send message.");
console.error(response);
console.error(error);
}
});
}
It shows me this error:
(#100) Must send either message or state'
Do you guys know what format for messageData should I use to send multiple messages? It works fine when I only send one that is not in an array.
Please help. This works in Firebase webhook in DialogFlow, so I don’t know why it’s not working.