I'm trying to find out how to create chat between two users. I can't find documentation how to configure control panel and how to write client to start chatting.
You need to do the following setup in the Voximplant Control Panel:
On the web client side do the initial setup
To send a message from user1 to user2, you need:
// let's assume user2's Voximplant username is user2@app.account.voximplant.com,
// where:
// - app is your Voximplant application name
// - account is your Voximplant account name
let messenger = VoxImplant.Messaging.getInstance();
let userEvent = await messenger.getUser("user2@app.account");
let user2Id = userEvent.user.userId;
let participant = {userId: user2Id};
let conversationEvent = await messenger.createConversation([participant]);
let conversation = conversationEvent.conversation;
let messageEvent = await conversation.sendMessage("text message");
// to obtain a sent message from the event
let message = messageEvent.message;
To receive messages and other messaging events, you need to subscribe on MessengerEvents. The most important for this case are:
messenger.on(VoxImplant.Messaging.MessengerEvents.CreateConversation,
(conversationEvent) => {
// user2 receives this event after user1 has created a conversation
// obtain the conversation instance from `conversationEvent` to send messages
// from user2 to user
let conversation = conversationEvent.conversation;
});
messenger.on(VoxImplant.Messaging.MessengerEvents.SendMessage,
(messageEvent) => {
// user2 receives this event after user1 has sent a message
// to get the text of the message
let textMessage = messageEvent.message.text;
});