send(eventName, data)
Creates an event instance and automatically sends it
eventName
String: Event nameeventData
Object: Event datareturn Promise{Object|Error}: A Promise fulfilled with the data coming from the server
subscribe(eventName, callback)
Subscribes to an event, which allows you to execute a callback each time it is fired
eventName
String: Event namecallback
String: Function to call once event firesunsubscribe(eventName, listener)
Removes the listener of the specified event
eventName
String: Event namecallback
String: Listener attached to the event, necessary for not removing all listeners with the same nameMost of the following events are already used by functions in the Chat object. Inbenta recommends that you try using these functions before you try to send event directly. Here is the list of events that you can send as a user with the send
method and its data:
chats:assign
Used to assign a chat to an agent
{
chatId,
algorithm, // optional algorithm to use for agent selection instead of the default one
maxAttempts, // maximum number of "jumps" between agents before considering no one is available
interval // time an assignation for an agent lasts in seconds
}
chats:join
Used to have a user join a chat
{
chatId,
userId
}
users:activity
Used to send a user activity
{
chatId,
userId,
type // writing, stop-writing or not-writing
}
user:focus
Used to send that the user focused the view.
messages:read
Used to mark a message as read by the user
{
messageId,
userId
}
chats:close
Used to close a chat
{
chatId,
userId
}
history:import
Used to import external history into a chat
{
chatId,
history // array of objects. You can check the definition of a History Entry [here](https://developers.inbenta.io/agent-chat/api/api-definitions#HistoryEntry) in the HistoryEntry section
}
chats:get
Used to retrieve a chat data
{
chatId,
fields // Optional related fields to retrieve to the chat, separated by commas. Can be a combination of: users,watchers,history
}
chats:create
Used to create a chat
{
room // room (aka queue) where the chat will be created
source // sourceId where the chat comes from
lang // optional language of the chat
creator // userId of the chat creator
}