Facebook messenger bot quick reply with image_url only not working - facebook

I created my nodejs facebook messenger chatbot and everything is working fine, except quick replies with images only.
according to the Facebook documentation:
You may also send a quick reply with an image and an empty title string to create an icon-only quick reply.
When I send an image with the title attribute I get the quick reply prepended with the image correctly, however when I put an empty string in the title attribute to show an "Only-icon" quick reply, it doesn't work.
JSON that works:
{
"content_type": "text",
"title": 'Any text here',
"payload": '',
"image_url": "Link/To/Img"
}
JSON that doesn't work:
{
"content_type": "text",
"title": '', // (Change is here) Empty title
"payload": '',
"image_url": "Link/To/Img"
}
I have been stuck for hours in this matter, thanks in advance for your help.

Related

Can't create a Facebook Page post with a MESSAGE_PAGE cta button

Could you please give me a suggestion? I want to create a Post with a picture and a CTA button “MESSAGE_PAGE” via Graph API, but it’s not working.
I’ve tried to create a Post this way (using Page Access Token):
POST request: https://graph.facebook.com/v13.0/<Page_ID>/feed
POST body:
{
"message": "<MSG>",
"published": "false",
"attached_media": [
"{\"media_fbid\":\"<MEDIA_ID>\"}"
],
"call_to_action": {
"type": "MESSAGE_PAGE",
"value": {}
}
}
As a result, I get a hidden Post with an image and my text, published by my application on my Page, but no button on it.
At the same time, I can create such Posts manually via a web browser.
If I change the CTA type to LEARN_MORE and pass a link - the CTA button is created normally, but the image is dropped.
How could I create a Post with an image and a MESSAGE_PAGE CTA button?

How to get the text of message, when quick reply is tapped in facebook messanger bot?

Question related to API.AI Bot , Facebook Messanger
When a Quick Reply is tapped, a text message will be sent to your webhook Message Received Callback. The text of the message will correspond to the title of the Quick Reply, when the content type is 'text'. How can we get the text of message! when the content type is 'location'?. It is mentioned that when we use location quick reply, we don't add title field. so how can we get a text message without using title?
I am unable to call webhook, due to not getting text of the message.
Please help me out. I am stuck from last 2 days.
You can manipulate with ChannelData.
hehe I got your Problem
I hope you know the responses coming from webhook if not here is sample responses
responses for quick_reply with type text
"message": {
"quick_reply": {
"payload": "productId-12345678"
},
"mid": "mid.$cAAFXVKjn1KtjtBAtHFdgsrkbGWwm",
"seq": 15453,
"text": "buy this"
}
responses for quick_reply with type location
"message": {
"mid": "mid.$cAAFXVLGKMJ1jtApB51dgsTnITNet",
"seq": 25413,
"attachments": [
{
"title": "Hi-tech city Hyderabad",
"url": "https://l.facebook.com/l.php?u=https%3A%2F%2Fwww.bing.com%2Fmaps%2Fdefault.aspx%3Fv%3D2%26pc%3DFACEBK%26mid%3D8100%26where1%3DHyderabad%2B500081%26FORM%3DFBKPL1%26mkt%3Den-US&h=ATPXrPSDsyApPyqD9ozWt82dL9M28VZPQCqmICpsmBfXY0BCffiP4ychQ36sSWUNNBOeiJZq8tq8DLF7-A0_7VViPwwC64LM1XR-uAUN0sXdcgP5rDg&s=1&enc=AZPs1nCI5B8J4s27b7zAJKJDYaa2KSlhxQ5ppN30fb5lI3KUFcnQlSn_g4796j3p4ShwnzPvRyqXS470lEluzN06",
"type": "location",
"payload": {
"coordinates": {
"lat": 17.44521051,
"long": 78.38363399
}
}
}
]
}
as you can see that in text type quick_reply we are getting the previous context as text to which user respond and we can use respective payload for processing. This is what facebook try to incorporate context of chat for a single time for quick reply they havnt incorporated this to other may be because of frequent use of context in case of text quick_reply rather than location.
Now the things which you are wondering about is context . Yes you need to maintain context of chat and thats how a real bot thing came into picture. you can maintain context of chat using many free nlp engine like wit.ai , api.ai and other

