I am trying to build an Lex bot for Pizza delivery using Node.js. I have 2 intents 1) Customer data 2) Pizza Order.
So currently, my code work perfectly if I just want to get customer data from user and send the response to Bot, I am trying to **save the data to DB(Dynamo DB) and display the data to user. **, this is when I get the above error. Please view the below code:
function custData(intentRequest,callback){
const sessionAttributes = intentRequest.sessionAttributes;
const slots = intentRequest.currentIntent.slots;
const name = slots.Name;
const phone = slots.Phone;
const address = slots.Address;
callback(checkDB(name,phone,address), close(sessionAttributes,'Fulfilled',
{'contentType': 'PlainText', 'content': 'Thank you, How can I help you today'}));
}
1) If I call "ONLY" the CheckDB function i.e checkDB(name,phone,address), the database is updated by user inputs and I get the above error in Lex test bot console.
2) If I call only the Close i.e( elicit_close) function, the message I pass is displayed in the Bot console.
3) If I call both the function (similar to the code shared above), I get the above error in Bot console and the DB is updated with user submitted values and in this scenario, the last slot value is taken has null in Bot console but saved correctly in DB.
I searched the similar errors but, the solution does not help since I get the error only when I mention the checkDB in the call back or if i call both functions via callback. if not everything works perfect.