ChatterMessages Class

Access and modify message and conversation data.

Namespace

ConnectApi

Usage

Use Connect in Apex to get, send, search, and reply to messages. You can also get and search conversations, mark conversations as read, and get a count of unread messages.

ChatterMessages Methods

The following are methods for ChatterMessages. All methods are static.

getConversation(conversationId)

Get a conversation.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversation getConversation(String conversationId)

Parameters

conversationId
Type: String
Specify the ID for the conversation.

getConversation(conversationId, pageParam, pageSize)

Get a page of a conversation.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversation getConversation(String conversationId, String pageParam, Integer pageSize)

Parameters

conversationId
Type: String
Specify the ID for the conversation.
pageParam
Type: String
Specifies the page token to be used to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

getConversation(communityId, conversationId)

Get a conversation from a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversation getConversation(String communityId, String conversationId)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.
conversationId
Type: String
Specify the ID for the conversation.

getConversation(communityId, conversationId, pageParam, pageSize)

Get a page of a conversation from a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversation getConversation(String communityId, String conversationId, String pageParam, String pageSize)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.
conversationId
Type: String
Specify the ID for the conversation.
pageParam
Type:String
Specifies the page token to be used to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

getConversations()

Get the most recent conversations.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversationPage getConversations()

getConversations(pageParam, pageSize)

Get a page of conversations.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversationPage getConversations(String pageParam, Integer pageSize)

Parameters

pageParam
Type: String
Specifies the page token to be used to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

getConversations(communityId)

Get the most recent conversations from a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversationPage getConversations(String communityId)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.

getConversations(communityId, pageParam, pageSize)

Get a page of conversations from a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversationPage getConversations(String communityId, String pageParam, Integer pageSize)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.
pageParam
Type:String
Specifies the page token to be used to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

getMessage(messageId)

Get a message.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterMessage getMessage(String messageId)

Parameters

messageId
Type: String
ID for the message.

Return Value

Type: ConnectApi.​Chatter​Message

getMessage(communityId, messageId)

Get a message from a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterMessage getMessage(String communityId, String messageId)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.
messageId
Type: String
ID for the message.

getMessages()

Get the most recent messages.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterMessagePage getMessages()

getMessages(pageParam, pageSize)

Get a page of messages.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterMessagePage getMessages(String pageParam, Integer pageSize)

Parameters

pageParam
Type: String
Specifies the page token to be used to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

getMessages(communityId)

Get the most recent messages from a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterMessagePage getMessages(String communityId)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.

getMessages(communityId, pageParam, pageSize)

Get a page of messages from a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterMessagePage getMessages(String communityId, String pageParam, Integer pageSize)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.
pageParam
Type: String
Specifies the page token to be used to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

getUnreadCount()

Get the number of conversations that are marked unread.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.UnreadConversationCount getUnreadCount()

Return Value

Type: ConnectApi.​​UnreadConversationCount

If there are fewer than 50 unread conversations, ConnectApi.UreadConversationCount returns the exact number of unread conversations and the hasMore property is false. If there are more than 50 unread conversations, ConnectApi.UreadConversationCount returns 50 unread conversations and the hasMore property is true.

Example

ConnectApi.UnreadConversationCount unread = ConnectApi.ChatterMessages.getUnreadCount();

getUnreadCount(communityId)

Get the number of conversations that are marked unread in a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.UnreadConversationCount getUnreadCount(String communityId)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.

Return Value

Type: ConnectApi.​​UnreadConversationCount

If there are fewer than 50 unread conversations, ConnectApi.UreadConversationCount returns the exact number of unread conversations and the hasMore property is false. If there are more than 50 unread conversations, ConnectApi.UreadConversationCount returns 50 unread conversations and the hasMore property is true.

markConversationRead(conversationId, read)

Mark a conversation as read or unread.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversationSummary markConversationRead(String conversationId, Boolean read)

Parameters

conversationId
Type: String
Specify the ID for the conversation.
read
Type: Boolean
Specify whether the conversation is read (true) or not (false).

markConversationRead(communityId, conversationID, read)

Mark a conversation as read or unread in a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversationSummary markConversationRead(String communityId, String conversationID, Boolean read)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.
conversationId
Type: String
Specify the ID for the conversation.
read
Type: Boolean
Specify whether the conversation is read (true) or not (false).

replyToMessage(text, inReplyTo)

Reply to a message.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterMessage replyToMessage(String text, String inReplyTo)

Parameters

text
Type: String
The text of the message. Cannot be empty or over 10,000 characters.
inReplyTo
Type: String
ID of the message that is being responded to.

