DEV Community

Discussion on: Make a Simple Chatbot with JavaScript!

Collapse
 
rickasterlyvevoofficalnotfake profile image
rick asterly

i alredy made the chat app is there a way just to add the bot here is the code :

note after you close the tab you will lose your conversation


note the ai is not completed yet so dont judge yet !


chat

<br> var username = window.prompt(&quot;what should we call you&quot;);</p> <p>document.write(&quot;hey &quot;+username +&quot; how are you today ?&quot; );</p> <div class="highlight"><pre class="highlight plaintext"><code>&lt;/script&gt;&lt;/h1&gt; </code></pre></div> <p><body style="background-color: aquamarine; background-image:url(Background.max-x-PIC-MCH043354.jpg); " ><br> <input id="textbox" type="text" placeholder="chat with the ai :)" ><button id="button" onclick="ping.play()" >Send</button><br><br> <ul id="messages"></ul><br> <script src="script.js"> var messages = document.getElementById("messages"); var textbox = document.getElementById("textbox"); var button = document.getElementById("button"); button.addEventListener("click", function(){ var newMessage = document.createElement("li"); newMessage.innerHTML = textbox.value; messages.appendChild(newMessage); textbox.value = ""; }); var ping = new Audio(); ping.src = "ping.mp3";