I have created a bot with Amazon Lex V2 and I have implemented a code on Node.JS to interact with Amazon Lex. Everything is working fine. I have a requirement of accessing the database when users ask certain questions to the bot. I use MongoDB for the database. I see there is a way using lambda. But then there is no proper documentation for V2. Is there any way I can access MongoDB with Node.js when users ask a certain question to Amazon Lex bot?
Code
var params = {
botAliasId: 'XXXXXX', /* required */
botId: 'XXXXXXXXX', /* required */
localeId: 'en_US', /* required */
requestContentType: 'text/plain; charset=utf-8', /* required */
sessionId: req.body.sessionId.toString(), /* required */
inputStream: req.body.message,
responseContentType: "audio/mpeg",
};
lexruntimev2.recognizeUtterance(params, (err, data) => {
if (err) console.log(err, err.stack); // an error occurred
else {console.log(data)}