I just started to create a chat bot using Amazon Lex. I would like to use some session attributes to keep the state of conversation. Basically, my bot first selects a file from a DB, for example file "abc123", and then keeps the state of that file so the user doesn't need to keep specifying the file when trying to retrieve contents from that file. How do I keep the state of flow within the file?
I have created an Intent called "FileQuery", and modified the sessionAttribute to "file": fileNo
fileNo is passed through the users input in the chatbot and stored in the variable. Here is my lambda function below.
exports.handler = (event, context, callback) => {
//storing users input for file into "file"
var fileNo = event.currentIntent.slots.FileNumber;
callback(null, {
"sessionAttributes": {
"file": fileNo,
"key": "value"
},
"dialogAction": {
"type": "Close",
"fulfillmentState": "Fulfilled",
"message": {
"contentType": "PlainText",
"content": "File " + fileNo + " selected"
}
}
});
}; //end
When user enters: "Select file abc123"
Lex: "File abc123 selected"
User: "Give me the name and contact information"
I want Lex/Lambda to understand the file in context and retrieve information about that file. How can I do this?