article by Frank Nimphius, November 2020
Often the unexpected is the best teacher. While participating in a team effort to build a digital assistant, one of my skills failed after adding a component developed by one of my peer developers.
The error message was pretty clear and reported my standard error handler as the dialog flow state the error happens. Apparently, the user message my standard error handler passes to a custom component contained invalid characters.
If you look at the error message, you can see that the last user message is actually a JSON payload, not a string. The JSON payload actually contained a lot of double quotes, which actually seems to confuse the BotML. Don't ask me how the JSON payload got in, but this also is what made it unexpected.
On my journey to find a fix, I came a cross a specific Apache FreeMarker expression that does not try to understand the message it passes but treat it as a raw payload. The dialog flow state below shows the original dialog flow definition. As you see for the Last user message property, it accessed the last user input and passed it to the custom component.
The BotML code below shows the fix. Instead of using ${system.message.messagePayload.text} I change the expression to ${r+[system.message.messagePayload.text]}. This then interpreted the user message as a raw input, which means the Apache FreeMarker engine in Oracle Digital Assistant dialog flow just does not bother interpreting it.
I then realized another flow I had in my BotML. The default error handler should report errors but not cause them. So to handle the case in which the default error handler is the trouble maker, I added a local error transition to the default error handling state. This error transition then navigates t a state that plays is safe in that it only prints a static message. This way my default error handler is no longer an error candidate due to the unexpected.
Related content
TechExchange Quick-Tip: Creating an Default Error Handler in Oracle Digital Assistant
TechExchange: All 2-Minutes Oracle Digital Assistant Tech Tip Videos on YouTube
TechExchange Quick-Tip: Adding Default Transitions to Dialog Flows