| <button onclick="returnsUserMessage()">Send</button> | |
| <script> | |
| async function returnsUserMessage() { | |
| var user_input = document.getElementById("input-chat").value; | |
| var bot_reponse = await fetch('localhost/response', | |
| { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json' | |
| }, | |
| body: JSON.stringify({user_response: user_input}) | |
| }); | |
| // Then you need to present the bot response in your element | |
| } | |
| </script> |