向特定用户发送Bot Framework Node.js临时消息
我已经盯着这个看了好几个小时了,找不到解决方案,尽管根据所有建议,它都应该很容易-
I have been staring at this for hours and can't find a solution and that is even though by all suggestions it SHOULD be quite easy - https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-proactive-messages.
我创建了一个简单的代码,它将注册"用户并将其数据保存在Azure上的cosmosDatabse中.效果很好.
I have created a simple code which will "register" the user and save their data in my cosmosDatabse on Azure. That works perfectly.
//ON "register" SAVE USER DATA AND SAY REGISTERED MESSAGE
bot.dialog('adhocDialog', function(session, args) {
var savedAddress = session.message.address;
session.userData.savedAddress = savedAddress;
//REGISTERED MESSAGE
session.endDialog("*Congratulations! You are now registered in our network! (goldmedal)*");
})
.triggerAction({
matches: /^register$/i
})
- 但是如果满足条件,我该如何访问该特定用户并向他发送消息?(实际上是针对HTTP请求)
- But how can I then access that specific user and send him a message if, say, a condition is met? (in fact on HTTP request)
我敢肯定,我们必须在某个地方写入对话ID或用户ID.问题在哪里?
I am fairly certain we have to write the conversation ID or user ID somewhere. The question is where?
function startProactiveDialog(address) {
bot.beginDialog(address, "A notification!");
}
- 我认为这应该很简单.但是,您在哪里指定用户呢?
我创建了一个users.json文件,我将所有用户保存到该文件中.它以我需要的方式工作.我想数据库会更好,但是我真的不知道从哪里开始.数据库是我尚未遇到的全新篇章,因此在项目需求得到解决后再进行操作就没有意义了.
I created a users.json file, to which I save all the users. It works the way I need it to. I guess database would be better, but I don't really have a clue where to begin with that. Database is a whole new chapter I have not encountered yet, so it doesn't make sense to work on it when the project needs are resolved.