Closed pmarsh-scottlogic closed 3 months ago
I need to solve a problem where we are not sending the congratulations message if there is an OpenAI error after the winning email has been sent
I've decided the gain is not worth the cost. In the startlingly unlikely event that the user would win a level with a sent email, but open has an error after the function call, then the user will not win the level.
Description
Before, when the user would send a message that would cause the level to be won, we would check if
wonLevel
in the backend's response wastrue
, and if so, we would add a congratulations message to the chat History, causing an extra API call.Now, we return the congratulations messagge (
wonLevelMessage
) in the chat response. The front end simply appends it to the history if it is there, and can use this to determine if the user has won the level.Screenshot
Notes
also does these things:
chatMessageType
LEVEL_INFO
toLEVEL_COMPLETE
Concerns
ChatHttpResponse
contains thewonLevel
boolean property. It gets marked as true at the points of the send email function call. At the end ofhandleChatToGPT
in the chatController, we checkwonLevel
. If we have won the level, then we add the congratulations message to the history and return it to the frontend. The frontend only needs the congratualtions message to determine that a level has been won, making wonLevel redundant in the frontend. This is untidy, but not necessarily problematic. This will be made irrelevant by #780Checklist
Have you done the following?