Closed dboscanv closed 6 years ago
@dboscanv How long does your database query take in seconds? If your database call is taking more than 10-15s that could be your problem.
Can you share your bot code?
Hello @nwhitmont, thanks for your reply. The database query do not reach 1 second, they are very simple. I attached the code of the dialog that I attached in the image:
let bd = require('../database');
let helpers = require('../helpers');
let textoNoEntendi = require('../helpers/constant');
let Schedule = require('../models/Schedule');
module.exports = [
function (session, args, next) {
if(!args) {
session.endDialog(textoNoEntendi);
return;
}
let intent = args.intent;
let empresa = builder.EntityRecognizer.findEntity(intent.entities, 'empresa');
if(!empresa) {
session.endDialog(textoNoEntendi);
return;
}
bd.query(`SELECT id, name, website, street_name, phone, phone2 FROM businessesreal WHERE name LIKE "%${empresa.entity}%"`, function (error, result, fields) {
if (error) throw error;
if (result.length == 0) {
session.endDialog('No tenemos registros para lo que buscas :(');
} else if (result.length > 1) {
session.dialogData.results = result;
let options = result.map(r => r.name);
builder.Prompts.choice(session, "¿Cuál de las siguientes empresas es la que buscas?", options, { listStyle: 3 });
} else {
let company_selected = result[0];
// Buscar el horario
bd.query(`SELECT bh.day, bh.to, bh.from FROM businessesreal md, business_hours bh WHERE md.id = bh.business_list_id AND md.id = ${company_selected.id}`, function (error, result, fields) {
if (error) throw error;
let company = helpers.mapSchedule(result,company_selected);
company.schedule = new Schedule();
for (let data of company.hours) {
company.schedule.setDay(data);
}
session.endDialog(helpers.mapResponseOpen(company)); // TODO mostrar todos los horarios o solo el dia de hoy?
});
}
});
},
function (session, results) {
if (results.response) {
let company_selected = session.dialogData.results[results.response.index];
bd.query(`SELECT bh.day, bh.to, bh.from FROM businessesreal md, business_hours bh WHERE md.id = bh.business_list_id AND md.id = ${company_selected.id}`, function (error, result, fields) {
if (error) throw error;
let company = helpers.mapSchedule(result,company_selected);
company.schedule = new Schedule();
for (let data of company.hours) {
company.schedule.setDay(data);
}
session.endDialog(helpers.mapResponseOpen(company)); // TODO mostrar todos los horarios o solo el dia de hoy?
});
}
}
];
The functions in the "helpers" file have been tested locally and do not give errors, nor do they make queries.
Thanks!!
I know this is not directly related, but it can help you debug. If you mock dependencies external to the bot code (e.g. DB calls) or use a test db with hand picked data, you should be able to determine/isolate the problem with tests. Check out the BotTester framework for an easy way to write and run the tests
Closing the issue assuming it as resolved. Please reopen a new issue if it still persists.
Bot Info
Issue Description
Hello, I am developing a bot with LUIS.AI and MBF, but the problem is the following: the bot stops responding at some point in the conversation, and it takes to respond again. I connect to a MySQL database for the querys. I enclose an image so you can see better:
The funny thing is that the bot works, but at some point it stops responding and fails (as shown in the image).
Thanks!