ker0x/messenger

Messaging type should be MESSAGE_TAG for tagged messages.

yaliniyalu opened this issue · 4 comments

Tried to send message with tag
$messenger->send()->message('', '', Send::NOTIFICATION_TYPE_REGULAR, Send::TAG_ISSUE_RESOLUTION);

I got error
Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: POST https://graph.facebook.com/v2.11/me/messages?access_token= resulted in a 400 Bad Request response:
{"error":{"message":"(#100) Messaging type should be MESSAGE_TAG for tagged messages.","type":"OAuthException","code":10 (truncated...)
in /vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113

I don't know whether i made mistake in my code. but it looks like messaging_type is not set correctly so i reported it.

ker0x commented

Hello,

according to the doc, all tags, except NON_PROMOTIONAL_SUBSCRIPTION, can only be used with generic model! Are you using another model ? If so, can you try with the GenericTemplate and keep me updated ?

Anyway, I have to add a check on the tags !

I tried this
$ge = GenericElement::create('title');
$ge->setSubtitle('subtitle');
$message = GenericTemplate::create([$ge->toArray()]);
$messenger->send()->message('1973204866024629', $message, Send::NOTIFICATION_TYPE_REGULAR, Send::TAG_ISSUE_RESOLUTION);

$request->build() in send.php gives
{
"headers": {
"Content-Type": "application/json"
},
"json": {
"messaging_type": "RESPONSE",
"recipient": {
"id": "1973204866024629"
},
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [
{
"title": "title",
"subtitle": "subtitle"
}
]
}
}
},
"notification_type": "REGULAR",
"tag": "ISSUE_RESOLUTION"
},
"query": {
"access_token": ""
}
}

ker0x commented

Ok, forget what i say, i d'ont allow to change the value of messagingType in message() 👎

I will fixed that in the coming day

ker0x commented

@yaliniyalu this is has been fixed in 3.0. You can do like this

$ge = GenericElement::create('title');
$ge->setSubtitle('subtitle');
$message = GenericTemplate::create([$ge]);
$messenger->send()->message('1973204866024629', $message, [
    'notification_type' => Send::NOTIFICATION_TYPE_REGULAR, 
    'tag' => Send::TAG_ISSUE_RESOLUTION,
]);