fix: Reset session when user says "서버 추천" during active session
When user requests server recommendation while in an existing session (e.g., selecting state), reset the session and start fresh instead of continuing the old session context. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -507,6 +507,26 @@ export async function processServerConsultation(
|
|||||||
return '상담이 취소되었습니다. 다시 시작하려면 "서버 추천"이라고 말씀해주세요.';
|
return '상담이 취소되었습니다. 다시 시작하려면 "서버 추천"이라고 말씀해주세요.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "서버 추천" 키워드로 새로 시작 요청 (기존 세션 리셋)
|
||||||
|
if (/서버\s*추천/.test(userMessage)) {
|
||||||
|
await deleteServerSession(env.SESSION_KV, session.telegramUserId);
|
||||||
|
logger.info('서버 추천 키워드로 세션 리셋', {
|
||||||
|
userId: session.telegramUserId,
|
||||||
|
previousStatus: session.status
|
||||||
|
});
|
||||||
|
// 새 세션 생성하고 시작 메시지 반환
|
||||||
|
const newSession: ServerSession = {
|
||||||
|
telegramUserId: session.telegramUserId,
|
||||||
|
status: 'gathering',
|
||||||
|
collectedInfo: {},
|
||||||
|
messages: [],
|
||||||
|
createdAt: Date.now(),
|
||||||
|
updatedAt: Date.now()
|
||||||
|
};
|
||||||
|
await saveServerSession(env.SESSION_KV, session.telegramUserId, newSession);
|
||||||
|
return '안녕하세요! 서버 추천을 도와드리겠습니다. 😊\n\n어떤 서비스를 운영하실 건가요?\n예: 블로그, 쇼핑몰, 커뮤니티, API 서버 등';
|
||||||
|
}
|
||||||
|
|
||||||
// 선택 단계 처리
|
// 선택 단계 처리
|
||||||
if (session.status === 'selecting' && session.lastRecommendation) {
|
if (session.status === 'selecting' && session.lastRecommendation) {
|
||||||
const selectionMatch = userMessage.match(/(\d+)(?:번|번째)?|첫\s*번째|두\s*번째|세\s*번째/);
|
const selectionMatch = userMessage.match(/(\d+)(?:번|번째)?|첫\s*번째|두\s*번째|세\s*번째/);
|
||||||
|
|||||||
Reference in New Issue
Block a user