@atlasat/live-chat-agent-sdk
v0.0.0-beta.4
Published
![npm](https://img.shields.io/npm/v/@atlasat/webphone-sdk?style=flat-square)
Downloads
5
Readme
LiveChatAgent SDK
Example
Connecting and registering
import { LiveChatAgent } from '@atlasat/live-chat-agent-sdk';
const liveChat = new LiveChatAgent({ clientId: 'your-client-id' });
const data = await liveChat
.authenticate({
name: 'your name',
email: '[email protected]',
})
.catch((err) => {
console.log('got error ', err);
});
Event
/**
* get all message
*/
const message = await liveChat.messages();
console.log('got message', message);
/**
* get all participants
*/
const participants = await liveChat.participants();
console.log('list of participants', participants);
/**
* connect to websocket server
*/
liveChat.connect();
liveChat.on('connect', () => {
console.log('connected to server');
});
/**
* listen for new message
*/
liveChat.on('message', (message) => {
console.log('new message', message);
});
/**
* listen for new participant
*/
liveChat.on('newParticipant', (participant) => {
console.log('new participant', participant);
});
Send message
const message = await chatAgent?.sendMessage({
message: 'Hello, are you there?',
type: 'text',
});