Links

Conversation (Chat)

A conversation(chat) object lets you have conversations with 1 or more Users.
You can view how a chat object can be created for a one-to-one conversation or a group chat with multiple members.

Event Listeners

Listen for new messages

This is called whenever the current user receives a new message.
chat.onMessage((message) => {
//do something with message
})
Response
Field
Type
Description
message
Message
the message that has been received.

Listen for typing started

This is called whenever a participant of the conversation starts typing.
chat.onTypingStarted((user) => {
//do something when a user starts typing
})
Response
Field
Type
Description
user
User
the user that started typing

Listen for typing stopped

This is called whenever a participant of the conversation stops typing.
chat.onTypingStopped((user) => {
//do something when a user stops typing
})
Response
Field
Type
Description
user
User
the user that stopped typing

Functions

Get Messages

Messages retrieved in a conversation are paginated to 25 messages at a time.
async/await
callback
const { messages , page , totalMessages , totalPages } = await chat.getMessages(1 /** page to query **/ )
chat.getMessages(1 /** page to query **/ ,({ messages , page , totalMessages , totalPages })=>{
//do something with the messages
})
Parameters
Field
Type
State
Description
page
number
optional
query a specific page of messages, each page contains 25 messages. if null or undefined then the most recent 25 messages are returned
Response
Field
Type
Description
messages
Message[]
array of messages
page
number
shows the current page of messages. each page contains 25 messages
totalMessages
number
shows the total number of messages that exist
totalPages
number
shows the total number of pages of messages that exist. each page contains 25 messages

Send Message

To send a message, call a function on the chat object.
const message = {
text: "Hello World!"
}
const callback = (data)=> { /**
handle messages received
Ï */}
chat.sendMessage(message, callback)
Message Parameters
Field
Type
State
Description
text
string
optional
the text of the message
file
File
optional
upload a file as an attachment
metadata
json object
optional
an optional key value pair for any additional message information such as custom font size, font type, or JSON formatted string. accepts string,number and boolean values
Callback
Field
Type
Description
data
Message
the message that was sent

Get ID

Get the id of the conversation, returns a string
const id = chat.getId()

Get Title

Get the title of the conversation, returns a string
const title = chat.getTitle()

Get Conversation Avatar

Get the avatar of the chat, returns a string which is the url to the avatar
const avatar = chat.getChatAvatar()

Get recent message

Get the most recent message sent in the conversation. Returns a Message object.
const message = chat.getLastMessage()

Get Members

Get an array of all the users of this conversation
const users = await chat.getMembers()

Get MemberIds

Get an array of ids of all the members of this conversation
const userIds = await chat.getMemberIds()

Notify everyone typing started

Call this function to notify everyone who is a participant of the conversation that the current user has started typing
chat.startTyping()

Notify everyone typing stopped

Call this function to notify everyone who is a participant of the conversation that the current user has stopped typing
chat.stopTyping()
Last modified 21h ago