Direct message with quick reply received without buttons

directmessages
quickreplies
json

#1

Hi,

I am developing a bot that needs quick reply on direct messages.

The best I could get on quick reply is with this trurl:

twurl -t -A ‘Content-type: application/json’ /1.1/direct_messages/events/new.json -d ‘{“event”:{“type”:“message_create”,“message_create”:{“target”:{“recipient_id”:“999999999”},“message_data”:{“text”:“What syourfavoritetypeofbird?”,“quick_reply”:{“type”:“options”,“options”:[{“label”:“RedBird”,“description”:“Adescriptionabouttheredbird.”,“metadata”:“external_id_1”},{“label”:“BlueBird”,“description”:“Adescriptionaboutthebluebird.”,“metadata”:“external_id_2”},{“label”:“BlackBird”,“description”:“Adescriptionabouttheblackbird.”,“metadata”:“external_id_3”},{“label”:“WhiteBird”,“description”:“Adescriptionaboutthewhitebird.”,“metadata”:“external_id_4”}]}}}}}’

The json i taken from the official docs, just edited recipient_id, removed line breaks and the ’ in what’s.

Of course the account is authorized.
When I run this the destination user gets the text part only, buttons are completely ignored. Any advice? I suppose there is something wrong in my Json, but I cannot find it.


#2

I guess there is an issue wiht your json request

Check the below request which i have sent, and which gave the desired result

{
“event”: {
“type”: “message_create”,
“id”: “935405262147637252”,
“created_timestamp”: “1511852968142”,
“message_create”: {
“target”: {
“recipient_id”: “8888”
},
“sender_id”: “89898989”,
“message_data”: {
“text”: “What syourfavoritetypeofbird?”,
“entities”: {
“hashtags”: [],
“symbols”: [],
“user_mentions”: [],
“urls”: []
},
“quick_reply”: {
“type”: “options”,
“options”: [
{
“label”: “RedBird”,
“metadata”: “external_id_1”,
“description”: “Adescriptionabouttheredbird”
},
{
“label”: “BlueBird”,
“metadata”: “external_id_2”,
“description”: “Adescriptionaboutthebluebird”
}
]
}
}
}
}
}

One of the fastest way to check if your json is valid or not is to try formatting them .

For exmaple :

Try formating your request here https://www.freeformatter.com/json-formatter.html (Your request doesnt parse as it is not a valid json).

Hope it helps…

Regards,
Sajid


#3

Great! It works.
Is it possible to send emoji as well as text in buttons text?


#4

Yup it works…
Try sending emojis by utf-8 encoding.
Regards,
Sajid