显示 botframework VideoCard 时延迟 facebook messenger

Delay on facebook messenger when displaying a botframework VideoCard

正在尝试在 Facebook Messenger 上显示机器人框架 VideoCard。显示视频卡,但在大约 30 秒的显着延迟之后。将视频大小保持在 2.9Mb

尝试最小化视频的大小, 尝试使用视频

的 facebook URL

Bot 在 botbuilder 版本 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)
        ])
        );

每次将媒体模板发送到 Facebook Messenger 时,都必须上传视频,这会在用户消息和机器人响应之间造成延迟。如果您打算多次发送相同的媒体附件,您可以使用 Facebook 的附件上传 API 来保存视频。请注意,此方法不适用于 BotBuilder 视频卡,但您可以通过 activity 的源事件 属性.

发送 Messenger Media 模板

使用 Attachment Upload API

保存

您可以通过向附件上传 API /message_attachments 端点发送 post 请求来保存资产。该请求应使用我们在下一步中使用的 attachment_id 进行响应。

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>"

使用 BotFramework - Node SDK V3 发送 Messenger Media Template

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);

希望对您有所帮助!