get_customer_input ReasonForCalling_Play_prompt
Lambda function returns properly when testing Lex chatbot. Invoking the function through Amazon Connect results in an Error. Any ideas on how to save the return from Lambda in Connect with proper formatting? * Updated to add updated lambda code and Lex configuration image.
Lambda Code:
console.log('Loading event');
var AWS = require('aws-sdk');
var db = new AWS.DynamoDB({ apiVersion: '2012-08-10' });
exports.handler = (event, context, callback) => {
var ssn = event.currentIntent.slots.userSSN;
var mySecret = event.currentIntent.slots.secretWord;
var params = {
TableName: 'users',
Key: {
"fourDigSSN": {
"N": ssn
},
"mySecretWord": {
"S": mySecret
}
},
AttributesToGet: ["accountBalance"]
};
db.getItem(params, function(err, data) {
if (err) {
console.log(" It didn't work and here is the error " + err); // an error occurred
}
else
callback(null, {
"sessionAttributes":{
"accountBal": data.Item.accountBalance.N
},
"dialogAction": {
"type": "ConfirmIntent",
"message": {
"contentType": "PlainText",
"content": "Your account has been verified. Your account balance is " + data.Item.accountBalance.N + "."
},
"intentName": "ReasonForCalling",
"slots": {
"userSSN": ssn,
"secretWord": mySecret
}
}
});
// var accountBal = data.Item.accountBalance.N;
// //console.log("GetDBItem succeeded:", JSON.stringify(data, null, 2));
// callback(null, {accountBalance : accountBal});
});
};
[lex_configuration][1]
[connect_contact_flow][2]
[connect_lambda_Details][3]