2021 - Prototype Chat Simulator for Web by Levi Ellis, Emanuel Nation & Natalie Campos
Built in response to the rapid advancement of AI, this project is a basic web implementation of a chatbot developed in JavaScript capable of retroactively revising chat logs to deceive a user. With the support of a small team, I led the development of this project under a two-week time constraint. Let's break down some of the key components and functionalities of our code:
Variables:
canLaugh and canMod are boolean variables.
userMod and botMod are arrays initialized with zeros.
i is an integer initialized to 0.
Event Listeners:
The code includes several event listeners for the "DOMContentLoaded" event and the "keydown" event on the input field. These event listeners capture user input when the Enter key is pressed.
Functions:
The output function processes user input, removes special characters, sets the chatbot's response (product), and calls the speak function.
The addChat function adds user and chatbot responses to the HTML document and scrolls to the latest chat.
The speak function utilizes the Web Speech API to convert text into speech.
Trigger and Reply Arrays:
trigger array contains arrays of potential user inputs grouped by categories.
reply array contains corresponding arrays of chatbot responses.
Greeting, Mood Responses, Jokes, Thanks, Goodbye, Trust Sequences, and Other Categories:
Each category has predefined responses based on user input.
For example, if the user inputs a greeting, the chatbot responds with a friendly greeting from the reply array.
Speech Synthesis:
The chatbot has the ability to convert its responses into speech using the speak function.
Secret Inquiry, Gaslighting and Humor:
There are sections related to secrets, trust, and gaslighting, adding an element of mystery and intrigue to the chatbot's responses. There is also a section related to joking with humorous and nonsensical responses.
This JavaScript code is the foundation for a chatbot implemented in a web page. The chatbot responds to user inputs with predefined triggers and provides various responses based on the trigger categories. The code includes functionality for handling user interactions, such as capturing input, processing it, and displaying both user and bot messages on the web page. Additionally, there are elements related to voice synthesis for the bot's responses. The chatbot introduces a unique element by incorporating a trust sequence where it hints at having a secret and encourages the user to promise trust before revealing it. Overall, the project aims to create an interactive and engaging chatbot with specific features and responses.