0

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

有任何想法吗?

[更新:仅在我创建附件响应时才会发生。所以我希望这就是我有问题的地方]

4

1 回答 1

0

实际上 MS 网站上的代码不是最新的(在某种程度上)。

如果我遵循以下可见的代码:https ://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/core-ReceiveAttachment

例如,我可以接收附件并将其保存在公用文件夹的某个位置。完成后,我可以将“公共”URL 作为附件发回,然后它就可以工作了。

于 2017-12-07T02:52:10.700 回答