Reputation: 416
Attempting to display a bot framework VideoCard on facebook messenger. The videocard is displayed, but after a significant delay of around 30 seconds. Kept the size of video to 2.9Mb
Tried minimizing the size of the video, Tried using a facebook URL of the video
Bot is running on botbuilder version 3.14.0
var cards [];
cards.push(new builder.VideoCard(session)
.title('some video title')
.subtitle('some video subtitle')
.media([
{
url:'https://somesite/video-files/video.mp4'
}
])
.buttons([
builder.CardAction.postBack(session,"CONTINUE", continueBtnTxt)
])
);
Upvotes: 0
Views: 292
Reputation: 3712
Each time a Media Template gets sent to Facebook Messenger, the video has to upload which creates the delay between the user's message and the bot's response. If you plan to send the same media attachment multiple times, you can save the video with Facebook's Attachment Upload API. Note, this approach does not work with the BotBuilder Video Cards, but you can send a Messenger Media template through the activity's source event property.
Saving with the Attachment Upload API
You can save the asset by sending a post request to the Attachment Upload API /message_attachments
endpoint. The request should respond with an attachment_id
that we use in the next step.
curl -X POST -H "Content-Type: application/json" -d '{
"message":{
"attachment":{
"type":"image",
"payload":{
"is_reusable": true,
"url":"http://www.messenger-rocks.com/image.jpg"
}
}
}
}' "https://graph.facebook.com/v2.6/me/message_attachments?access_token=<PAGE_ACCESS_TOKEN>"
Sending Messenger Media Template with the BotFramework - Node SDK V3
var message = new botbuilder.Message(session)
.sourceEvent({
facebook: {
attachment: {
type: "template",
payload: {
template_type: "media",
elements: [
{
"media_type": "video",
"attachment_id": '<ATTACHMENT_ID>'
}
]
}
}
}
});
session.send(message);
Hope this helps!
Upvotes: 1