acceptGreeting
You can use this method to inform that a customer has seen a greeting. Based on that, the Reports section displays only the greetings seen by Customers instead of all the sent greetings. If a customer started a chat from a greeting but you didn’t executeacceptGreeting method, the greeting counts as seen in Reports anyway.
As arguments to this method you should use uniqueId & greetingId received in the incoming_greeting or connected event.
Errors
GREETING_NOT_FOUND- a givenuniqueIdcouldn’t be found on the server
cancelGreeting
Cancels a greeting (an invitation to the chat). For example, Customers could cancel greetings by clicking close icon on the displayed greeting.Errors
GREETING_NOT_FOUND- givenuniqueIdcould not be found on the server
cancelRate
Cancels rate-related thread properties.Errors
MISSING_CHAT_THREAD- the targeted chat is empty and has no threads.
connect
Starts the connection process to our servers. It is needed when:- The
autoConnect: falseargument has been passed to theinitmethod.
- You get disconnected for a reason that suspends reconnection attempts (e.g.
inactivity_timeout).
deactivateChat
Returned value:
deleteChatProperties
Deletes given chat properties.
Returned value:
deleteEventProperties
Deletes given event properties.
Returned value:
deleteThreadProperties
Deletes given chat thread properties.
Returned value:
destroy
Clears any stored resources, removes all listeners, and disconnects from the network. After using this method, you won’t be able to use the destroyed Customer SDK instance.disconnect
Disconnects from the server.getChat
Returns the chat data about the requested chat ID together with a single thread’s data. If the method is called with thethreadId parameter, then this particular thread is being returned. If no threadId is given, the latest thread is automatically returned.
Returned value:
getChatHistory
Helps loading in historical thread events. First, callgetChatHistory to access the history object of a particular chat.
The returned history object has only one method, next, which gives you a Promise with a { done, value } object.
done- indicates if there is anything more to loadvalue- an object with an array of threads, each containing an array of its events
history.next() multiple times to load previous historical events. They’re going to be grouped into threads and might require merging with already loaded events.
This is useful for implementing an infinite scroll or otherwise showing your customer’s archival chats.
Keep in mind, though, that you generally shouldn’t call next while the history is loading - we queue those requests, so the previous one must resolve before we proceed with the next one.
The structure such as our history object is called an async iterator.
getCustomer
Returns the info about the customer requesting it.getForm
Allows you to fetch a form template for a given group and form type.
Returned value:
getUrlInfo
It returns the info on a given URL.
Returned value:
off
Unsubscribes from emitted events, which are described here.on
Subscribes to emitted events, which are described here.once
Subscribes to emitted events, which are described here. Unsubscribes immediately after the callback gets called.listChats
It returns summaries of the chats a customer participated in.
Returned value:
listGroupStatuses
Returns availability statuses of the requested groups.
Returned value:
listThreads
Returns a list of thread objects together with the previous and next page ID cursors that can be used to load more threads. If you want to load consecutive events, consider usinggetChatHistory.
Returned value:
markEventsAsSeen
Marks events as seen by the current customer up to the given date.
Returned value:
rateChat
Sends chat rating and a comment for the most recent chat thread.
Returned value:
Errors
MISSING_CHAT_THREAD- the targeted chat cannot be rated because it has no threads.
requestWelcomeMessage
Requests a welcome message for the current customer. The welcome message is returned via theincoming_welcome_message event.
Returned value:
Errors
GROUP_OFFLINE- the requested group is offline, and it was not possible to return a predicted agent for it.GROUP_UNAVAILABLE- thrown when manual routing is enabled for the group and a predicted agent is requested for it. If you callstartChatorresumeChataccordingly, you’ll end up in the queue.
sendGreetingButtonClicked
Sends information to the server about a customer clicking a greeting button. Use this when a greeting includes a button with abuttonId property.
resumeChat
Resumes an archived chat.Errors
CHAT_ALREADY_ACTIVE- the chat is already active and you can’t activate it again.GROUPS_OFFLINE- a group in the targeted chat is offline. It can happen for licenses without continuous chats enabled.
sendEvent
Sends a provided object as an event with a specified type.sendRichMessagePostback
Sends information to the server about a user’s interaction with a rich message button.setCustomerSessionFields
Sends the request to set customer’s session fields. They are available for the duration of the session.setSneakPeek
You can use it to update the sneak peek in the Agent App. It is sent to the server only if the target chat is active. This method doesn’t return a promise.startChat
Starts a new chat. For one customer, you can only start one chat. In order to activate a previously started chat, useresumeChat.
Errors
CHAT_LIMIT_REACHED- the maximum limit of chats per customer has been reached, and it’s not possible to start a new one. You should activate one of the existing chats. The limit is 1.GROUPS_OFFLINE- a group in the target chat is offline. It can happen for licenses, which don’t allow Customers to chat during their unavailability.
updateChatProperties
updateCustomer
Updates the specified customer properties and fields.Errors
CUSTOMER_SESSION_FIELDS_LIMIT_REACHED- total amount of session fields would have been exceeded after requested update
updateCustomerPage
Updates information about the customer page using the provided page object.updateEventProperties
Updates given properties of an event.updateThreadProperties
uploadFile
Returns both apromise and a cancel. You can use cancel to abort a file upload.
It also lets you pass the onProgress callback function. Keep in mind that the maximum accepted file size is 10 MB.
It returns a URL that expires after 24 hours unless the URL is used in sendEvent
onProgress parameters:
Returned value:
In React Native, instead of passing a blob you need to pass an object of
such a shape: