SDK
- 主页:https://github.com/Microsoft/BotBuilder
- SDK 平台:Node.js
- SDK 版本:3.14.0
问题描述
你好,这个问题我找了好久了,还是没有找到答案。 我想知道是否有办法将一些 URL 参数绑定(bind)到用户的机器人 session 。 例如,如果对于特定的聊天对话框,我将端点 URL 设置为:
http://localhost:3978/api/messages?pronuntiation=british
有没有办法在 session 对象中获取名为“pronuntiation”的 url 参数,例如...
bot.dialog("/", function(session){
var desiredPronuntiation = session.someUrlParameters.pronuntiation;
if( desiredPronuntiation == "british"){
///blah
}
});
我认为在 C# SDK 中这是可能的,但我试图在 NodeJS 中做到这一点...
我已经调试了从 server.post('/api/messages', Connector.listen())
到 ChatConnector.verifyBotFramework()
的进程,其中最后我发现它调用 _this.dispatch(req.body, res, next);
(ChatbotConnector.js 第 149 行)仅传递帖子正文,但不传递请求对象本身...
所以乍一看我认为这是不可能的,我只是想确保我没有错过任何东西...... 谢谢, 路易斯
最佳答案
据我所知,Bot 框架不支持这一点,但我不明白为什么你需要这样做。这是您想要存储在状态中的内容,例如 userData
。您可以阅读更多here关于managing state in the Bot Framework .
如果您想将用户数据传递给机器人,这取决于 channel 。例如,Facebook 和 Webchat 允许您将数据直接传递给机器人,无需用户输入。
关于node.js - 用于 NodeJS 的 Microsoft/Botbuilder : Bind URL Parameters to bot session,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49364330/