[英]Facing Error: File attachments aren’t supported for this bot for MS Teams Bot built using Bot Framework SDK
我使用 Node.js Bot Framework SDK 和 VS Studio Code 的 Teams Toolkit 扩展创建了一个 MS Teams 机器人。 当我使用 ngrok 和 Bot Framework Emulator 在本地对其进行测试时,该机器人工作得非常好。 所有附件都已成功发送给用户。 但是,当我在 Azure 上部署机器人并在 Teams 频道上进行测试时,它会出现Error: File attachments aren't supported
错误。
附件.js
async function getInternetAttachment(filename, contentType, file_url) {
// NOTE: The contentUrl must be HTTPS.
return {
name: "sample.mp4",
contentType: "video/mp4,
contentUrl: "" // Content url
};
}
我使用相同的代码来发送执行时没有任何错误的图像文件,但是在发送视频或 pdf 文件时,它会给出上述错误。 任何帮助或建议表示赞赏
我们可以使用三种不同的场景来解决这个问题。
根据需求,我们可以使用处理附件操作来实现附件。 使用下面的代码块,我们将附加附件 object来处理正在上传的数据。 该代码块可以在模拟器中进行测试。
var bot = new builder.UniversalBot(connector, function (session) {
var msg = session.message;
if (msg.attachments && msg.attachments.length > 0) {
// Echo back attachment
var attachment = msg.attachments[0];
session.send({
text: "You sent:",
attachments: [
{
contentType: attachment.contentType,
contentUrl: attachment.contentUrl,
name: attachment.name
}
]
});
} else {
// Echo back users text
session.send("You said: %s", session.message.text);
}
});
contentType和contentURL将有助于确定附件操作。 异议类型和 URL 必须在session 中定义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.