无法通过bot向FB Messenger发送音频附件

时间:2017-01-09 08:58:25

标签: node.js botframework botbuilder

我无法通过botbuilder发送音频附件。我是最新版本的botbuilder。下面是我正在使用的代码片段。我尝试了所有不同的选择,但没有任何工作。有人可以解释为什么会发生这种情况吗?

var msg = new builder.Message(session).
sourceEvent( 
{facebook: { attachment: 
{ type: "audio", payload: 
{ url:"https://petersapparel.com/bin/clip.mp3" } } } }); 
session.send(msg);

我收到以下错误

Error: Request to 'https://facebook.botframework.com/v3/conversations/1106358962795256-204426340019460/activities/38b93pDlg4a' failed: [400] Bad Request at Request._callback (/workspace/FranceSayBot/node_modules/botbuilder/lib/bots/ChatConnector.js:413:46) at Request.self.callback (/workspace/FranceSayBot/node_modules/request/request.js:186:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request.<anonymous> (/workspace/FranceSayBot/node_modules/request/request.js:1081:10) at emitOne (events.js:96:13) at Request.emit (events.js:188:7) at IncomingMessage.<anonymous> (/workspace/FranceSayBot/node_modules/request/request.js:1001:12) at IncomingMessage.g (events.js:292:16) at emitNone (events.js:91:20)

1 个答案:

答案 0 :(得分:0)

无需使用SourceEvent。将其作为附件发送:

// Create and send attachment
var attachment = {
    contentUrl: 'https://petersapparel.com/bin/clip.mp3',
    contentType: 'audio/mpeg',
    name: 'My video clip'
};

var msg = new builder.Message(session)
    .addAttachment(attachment);

session.send(msg);