Constructor
new Chat(websiteId, visitrorId)
Properties:
| Name | Type | Description |
|---|---|---|
managers |
Array.<Manager> | people who are connected to current conversation in dashboard |
visitor |
Visitor | user who visits current page |
connection |
Connection | class provides protocol implementation |
Chat constructor
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
websiteId |
string | Website ID from Chatix dashboard |
|
visitrorId |
string |
null
|
Visitor ID can be passed from backend. If null, SDK will try to find it in local storage and request new if it wasn't found in storage. |
Methods
_onConversationMessageReceivedCallback(message)
Receiving new message in conversation
Parameters:
| Name | Type | Description |
|---|---|---|
message |
Message | new message |
_onManagerConnectedCallback(manager)
Parameters:
| Name | Type | Description |
|---|---|---|
manager |
Manager | new connected manager |
_onManagerSentScreenEventCallback()
_onScreenDataRequestedCallback()
(async) getConnectedManagers() → {Array.<Manager>|*}
Getter for current conversation managers
Returns:
- Type
- Array.<Manager> | *
(async) getConversationHistory(lastKnownMessageId, count) → {Promise.<Array.<Message>>}
Sends request for current conversation messages. Messages returns ordered by sent time ascending.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
lastKnownMessageId |
string | null |
null
|
ID of the last message in dialog you have rendered. |
count |
number |
50
|
Number of messages to return. |
Returns:
- Type
- Promise.<Array.<Message>>
(async) getManagerInfo(managerId)
Gets information about manager from API
Parameters:
| Name | Type | Description |
|---|---|---|
managerId |
string | ID of manager you are interested in |
(async) getManagers() → {Array.<Manager>|*}
Getter for all website managers
Returns:
- Type
- Array.<Manager> | *
getVisitor() → {Visitor|null}
Getter for current conversation visitor
Returns:
- Type
- Visitor | null
receivedChatInfo(chatInfo)
Parameters:
| Name | Type | Description |
|---|---|---|
chatInfo |
(async) sendChatroomFileMessage(files, chatroomId)
Sends files or images to chatroom
Parameters:
| Name | Type | Description |
|---|---|---|
files |
File | Array.<File> | File or files to send |
chatroomId |
string | Chatroom ID where to send messages |
(async) sendFileMessage(files)
- Source:
- See:
Sends file or image message to Chatix
Parameters:
| Name | Type | Description |
|---|---|---|
files |
File | Array.<File> | File to send or array of files |
(async) sendPage(url, title)
Sends data to server about user navigation
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string | Current page URL |
title |
string | Current page title |
(async) sendTextMessage(text)
Sends text message to current conversation
Parameters:
| Name | Type | Description |
|---|---|---|
text |
text | new message text |
(async) setVisitor(visitor)
Setter for current conversation visitor
Parameters:
| Name | Type | Description |
|---|---|---|
visitor |
Visitor |
sortMessages(messages)
Sorts messages by sent_at ascending
Parameters:
| Name | Type | Description |
|---|---|---|
messages |
Array.<Message> | Messages array to sort |
(async) startConnection()
Starts SignalR connection to server
(async) stopConnection()
Stops network connection
(async) visitorTypes(text)
Sends current visitor typing
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | current visitor input |