JavaScript
Send a Message
To send a message to other participants in the Conversation, you need to call the conversation.sendMessage() method.
You can do this by adding a handler for the message box's Submit button at the end of the run function:
// Listen for clicks on the submit button and send the existing text value
sendButton.addEventListener('click', () => {
conversation.sendMessage({ "message_type": "text", "text": messageTextarea.value }).then((event) => {
console.log("message was sent", event);
messageTextarea.value = '';
}).catch((error)=>{
console.error("error sending the message ", error);
});
});
Creating a web-based chat app
Create a web application that enables users to message each other
Steps
1
Introduction to this task2
Prerequisites3
Create a Vonage Application4
Create a conversation5
Create the users6
Add users to the conversation7
Generate JWTs8
Create the UI9
Authenticate your Users10
Fetch the conversation11
Show the message history12
Send a message13
Add typing indicators14
Run your application15
What's next?