var context id="";
我在我的bot.dialoge之外声明这个上下文id以保存我的用户的上下文ID但是对于所有用户来说它变得相同我如何管理该上下文id对于用户的会话保持相同
bot.dialog('/', [
function (session) {
var question=session.message.text;
session.send(question);
var id="";
var request = require('request'),
url="https://api.projectoxford.ai/luis/v2.0/apps/76c-4784-a26d-b? subscription-key=15f282c1&q=";
var url1=url+question;
url1+="&contextId=";
url1+=contextId ;//complete url to request with context id;
session.send(" i am here i function %s",url1);
session.send(" i am sessionid %s",session.id );
var luis_question=""//variable question generated by luis api;
request({
url: url1,
json: true
}, function (error, response, body) {
if (!error && response.statusCode === 200)
{
if(body.topScoringIntent.intent!="None")
{
session.send( "i am in intent %s",body.topScoringIntent.intent);
session.id=body.dialog.contextId;
session.send("i am in prompt %s",session.id);
我从这里获取上下文ID 关联标识符= body.dialog.contextId; session.send( 'ADDRES “%S”',session.message.address);
session.send(" %s",body.dialog.prompt);
session.send(" %s",body.dialog.status);
if(body.dialog.status=="Finished")
{
contextId ="";
session.send(" Thanks for co operation");
}
}
else
session.send(" Please ask relevant question");
/* session.send( body.dialog.status);
session.send("i am in prompt %s",body.entities[0].entity); */
}
}
)
}
]);
答案 0 :(得分:0)
我不清楚你想要完成什么,但是使用SDK的内置存储系统存储用户特定数据。
保存数据:
session.userData.{fieldName} = {value};
要检索:
session.userData.{fieldName}
请注意,这仅限于32k。示例here。