[Question] Bot does not respond or perform the expected action after dialog begins
System Information (Required)
- SDK Platform: Node
- SDK Version: 3.8.3
- Development Environment: localhost/ Azure webapp
Issue Description
I'm trying to create a simple bot using Node.js which accepts a name and creates a record for the same in the database. I have been using Orient DB for the same. Conversation goes as follows: User: Hi Bot: Please tell me your name User: Jim <no response/action>
Once the user name is provided, the bot fails to respond and the expected function(user record creation) is not carried out(as seen from the app logs). However, it is not clear as why this does not happen from the logs.
Log trace:
restify listening to http://undefined:undefined \\.\pipe\45bb0af1-7a18-493a-be9c-163708d378ba
ChatConnector: message received.
ChatConnector: message received.
ChatConnector: message received.
UniversalBot("*") routing "hii" from "emulator"
Session.beginDialog(/)
/ - waterfall() step 1 of 1
::input:: hii
/ - Session.beginDialog(/userCheck)
./userCheck - waterfall() step 1 of 2
User name does not exists
./userCheck - Session.beginDialog(BotBuilder:prompt-text)
..BotBuilder:prompt-text - Session.send()
..BotBuilder:prompt-text - Session.sendBatch() sending 1 message(s)
ChatConnector: message received.
UniversalBot("*") routing "amazon" from "emulator"
Library("BotBuilder").findRoutes() explanation:
ActiveDialog(0.5)
..BotBuilder:prompt-text - Prompt.returning(amazon)
..BotBuilder:prompt-text - Session.endDialogWithResult()
./userCheck - waterfall() step 2 of 2
./userCheck - Session.sendBatch() sending 0 message(s)
Example Code
//server.js -- configures as 'main' in the package.json
var restify = require('restify');
var builder = require('botbuilder');
var orient = require('./db');
//BOT REST end point
var server = restify.createServer();
var port = process.env.PORT;
var ip = process.env.IP
isEmpty : function isEmpty(str) {
return (!str || 0 === str.length);
}
server.listen(port,ip,function () {
console.log('%s listening to %s', server.name, server.url, port);
})
var connector = new builder.ChatConnector({
appId: process.env.BOTFRAMEWORK_APPID,
appPassword: process.env.BOTFRAMEWORK_APPSECRET
});
server.post('/api/messages', connector.listen());
var testDialog = new builder.UniversalBot(connector, function (session) {
console.log('::input:: %s',session.message.text);
session.beginDialog('/userCheck');
});
testDialog.dialog('/userCheck', [
function(session) {
if(isEmpty(session.userData.name)) {
console.log("User name does not exists");
builder.Prompts.text(session,'Please tell me your name');
}else {
console.log("user name is :"+ session.userData.name);
session.beginDialog('/startSession');
}
},
function(session,results) {
orient.selectM("Users","name",results.response,function(result) {
if(isEmpty(result)) {
orient.create("Users","name",results.response);
console.log("Created user : "+results.response);
session.userData.name = results.response;
}else {
session.userData.name = results.response;
}
});
}
]);
//--------------------------------------------------------------------------
// package.json
//--------------------------------------------------------------------------
{
"name": "bot123",
"version": "1.0.0",
"description": "A sample bot for getting started with Bot Framework",
"main": "server.js",
"repository": {
"type": "git",
"url": "git+https://github.com/{user}/{botname}.git"
},
"dependencies": {
"botbuilder": "^3.6.0",
"restify": "^4.2.0",
"orientjs": "^2.2.0"
}
}
//--------------------------------------------------------------------------
// db.js
//--------------------------------------------------------------------------
var Promise = require('promise');
var OrientDB =require('orientjs');
var config = require('./configuration');
var server = OrientDB({ host: config.publicip, HTTPport: config.db_port, username: config.db_username, password: config.db_password });
var db = server.use({
name: config.db_name,
username: config.db_username,
password: config.db_password
});
var select = function(tableName,fieldName,detail_name) {
db.query("SELECT FROM "+tableName+" WHERE "+fieldName+"="+"'"+detail_name+"'")
.then(function(result){
return result;
})
}
module.exports = {
selectM : function(tableName,fieldName,detail_name,callback) {
db.query("SELECT FROM "+tableName+" WHERE "+fieldName+"="+"'"+detail_name+"'")
.then(function(result) {
result = JSON.stringify(result);
result = JSON.parse(result);
callback(result);
})
}
};
Steps to Reproduce
- Deploy the code as an Azure web app (linking to the Github repo)
- Create a bot using https://dev.botframework.com and update the creds under Application settings in the webapp
- Use the Bot framework Channel Emulator with the necessary credentials to start a dialog and try to create the user(outcome)
- Refer to the app-logs under {bot-webapp}.scm.azurewebsites.com
Expected Behavior
User with the given user name should be created in the linked database
Actual Results
User is not created in the database, and the bot doesn't provide any form of response message
Did you try to debug? Look at the docs for help (You don´t have to use the consoleconnector as provided in the doc file)
Hello All, Thanks for your suggestions, but that was due to wrong assignment of the db port, my bad! Sorry to take away your time folks! Its resolved now.
Thanks again!