node.js - 用于 NodeJS 的 Microsoft/Botbuilder : Bind URL Parameters to bot session

标签 node.js botframework

SDK

问题描述

你好,这个问题我找了好久了,还是没有找到答案。 我想知道是否有办法将一些 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/

相关文章:

node.js - 使用 faye 通过 websockets 发送 javascript 对象

javascript - Node.js 中不必要的回调使用?

botframework - 为每个客户提供独特 channel 的 Multi-Tenancy 机器人

python - 我想知道如何使用Bot框架SDK for python设置自适应卡的主机配置

javascript - 如何在 async.js waterfall 流中传递上下文或属性?

javascript - 运行 npm start 时无法执行启动脚本

azure - MS bot服务消息端点可以检测用户的编辑行为吗?

javascript - 与 Direct line Microsoft Bot Framework 一起使用的自定义聊天机器人用户界面或客户端

botframework - Microsoft Teams 机器人消息扩展 : invoke/selectItem not working as expected

node.js - 将 Angular 应用程序部署到 Heroku 时出现 "violates the following Content Security Policy directive: "default-src 'none' ". 错误