useMessages hook
Last updated
Last updated
the useMessages
hook is used to interface with messages belonging to a Chat.
Messages retrieved in a conversation are paginated to 25 messages at a time.
Field | Type | Description |
---|---|---|
To send a message, call the sendMessage(...)
function from useMessages
hook.
New messages received are automatically added to the messages
variable of useMessages(...)
Message
Parameters
Callback
To update a message, call the updateMessage(...)
function from useMessages
hook.
messages are automatically updated in the messages
variable of useMessages(...)
Parameters
Message
Parameters
Callback
To delete a message, call the deleteMessage(...)
function from useMessages
hook.
Parameters
Field | Type | State | Description |
---|---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | State | Description |
---|---|---|---|
Field | Type | State | Description |
---|---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
messages
the list of messages returned. this is automatically updated whenever a new message is received for the current conversation.
loading
boolean
Shows the state of querying the messages, used to update your UI to show loading state.
error
object
an error object that is defined if an error occured while trying to query the messages.
sendMessage
function
function called to send a message to the conversation.
updateMessage
function
function called to update a specific message in a conversation.
deleteMessage
function
function called to delete a message in a conversation.
paginate
function
function called to get the next 25 messages, the messages are automatically added to the begining of the messages array.
paginateLoading
boolean
Shows the state of a paginated query for messages, used to update your UI to show pagination state. is true when the paginate function is called and is false when messages are returned.
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
data
the message that was sent
messageId
string
required
the id of the message to be updated
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
data
the message that was updated
messageId
string
the Id of the message to delete