Return Value

Type: ConnectApi.​Chatter​Message

replyToMessage(communityId, text, inReplyTo)

Reply to a message in a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterMessage replyToMessage(String communityId, String text, String inReplyTo)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.
text
Type: String
The text of the message. Cannot be empty or over 10,000 characters.
inReplyTo
Type: String
ID of the message that is being responded to.

Return Value

Type: ConnectApi.​Chatter​Message

searchConversation(conversationId, q)

Get a conversation that matches the search criteria.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversation searchConversation(String conversationId, String q)

Parameters

conversationId
Type: String
Specify the ID for the conversation.
q
Type: String
Required and cannot be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See Wildcards.

searchConversation(conversationId, pageParam, pageSize, q)

Get a conversation with a page of messages that match the search criteria.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversation searchConversation(String conversationId, String pageParam, Integer pageSize, String q)

Parameters

conversationId
Type: String
Specify the ID for the conversation.
pageParam
Type: String
Specifies the page token to be used to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.
q
Type: String
Required and cannot be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See Wildcards.

searchConversation(communityId, conversationId, q)

Get a conversation with messages that match the search criteria in a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversation searchConversation(String communityId, String conversationId, String q)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.
conversationId
Type: String
Specify the ID for the conversation.
q
Type: String
Required and cannot be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See Wildcards.

searchConversation(communityId, conversationId, pageParam, pageSize, q)

Get a conversation with a page of messages that match the search criteria in a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversation searchConversation(String communityId, String conversationId, String pageParam, Integer pageSize, String q)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.
conversationId
Type: String
Specify the ID for the conversation.
pageParam
Type: String
Specifies the page token to be used to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.
q
Type: String
Required and cannot be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See Wildcards.

searchConversations(q)

Get conversations in which member names and messages match the search criteria.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversationPage searchConversations(String q)

Parameters

q
Type: String
Required and cannot be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See Wildcards.

searchConversations(pageParam, pageSize, q)

Get a page of conversations in which member names and messages match the search criteria.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversationPage searchConversations(String pageParam, Integer pageSize, String q)

Parameters

pageParam
Type: String
Specifies the page token to be used to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.
q
Type: String
Required and cannot be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See Wildcards.

searchConversations(communityId, q)

Get conversations in which member names and messages match the search criteria in a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversationPage searchConversations(String communityId, String q)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.
q
Type: String
Required and cannot be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See Wildcards.

searchConversations(communityId, pageParam, pageSize, q)

Get a page of conversations in which member names and messages match the search criteria in a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterConversationPage searchConversations(String communityId, String pageParam, Integer pageSize, String q)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.
pageParam
Type: String
Specifies the page token to be used to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.
q
Type: String
Required and cannot be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See Wildcards.

searchMessages(q)

Get messages that match the search criteria.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterMessagePage searchMessages(String q)

Parameters

q
Type: String
Required and cannot be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See Wildcards.

searchMessages(pageParam, pageSize, q)

Get a page of messages that match the search criteria.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterMessagePage searchMessages(String pageParam, Integer pageSize, String q)

Parameters

pageParam
Type: String
Specifies the page token to be used to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.
q
Type: String
Required and cannot be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See Wildcards.

searchMessages(communityId, q)

Get messages that match the search criteria in a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterMessagePage searchMessages(String communityId, String q)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.
q
Type: String
Required and cannot be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See Wildcards.

searchMessages(communityId, pageParam, pageSize, q)

Get a page of messages that match the search criteria in a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterMessagePage searchMessages(String communityId, String pageParam, Integer pageSize, String q)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.
pageParam
Type: String
Specifies the page token to be used to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.
q
Type: String
Required and cannot be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See Wildcards.

sendMessage(text, recipients)

Send a message to a list of recipients.

API Version

29.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterMessage sendMessage(String text, String recipients)

Parameters

text
Type: String
The text of the message. Cannot be empty or over 10,000 characters.
recipients
Type: String
Up to nine comma-separated IDs of the users receiving the message.

Return Value

Type: ConnectApi.​Chatter​Message

sendMessage(communityId, text, recipients)

Send a message to a list of recipients in a community.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterMessage sendMessage(String communityId, String text, String recipients)

Parameters

communityId
Type:String
Use either the ID for a community, internal, or null.
text
Type: String
The text of the message. Cannot be empty or over 10,000 characters.
recipients
Type: String
Up to nine comma-separated IDs of users to receive the message.

Return Value

Type: ConnectApi.​Chatter​Message