Creating User’s message
This function adds a message box to the chat window. The message box contains the message of the user.
Adding typing animation
After the user types the message and the message box is displayed, setUserResponse() function is executed. This function sets up a message box from the bot’s side and fills it with a loading gif. The important thing to note is msgNumber variable. For each user message, this variable is incremented by one. So it keeps count of the total number of message from the user or the bot. Each message box from the bot is assigned a unique id: “susiMsg-<msgNumber>”. Thus, when the response from the SUSI server is received, the loading gif is replaced by the message from the server. The corresponding message box is identified by the above id.
This function adds a message box to the chat window containing the loading gif.
On receiving the response from the server, the following function is executed:
This function replaces the above loading gif with the server’s response.