我需要从机器人模拟器(https://github.com/microsoft/BotFramework-Emulator)发送一个特定的用户ID。我使用这个文本框(见下图)

但什么也没寄出去。在activity.From.Id中绝对有另一个guid。
是否可以使用特定的用户ID从仿真器发送消息?
发布于 2019-10-10 04:57:33
简短的答案是,如果您使用Direct Line从秘密生成令牌,并在其中指定了用户Id (请参阅所附代码),则仿真程序应优先使用该值,而不是您通过仿真程序设置传递的任何值。
在我个人的测试中,用户ID设置似乎覆盖了任何其他预先存在的值。
但是,需要注意的是,如果在设置中指定了用户ID值,则需要关闭选项卡式对话,并通过重新输入消息传递端点和AppId/AppPassword (或重新连接到.bot文件,如果使用)来重新启动对话。简单地按“重新启动对话”不会使Emulator获得用户ID设置。
希望能帮上忙!
// Listen for incoming requests.
server.post('/directline/token', (req, res) => {
// userId must start with `dl_` for Direct Line enhanced authentication
const userId = (req.body && req.body.id) ? req.body.id : `dl_${ Date.now() + Math.random().toString(36) }`;
const options = {
method: 'POST',
uri: 'https://directline.botframework.com/v3/directline/tokens/generate',
headers: {
'Authorization': `Bearer ${ process.env.directLineSecret }`
},
json: {
user: {
Id: `${ userId }`
}
}
};
request.post(options, (error, response, body) => {
if (!error && response.statusCode < 300) {
res.send(body);
console.log('Someone requested a token...');
} else {
res.status(500).send('Call to retrieve token from DirectLine failed');
}
});
});


https://stackoverflow.com/questions/58285599
复制相似问题