function sendMessage() var chatInput = document.querySelector('.chat-input'); if (chatInput) chatInput.value = "!hello"; // Setting the chat to send a "!hello" message var event = new Event('input', bubbles: true ); chatInput.dispatchEvent(event); // You might need to simulate a send button click or use a timeout // setTimeout(function() chatInput.dispatchEvent(new Event('keydown', key: 'Enter')); , 1000);