I was wondering if it is possible to have a messenger bot send you a youtube video link and generate a playable video inside messenger the same way you can if you paste a link inside the messenger. Right now my bot can send a message with a youtube link but it just sends it as text it doesn't generate a video recognizing the title, description etc. Any help would be appreciated.
-
i guess this would need to be able to "parse" youtube link like the bot is sending which it does automatically with users :( there is no way to do that now – user151496 Nov 14 '16 at 16:24
4 Answers
You can also send by OpenGraph. It will automatically display the video inside m.me chat window but in mobile iOS app, currently it redirects to youtube page:
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"USER_ID"
},
"message":{
"attachment":{
"type":"template",
"payload":{
"template_type":"open_graph",
"elements":[
{
"url":"https://www.youtube.com/watch?v=y9A1MEbgLyA"
}
]
}
}
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=$TOKEN"

- 2,171
- 21
- 17
-
https://developers.facebook.com/docs/messenger-platform/open-graph-template This is the correct answer. – baquiax Jul 12 '17 at 22:52
-
-
Open Graph Template is deprecated since V4.0 (2019) How we can do this now? – kio21 May 31 '21 at 14:44
As of 7/1/2016, the new API docs allow video messages assuming you've got the url of the actual mp4 file. For a youtube video, that url is (purposefully) not easy to get to. There are some tools, like youtube-dl, that will get the url of a file from YouTube and it would be possible to use that url with a facebook video message. This setup is of course assuming facebook does not have any blocking in place for youtube video links.
Another approach would be to build your own combo thumbnail/video link message using a "generic template" facebook message.

- 613
- 6
- 5
-
Combo approach seems good since it is easy to get the thumbnails (See http://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api), then simply have Play button that links out to the video – Metablocks Corp Aug 01 '16 at 06:41
-
You can also use something like this (https://github.com/halgatewood/youtube-thumbnail-enhancer) to add a play icon on top of the video thumbnail – Metablocks Corp Aug 01 '16 at 06:44
-
Calling a YouTube video through the direct mp4 link is very slow. Could it be that Facebook is downloading that video completely before it plays it? – Marc May 15 '17 at 03:47
You can send Video with size <= 30MB with following code.
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"USER_ID"
},
"message":{
"attachment":{
"type":"video",
"payload":{
"url":"direct_url_to_video",
"is_reusable":true
}
}
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=ACCESS_TOKEN"
After that, above command will return "attachment_id" of video From now, you can send video with attachment_id and never expire.
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"USER_ID"
},
"message":{
"attachment":{
"type":"video",
"payload":{
"attachment_id": "<attachment_id_here"
}
}
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=ACCESS_TOKEN"

- 341
- 2
- 4
I found a temporary solution (videos may expire). Try this site: http://catchvideo.net/. It will give you the playable video link you can use your bot to send in the messenger as an attachment. Hope this helps!
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"USER_ID"
},
"message":{
"attachment":{
"type":"video",
"payload":{
"url":"THE_LINK_FROM_WEBSITE_ABOVE" (example: https://redirector.googlevideo.com/videoplayback?itag=18.....)
}
}
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=ACCESS_TOKEN"

- 111
- 7