在BotFramework(NodeJS)上,我试图复制https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-send-receive-attachments处提供的演示版。它实际上运作良好。
ms文章更改时的代码:
// Create your bot with a function to receive messages from the user
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);
}
});
但是,我遇到的问题是,当我从Skype(普通)拨打电话时,收到错误消息:
2017-12-07T02:16:15.815Z Error: POST to 'https://smba.trafficmanager.net/apis/v3/conversations/<My Conversation>/activities' failed: [400] Bad Request
at Request._callback (/app/node_modules/botbuilder/lib/bots/ChatConnector.js:545:46)
at Request.self.callback (/app/node_modules/request/request.js:186:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.<anonymous> (/app/node_modules/request/request.js:1163:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (/app/node_modules/request/request.js:1085:12)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
有什么想法吗?
[更新:仅在我创建附件响应时才会发生。所以我希望这就是我有问题的地方]
答案 0 :(得分:0)
实际上,MS网站上的代码不是最新的(在某种程度上)。
如果我按照https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/core-ReceiveAttachment
上显示的代码进行操作例如,我可以收到附件并将其保存在公共文件夹的某个位置。一旦完成,我就可以发回&#34; public&#34; URL作为附件,然后它可以工作。