Hello good day is there a way for initializing custom states as I am having problems when checking against them.
I checked before and when I used an uninitialized custom state in an if statement it went to the else branch, but now it throws me an error and makes the chatflow respond with just a line.
Here is the source code:
try {
if (event.session.customState.customResponse != '') {
requestMessage = event.session.customState.customResponse
oldConversation = true
} else if (event.session.customState.oldConversation == 'true') {
requestMessage = event.userMessage.message
oldConversation = true
} else {
requestMessage = 'Hello Good Day'
oldConversation = true
}
} catch (error) {
requestMessage = event.userMessage.message
}
It currently gives an incorrect error when run
ERROR Invoke Error {"errorType":"TypeError","errorMessage":"Cannot read properties of undefined (reading 'toLowerCase')","stack":["TypeError: Cannot read properties of undefined (reading 'toLowerCase')"," at exports.main (/var/task/Template.js:57:24)"," at exports.hubspot_handler [as handler] (/var/task/hubspotHandler.js:7:21)"," at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1187:29)"]}
This points to another line of code that runs after said comparison and assignment.
Thank you.