useMessages hook
the useMessages
hook is used to interface with messages belonging to a Chat.
Get Messages
Messages retrieved in a conversation are paginated to 25 messages at a time.
Field | Type | Description |
---|---|---|
messages | the list of messages returned. this is automatically updated whenever a new message is received for the current conversation. | |
|
| Shows the state of querying the messages, used to update your UI to show loading state. |
|
| an error object that is defined if an error occured while trying to query the messages. |
|
| function called to send a message to the conversation. |
|
| function called to update a specific message in a conversation. |
|
| function called to delete a message in a conversation. |
|
| function called to get the next 25 messages, the messages are automatically added to the begining of the messages array. |
|
| 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. |
Send Message
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
Field | Type | State | Description |
---|---|---|---|
|
| optional | the text of the message |
|
| optional | upload a file as an attachment |
|
| optional | an optional key value pair for any additional message information such as custom font size, font type, or |
Callback
Field | Type | Description |
---|---|---|
| the message that was sent |
Update Message
To update a message, call the updateMessage(...)
function from useMessages
hook.
messages are automatically updated in the messages
variable of useMessages(...)
Parameters
Field | Type | State | Description |
---|---|---|---|
|
| required | the id of the message to be updated |
Message
Parameters
Field | Type | State | Description |
---|---|---|---|
|
| optional | the text of the message |
|
| optional | upload a file as an attachment |
|
| optional | an optional key value pair for any additional message information such as custom font size, font type, or |
Callback
Field | Type | Description |
---|---|---|
| the message that was updated |
Delete Message
To delete a message, call the deleteMessage(...)
function from useMessages
hook.
Parameters
Field | Type | Description |
---|---|---|
|
| the Id of the message to delete |
Last updated