Get scraped data from facebook graph api using url reliably

My app needs to get data facebook scrapes from URLs. Up until now we were getting it using
POST /?id={object-instance-id or object-url}&scrape=true
Which is detailed in updating object section in https://developers.facebook.com/docs/sharing/opengraph/using-objects
For example
POST /?id=http://google.com
{
"url": "http://www.google.com/",
"type": "website",
"title": "Google",
"image": [
{
"url": "http://www.google.com/images/branding/googleg/1x/googleg_standard_color_128dp.png"
}
],
"description": "Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.",
"updated_time": "2015-10-06T11:34:58+0000",
"id": "381702034999"
}
Notice image section.
Unfortunately if og tags are configured wrongly on the server
POST /?id=http://some.page.with.bad.tags.com
{
"error": {
"message": "Invalid parameter",
"type": "FacebookApiException",
"code": 100,
"error_subcode": 1611016,
"is_transient": false,
"error_user_title": "Object Invalid Value",
"error_user_msg": "Object at URL 'http://some.page.with.bad.tags' of type '' is invalid because the given value '/some-bad-value' for property 'og:url' could not be parsed as type 'url'.",
"fbtrace_id": "abcabcabc"
}
}
Which returns nothing interesting.
Attempt to GET the url returns this:
{
"og_object": {
"id": "381702034999",
"description": "Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.",
"title": "Google",
"type": "website",
"updated_time": "2015-10-06T11:40:04+0000",
"url": "http://www.google.com/"
},
"share": {
"comment_count": 2,
"share_count": 13494003
},
"id": "http://www.google.com"
}
Which misses image section. I cannot find in the documentation any way to retrieve result with images without using POST /?id={url}, but that fails on any errors in og tags.
GET /{ObjectId}
returns only type and created_time
Entering the same broken link in https://developers.facebook.com/tools/debug/ results in page which contains image, description, title and captions for the page. Which I need. So it means facebook stores them, even though page has wrong tags, but I need a way to fetch them. Unfortunatelly I cannot provide link for broken url due to NDA, and I couldn't find other page with broken tags.
If the page contains invalid Open Graph markup this seems expected, also do not confuse the Graph API with some sort of datasource or a scraping service you can utilize to generate the preview for web content.
If Facebook , for whatever reason, can't parse the Open Graph tags of a URL it will try to make a good guess based on the content of the page (large junks of text, images it finds, title tags etc.) to build the preview so you might get some sort of data back from GET /{object-id} which can just be a guess instead of actual og:.. data.
In case you really need a more or less failsafe solution, you could build your own scraper that looks for Open Graph tags.

How I can give a link to the caption of audio post on the wall

Hey!! I have made an application through which I am publishing an audio file to the wall in facebook. Further I want to give a clickable caption, that when get a click take me to some url. Can somebdy plz help me in sorting it out....
Thanx in advance...!
You need to send media as an attachment with your publish request.
{"media": [{
"type": "music",
"src": "URL_OF_MEDIA",
"title": "NAME_OF_AUDIO_CLIP",
"artist": "ARTIST",
"album": "ALBUM"
}]}
Docs here: http://developers.facebook.com/docs/guides/attachments

How to format facebook status retrieved using status.get

When I retrieve my facebook status through facebook API, using status.get, the informations comes in the form of
[
{
"message": "Does anyone here knows how to disappear and reappear again after a few months??",
"time": 1282146230,
"status_id": 00000000000000,
"source": 2915120374,
"uid": 000000000
},
{
"message": "Blah blah and blah",
"time": 1282073572,
"status_id": 00000000000000,
"source": 2915120374,
"uid": 000000000
}
]
I want to format the information using css and display the updates on my blog. How do I extract the info from the above retrieved format so that I can use it on my php page and use css to style the updates??
This is called JSON format. If you scroll to the bottom on the JSON site you will find a huge list of available libraries for pretty much every language.