I'm using the Akinator API with this latest aki-api package in my project to create a web application where users can interact with Akinator. However, I'm encountering an issue where Akinator keeps asking the same question after several user responses.
Steps Taken
Ensured proper session management on my server.
Used the latest version of the Akinator API.
Added additional logging to check Akinator's response after each step, and found that the question does not change after several user responses.
Environtment I Use
Debian 11
NodeJS 21
Reproduction Steps
Start a new session with Akinator.
Provide several different answers to the questions posed by Akinator.
Notice that after a few responses, Akinator continues to ask the same question.
Log
root@debian-s-4vcpu-8gb-240gb-intel-sgp1-01:/var/www/api/backend# node server.js
(node:214478) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Server berjalan di http://localhost:3000
API keys loaded successfully
Starting a new Akinator session with region: id
Session started with question: Apakah dia berkelamin perempuan?
Received answer for session 7e03a93c-7e13-4b2e-a01b-b7d8490eefd7: Iya
Akinator response: Akinator {
currentStep: 1,
region: 'id',
uri: 'https://id.akinator.com',
guess: undefined,
progress: 12.4796,
step_last_proposition: '',
guessCount: 0,
childMode: false,
config: {},
question: 'Apakah dia bernyanyi di panggung?',
answers: [ 'Iya', 'Tidak', 'Tidak tahu', 'Mungkin', 'Mungkin tidak' ],
session: '1EuIYt2+wUuiWAS1rAWyNRZytqxYZgerwAprpOj3IZv57XfUUKtJrtGN9mHzHOp6mstO7fpoz1TQ21RN+8WqOw==',
signature: '3/D5n/0Xc5SS5xATHWrKxxKSnUVxqMDpYIdvhS02+eWbV/GLHwE60Xl4nUXwnr5MAHgPaf/Jj6l+VEy91pVu+Q=='
}
Next question: Apakah dia bernyanyi di panggung?
Received answer for session 7e03a93c-7e13-4b2e-a01b-b7d8490eefd7: Tidak
Akinator response: Akinator {
currentStep: 2,
region: 'id',
uri: 'https://id.akinator.com',
guess: undefined,
progress: 35.5399,
step_last_proposition: '',
guessCount: 0,
childMode: false,
config: {},
question: 'Apakah dia seorang muslim?',
answers: [ 'Iya', 'Tidak', 'Tidak tahu', 'Mungkin', 'Mungkin tidak' ],
session: '1EuIYt2+wUuiWAS1rAWyNRZytqxYZgerwAprpOj3IZv57XfUUKtJrtGN9mHzHOp6mstO7fpoz1TQ21RN+8WqOw==',
signature: '3/D5n/0Xc5SS5xATHWrKxxKSnUVxqMDpYIdvhS02+eWbV/GLHwE60Xl4nUXwnr5MAHgPaf/Jj6l+VEy91pVu+Q=='
}
Next question: Apakah dia seorang muslim?
Received answer for session 7e03a93c-7e13-4b2e-a01b-b7d8490eefd7: Tidak
Akinator response: Akinator {
currentStep: 3,
region: 'id',
uri: 'https://id.akinator.com',
guess: undefined,
progress: 47.9979,
step_last_proposition: '',
guessCount: 0,
childMode: false,
config: {},
question: 'Apakah dia berambut pendek?',
answers: [ 'Iya', 'Tidak', 'Tidak tahu', 'Mungkin', 'Mungkin tidak' ],
session: '1EuIYt2+wUuiWAS1rAWyNRZytqxYZgerwAprpOj3IZv57XfUUKtJrtGN9mHzHOp6mstO7fpoz1TQ21RN+8WqOw==',
signature: '3/D5n/0Xc5SS5xATHWrKxxKSnUVxqMDpYIdvhS02+eWbV/GLHwE60Xl4nUXwnr5MAHgPaf/Jj6l+VEy91pVu+Q=='
}
Next question: Apakah dia berambut pendek?
Received answer for session 7e03a93c-7e13-4b2e-a01b-b7d8490eefd7: Tidak tahu
Akinator response: Akinator {
currentStep: 4,
region: 'id',
uri: 'https://id.akinator.com',
guess: undefined,
progress: 63.9015,
step_last_proposition: '',
guessCount: 0,
childMode: false,
config: {},
question: 'Apakah dia memiliki suami?',
answers: [ 'Iya', 'Tidak', 'Tidak tahu', 'Mungkin', 'Mungkin tidak' ],
session: '1EuIYt2+wUuiWAS1rAWyNRZytqxYZgerwAprpOj3IZv57XfUUKtJrtGN9mHzHOp6mstO7fpoz1TQ21RN+8WqOw==',
signature: '3/D5n/0Xc5SS5xATHWrKxxKSnUVxqMDpYIdvhS02+eWbV/GLHwE60Xl4nUXwnr5MAHgPaf/Jj6l+VEy91pVu+Q=='
}
Next question: Apakah dia memiliki suami?
Received answer for session 7e03a93c-7e13-4b2e-a01b-b7d8490eefd7: Tidak
Akinator response: Akinator {
currentStep: 5,
region: 'id',
uri: 'https://id.akinator.com',
guess: undefined,
progress: 73.3724,
step_last_proposition: '',
guessCount: 0,
childMode: false,
config: {},
question: 'Apakah dia dari Pokemon Sword and Shield?',
answers: [ 'Iya', 'Tidak', 'Tidak tahu', 'Mungkin', 'Mungkin tidak' ],
session: '1EuIYt2+wUuiWAS1rAWyNRZytqxYZgerwAprpOj3IZv57XfUUKtJrtGN9mHzHOp6mstO7fpoz1TQ21RN+8WqOw==',
signature: '3/D5n/0Xc5SS5xATHWrKxxKSnUVxqMDpYIdvhS02+eWbV/GLHwE60Xl4nUXwnr5MAHgPaf/Jj6l+VEy91pVu+Q=='
}
Next question: Apakah dia dari Pokemon Sword and Shield?
Received answer for session 7e03a93c-7e13-4b2e-a01b-b7d8490eefd7: Tidak
Akinator response: Akinator {
currentStep: 6,
region: 'id',
uri: 'https://id.akinator.com',
guess: undefined,
progress: 92.2482,
step_last_proposition: '',
guessCount: 0,
childMode: false,
config: {},
question: 'Apakah dia orang yang galak?',
answers: [ 'Iya', 'Tidak', 'Tidak tahu', 'Mungkin', 'Mungkin tidak' ],
session: '1EuIYt2+wUuiWAS1rAWyNRZytqxYZgerwAprpOj3IZv57XfUUKtJrtGN9mHzHOp6mstO7fpoz1TQ21RN+8WqOw==',
signature: '3/D5n/0Xc5SS5xATHWrKxxKSnUVxqMDpYIdvhS02+eWbV/GLHwE60Xl4nUXwnr5MAHgPaf/Jj6l+VEy91pVu+Q=='
}
Next question: Apakah dia orang yang galak?
Received answer for session 7e03a93c-7e13-4b2e-a01b-b7d8490eefd7: Tidak
Akinator response: Akinator {
currentStep: 7,
region: 'id',
uri: 'https://id.akinator.com',
guess: undefined,
progress: 95.1143,
step_last_proposition: '',
guessCount: 0,
childMode: false,
config: {},
question: 'Apakah dia berasal dari Lookism?',
answers: [ 'Iya', 'Tidak', 'Tidak tahu', 'Mungkin', 'Mungkin tidak' ],
session: '1EuIYt2+wUuiWAS1rAWyNRZytqxYZgerwAprpOj3IZv57XfUUKtJrtGN9mHzHOp6mstO7fpoz1TQ21RN+8WqOw==',
signature: '3/D5n/0Xc5SS5xATHWrKxxKSnUVxqMDpYIdvhS02+eWbV/GLHwE60Xl4nUXwnr5MAHgPaf/Jj6l+VEy91pVu+Q=='
}
Next question: Apakah dia berasal dari Lookism?
Received answer for session 7e03a93c-7e13-4b2e-a01b-b7d8490eefd7: Tidak
Akinator response: Akinator {
currentStep: 8,
region: 'id',
uri: 'https://id.akinator.com',
guess: undefined,
progress: 97.1951,
step_last_proposition: '',
guessCount: 0,
childMode: false,
config: {},
question: 'Apakah ia berasal dari Portugal?',
answers: [ 'Iya', 'Tidak', 'Tidak tahu', 'Mungkin', 'Mungkin tidak' ],
session: '1EuIYt2+wUuiWAS1rAWyNRZytqxYZgerwAprpOj3IZv57XfUUKtJrtGN9mHzHOp6mstO7fpoz1TQ21RN+8WqOw==',
signature: '3/D5n/0Xc5SS5xATHWrKxxKSnUVxqMDpYIdvhS02+eWbV/GLHwE60Xl4nUXwnr5MAHgPaf/Jj6l+VEy91pVu+Q=='
}
Next question: Apakah ia berasal dari Portugal?
Received answer for session 7e03a93c-7e13-4b2e-a01b-b7d8490eefd7: Tidak
Akinator response: Akinator {
currentStep: 8,
region: 'id',
uri: 'https://id.akinator.com',
guess: {
completion: 'OK',
id_proposition: '3611',
id_base_proposition: '1941084',
valide_contrainte: '1',
name_proposition: 'Guardworm',
description_proposition: 'Spongebob',
flag_photo: '3',
photo: 'https://photos.clarinea.fr/BL_50_id/600/partenaire/i/1941084__420000600.jpg',
pseudo: 'none',
nb_elements: 2
},
progress: 97.1951,
step_last_proposition: '',
guessCount: 0,
childMode: false,
config: {},
question: 'Apakah ia berasal dari Portugal?',
answers: [ 'Iya', 'Tidak', 'Tidak tahu', 'Mungkin', 'Mungkin tidak' ],
session: '1EuIYt2+wUuiWAS1rAWyNRZytqxYZgerwAprpOj3IZv57XfUUKtJrtGN9mHzHOp6mstO7fpoz1TQ21RN+8WqOw==',
signature: '3/D5n/0Xc5SS5xATHWrKxxKSnUVxqMDpYIdvhS02+eWbV/GLHwE60Xl4nUXwnr5MAHgPaf/Jj6l+VEy91pVu+Q=='
}
Question did not change for session 7e03a93c-7e13-4b2e-a01b-b7d8490eefd7. Current question: Apakah ia berasal dari Portugal?
Next question: Apakah ia berasal dari Portugal?
Received answer for session 7e03a93c-7e13-4b2e-a01b-b7d8490eefd7: Tidak
Akinator response: Akinator {
currentStep: 8,
region: 'id',
uri: 'https://id.akinator.com',
guess: {
completion: 'OK',
id_proposition: '3611',
id_base_proposition: '1941084',
valide_contrainte: '1',
name_proposition: 'Guardworm',
description_proposition: 'Spongebob',
flag_photo: '3',
photo: 'https://photos.clarinea.fr/BL_50_id/600/partenaire/i/1941084__420000600.jpg',
pseudo: 'none',
nb_elements: 2
},
progress: 97.1951,
step_last_proposition: '',
guessCount: 0,
childMode: false,
config: {},
question: 'Apakah ia berasal dari Portugal?',
answers: [ 'Iya', 'Tidak', 'Tidak tahu', 'Mungkin', 'Mungkin tidak' ],
session: '1EuIYt2+wUuiWAS1rAWyNRZytqxYZgerwAprpOj3IZv57XfUUKtJrtGN9mHzHOp6mstO7fpoz1TQ21RN+8WqOw==',
signature: '3/D5n/0Xc5SS5xATHWrKxxKSnUVxqMDpYIdvhS02+eWbV/GLHwE60Xl4nUXwnr5MAHgPaf/Jj6l+VEy91pVu+Q=='
}
Question did not change for session 7e03a93c-7e13-4b2e-a01b-b7d8490eefd7. Current question: Apakah ia berasal dari Portugal?
My Code
app.get('/akinator', async (req, res) => {
if (req.query.start === 'true') {
try {
const region = 'id'; // Set the desired region
console.log(`Starting a new Akinator session with region: ${region}`);
const aki = new Aki({ region: region });
await aki.start();
const sessionId = uuidv4();
sessions[sessionId] = aki;
const response = {
status: 200,
creator: '@akane_chiwa',
sessionId: sessionId,
question: aki.question,
answers: aki.answers,
session_link: `https://api.chiwa.my.id/akinator?session=${sessionId}&answer=`
};
console.log('Session started with question:', aki.question);
sendJSONResponse(res, response);
} catch (error) {
console.error('Error starting Akinator session:', error);
res.json({ status: 500, error: 'Failed to start session with Akinator' });
}
} else if (req.query.session) {
const sessionId = req.query.session;
const answer = req.query.answer;
if (!sessions[sessionId]) {
return res.json({ status: 404, error: 'Session not found' });
}
try {
const aki = sessions[sessionId];
console.log(`Received answer for session ${sessionId}:`, answer);
const previousQuestion = aki.question;
await aki.step(answer);
// Log full response for debugging
console.log('Akinator response:', aki);
if (previousQuestion === aki.question) {
console.warn(`Question did not change for session ${sessionId}. Current question: ${aki.question}`);
}
const response = {
status: 200,
creator: '@akane_chiwa',
question: aki.question,
answers: aki.answers,
progress: aki.progress,
guessCount: aki.guessCount
};
console.log('Next question:', aki.question);
sendJSONResponse(res, response);
} catch (error) {
console.error('Error fetching response from Akinator:', error);
res.json({ status: 500, error: 'Failed to fetch response from Akinator' });
}
} else {
res.json({ status: 400, error: 'Invalid request' });
}
});
Issue Title
Akinator API: Repeated Questions Issue
Description
Problem Description
I'm using the Akinator API with this latest aki-api package in my project to create a web application where users can interact with Akinator. However, I'm encountering an issue where Akinator keeps asking the same question after several user responses.
Steps Taken
Environtment I Use
Reproduction Steps
Log
My Code
Video when i implement this package to my express
https://www.youtube.com/watch?v=q0E7zjGS5D8
Expected Outcome
I expect that Akinator should provide a new question after each user response, rather than repeating the same question multiple times.
Thank you for your assistance in resolving this issue.