我正在努力将我的机器人仓库分成两个独立的回购
目前,我们有一个功能,我们可以触发机器人启动一个特定的对话框,如果它作为URL中的参数提到。像
这样的东西 https://foo.com/?param=bar
会触发bar
对话框
这是处理它的代码
function(userId,conversationId,params,token){
return new Promise((resolve, reject)=>{
var _directlineAddress = {
bot: {"id":config.BOT.ID, "name": config.BOT.HANDLE},
channelId: "directline",
serviceUrl: config.BOT.DIRECTLINE_URL,
useAuth: true,
user:{"id": userId},
"conversation": {"id": conversationId}
}
if(params.options){
var _re = /^\?(\w+)*=(\w+)*/
var _programType = _re.exec(params.options);
if (_programType[1] === "foo") {
var _dialogId = "*:/foo";
}
else {
var _dialogId = "*:/" + _programType[1];
}
} else {
var _dialogId = "*:/";
var _specialParams = {"sessionId":token};
}
bot.beginDialog(_directlineAddress, _dialogId, _specialParams, function(err){
else{
resolve();
}
});
})
};
由于我将直接线从机器人逻辑中分离出来,我将不再能够访问机器人对象。因此bot.beginDialog
在这里不起作用
有没有办法可以通过发布到Directline API来触发对话框?
答案 0 :(得分:0)
没有。使用Direct Line
,您将能够向僵尸程序发送消息。我想这里的一种方法是定义一条你将通过Direct Line
发送的约定消息,并且机器人逻辑将知道它必须基于它开始一个对话框。