首页 > 解决方案 > 在 Bot Framework SDK 4 中,视频上传未被确认为附件

问题描述

我有这个昨天有效的代码。它对视频文件上传的简单请求,验证文件是否为视频格式,然后保存。

视频提示是

var promptOptions = {
            prompt: 'Upload a video',
            retryPrompt: 'The attachment must be a video file.'
        };
        return await step.prompt(VID_PROMPT, promptOptions);

其中 VID_PROMPT 是一个 AttachmentPrompt:

this.addDialog(new AttachmentPrompt(VID_PROMPT, this.videoValidator));

而验证器videoValidator的代码是:

async videoValidator(promptContext) {
        //for back end cheking
        console.log("\n\r Message Type:" + promptContext.context._activity.type);
        console.log("\n\r Message:" + JSON.stringify(promptContext.context._activity.channelData.message));       
        /***************************/
        if (promptContext.recognized.succeeded) {
            var attachments = promptContext.recognized.value;
            var validImages = [];

            attachments.forEach(attachment => {
                if (attachment.contentType === 'video/mp4' || attachment.contentType === 'video/x-msvideo' || attachment.contentType === 'video/mpeg' || attachment.contentType === 'video/3gpp' || attachment.contentType === 'video/3gpp2') {
                    validImages.push(attachment);
                }
            });

            promptContext.recognized.value = validImages;

            // If none of the attachments are valid videos, the retry prompt should be sent.
            return !!validImages.length;
        }
        else {
            await promptContext.context.sendActivity('No attachments received. Please attach video file.');
            return false;
        }
    }

同样,昨天这工作正常(使用相同的代码)但今天,每当我上传视频时: 在此处输入图像描述

它会提示没有收到附件。请附上我的验证器的视频文件 所以我在后面看了看:

在此处输入图像描述

这表示收到的消息不包含附件,当然 AttachmentPrompt 会看到这一点,并且promptContext.recognized.succeeded 将是错误的,因此在我的 videoValidator 中执行 else 子句

现在,我尝试上传图片,只是为了检查它是否会识别附件文件类型: 在此处输入图像描述

并且消息附件必须是视频文件。当它识别出我上传了附件但文件类型不是视频时显示。这是后面的数据:

在此处输入图像描述

我该如何解决。我没有改变任何东西,只是突然没有工作。请帮忙。谢谢!

PS。我使用 botbuilder 4.11.0。

更新:我检查了直达频道及其工作正常。我猜它在 Facebook 频道上不起作用?

更新:现在,即使图像也不会被识别为附件 :(

标签: botframeworkfacebook-messengerfacebook-messenger-bot

解决方案


此问题与 FB webhooks 相关(并且正在运行)请参阅此线程:https ://developers.facebook.com/support/bugs/393441492018560/


推荐阅读