如何在对话框流SDK的V2版本中维护会话? 代理在传递输入查询文本时中断会话。对于每个意图问题,我都会创建新的会话客户端,但会传递相同的会话ID。
// A unique identifier for the given session
const sessionId = req.data.rid;
let config = {
credentials: {
private_key: req.data.agent.private_key,
client_email: req.data.agent.client_email
}
}
const projectId = req.data.agent.projectId;
//this.sessionClient = new dialogflow.SessionsClient(config)
// Create a new session
const sessionClient = new dialogflow.SessionsClient(config);
const sessionPath = sessionClient.sessionPath(projectId, sessionId);
// The text query request.
const request = {
session: sessionPath,
queryInput: req.req.queryInput
};
// Send request and log result
const responses = await sessionClient.detectIntent(request);