Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The 'chattergetconversations' request takes two optional parameters (sinceDate and orderBy). The sinceDate parameter expects a date string in ISO 8601 format. The orderBy parameter should be a valid SQL order by clause without the 'Order By' text. A successful response will return a list of the most recent message objects for the most recent 100 conversations.

Each message object will contain these fields (example):

{
"Id" : "03J1Y0000005jYhUAI"
"Body" : "Hello, U1 this is U2"
"ConversationId" : "03M1Y0000004pUFUAY"
"SenderId" : "005i0000001oGt8AAE"
"SenderNetworkId" : null
"SentDate" : "2017-07-03T22:42:07.000Z"
"NextMessageId" : null
"IsOldest" : "0"
"SenderName" : "User Two"
"Members" : ["User Two","User One"]
}

Id = id of this message.
Body = message content.
ConversationId = id of the conversation this message is associated with.
SenderId = id of the message sender.
SenderNetworkId = id of the group the sender is associated with.
SentDate = date the message was sent by Salesforce.
NextMessageId = the message id of the next message in descending order of message sent date. If this field is empty and it is not the oldest message, this means there are messages that haven't yet been synced.
IsOldest = false (0) for all messages except for the oldest one (1). Used to determine when necessary to query Salesforce for more history.
SenderName = the resolved user full name of SenderId. This may be empty if the User table is not being or needs to be synced.
Members = a list of names of all members of the conversation associated with this message (including the sender). The number of members can range between 2 and 10.
Section


Panel
titleChatter Object Feeds


Panel
titlegetfeed


Note

The 'chattergetfeed' request will provide access to object-related chatter feeds, as synced by Pulsar Chatter object sync configuration.


Code Block
var request = {
	'type' = 'chattergetfeed',
	'data' = { 
		'ParentId' : '123456789ABCDEFGHI',
		'@@after_date' : '2017-07-11T04:31:06.000+0000', // optional -- query all FeedItems after a specific datetime in SFDC format
		'@@before_date' : '2017-07-12T04:31:06.000+0000', // optional -- query all FeedItems before a specific datetime in SFDC format 
		'orderBy' : 'CreatedDate ASC'  // optional -- SQL order by clause without 'ORDER BY'. Note, field(s) must exist in the FeedItem table. 
	}
};
bridge.sendRequest(request, function(responseData) {
    console.log('chattergetfeed: ' + responseData);
    if (responseData.type === "chatterGetFeedResponse") {
        console.log('success');
		// success actions - responseData.data contains an array of FeedItem objects
    } else if (responseData.type == 'error') {
        var errStr = responseData.data;
        console.log('A problem occurred:\n' + errStr);
    }
});



Panel
titlepostfeed


Note

The 'chatterpostfeed' request allows posting to object-related chatter feeds. Chatter comments are added using the 'ParentFeedItem' parameter. Chatter attachments are not currently supported through this API.


Code Block
var request = {
	'type' : 'chatterpostfeed',
    'data' : {
	    'Message' : 'This is the text of the chatter post',
    	'Parent' : '123456789ABCDEFGHI',
        'ParentFeedItem' : '0987654321HGFEDCBA'
	}
};
bridge.sendRequest(request, function(responseData) {
	console.log('chatterpostfeed: ' + responseData);
    if (responseData.type === "chatterPostFeedResponse") {
        console.log('success');
		// success actions - responseData does not contain FeedItem data
    } else if (responseData.type == 'error') {
        var errStr = responseData.data;
        console.log('A problem occurred:\n' + errStr);
    }
});
Panel
titleChatter Direct Messages
Panel
titlehasConversations
Note

If the app is online, both 'chatterhasconversations' and 'chattergetconversations' first issue a single call to Salesforce for the latest 100 conversations. This call automatically parses and stores information such as the conversation id, conversation members, and the latest message in that conversation. This is useful to perform prior to the getLatestMessages call below because if the conversation id is already known, the first call to getLatestMessages will successfully return the conversation message history. Otherwise, the conversation information is only returned after the first successful call of sendMessage.

Info

The 'chatterhasconversations' request takes one parameter (sinceDate), a date string in ISO 8601 format. A successful response will return either 'YES' or 'NO'.

Code Block
var request = {
    'type': 'chatterhasconversations',
	'data': { 'sinceDate': '2017-06-30T04:39:32.000Z' }
};

bridge.sendRequest(request, function (responseData) {
    if (responseData.type === "chatterHasConversationsResponse") {
	    console.log('chatterhasconversations: ' + responseData.data);
        // success actions - responseData.data contains either 'YES' or 'NO'        
    } else if (responseData.type == 'error') {
        var errStr = responseData.data;
        console.log('A problem occurred:\n' + errStr);
    }
});
Panel
titlegetConversations
Info
Code Block
var request = {
    'type': 'chattergetconversations',
	'data': { 'sinceDate': '2017-06-30T04:39:32.000Z', 'orderBy' : 'SentDate ASC' }
};

bridge.sendRequest(request, function (responseData) {
    if (responseData.type === "chatterGetConversationsResponse") {

        // success actions - responseData.data contains an array of up to 100 message objects
		
		var messageList = result;            
        var resultString = '';
        for (let i = 0; i < messageList.length; i++) {
        	if (i > 0)
            	resultString += '<br>';
           	var message = messageList[i];
            var sentDate = new Date(message.SentDate);
            resultString += '<i>' + sentDate.toString() + ':</i> <u>' + message.Members + '</u> <b>' + message.Body + '</b>';
      	}
        if (messageList.length == 0)
        	resultString = '0 messages were returned';
                    
		var getConversationsBody = document.getElementById("GetConversationsBody");
        getConversationsBody.innerHTML = resultString;


    } else if (responseData.type == 'error') {

        var errStr = responseData.data;
        console.log('A problem occurred:\n' + errStr);
    }
});
Panel
titlegetlatestmessages
Note

Chatter private messages are grouped into conversations- each of which is defined by the list of conversation participants. Due to limitations enforced by Salesforce Chatter, the Pulsar API does not provide a way to get an ad hoc list of the Chatter conversations that exist on the server, but a Conversation Id is returned when a message is sent. As a result, 'chattergetlatestmessages' may not return anything until a message has been sent from the device, and the response has been stored in the database.

Info

The 'chattergetlatestmessages' request takes a (required) list of User Ids as the participants for a Chatter conversation. The sinceDate is an optional parameter expected to be in ISO 8601 date format. If specified, only messages that are more recent than this date will be returned. The orderBy parameter is optional and is expected to be a valid SQL order by clause without the 'Order By' text. The response includes an array of the last 100 private Chatter messages sent between those participants.

Code Block
var request = {
    'type': 'chattergetlatestmessages',
    'data': {
		'sinceDate': '2017-06-30T04:39:32.000Z',
		'orderBy' : 'SentDate ASC',
        'memberList': ['005ABCDEFGHIJKLMNO', '005DEFGHIJKLMNOPQR', '005GHIJKLMNOPQRSTU'] // two or more User Ids, including the current user
    }
};

bridge.sendRequest(request, function (responseData) {
    if (responseData.type === "chatterGetLatestMessagesResponse") {
	    console.log('chatterGetLatestMessages: ' + responseData.data);
        // success actions - responseData.data contains an array of up to 100 message objects        
    } else if (responseData.type == 'error') {
        var errStr = responseData.data;
        console.log('A problem occurred:\n' + errStr);
    }
});
Panel
titlesendmessage
Info

The 'chattersendmessage' request sends a message either to (a) a specified set of recipients (defining a conversation), or (b) in reply to a specific message, which is already part of a conversation.

Note

The use of 'replyToId' will ignore anything specified in the 'toList' parameter.

It is possible to receive a failure response where the message was actually sent. This occurs if Pulsar does not receive proper confirmation of success from the Salesforce server. Other reasons to receive a failure are:

  • <1 or >9 recipients specified, not including the sending user Id
  • 0 length message
  • connectivity issues

For this reason, refer to the Pulsar log for more details about why 'chattersendmessage' failed.

Code Block
var request = {
    'type': 'chatterSendMessage',
    'data': {
        'toList': ['005ABCDEFGHIJKLMNO', '005DEFGHIJKLMNOPQR', '005GHIJKLMNOPQRSTU'], // up to 9 User Ids, NOT USED WITH 'replyToId'
        'replyToId' : '123456789ABCDEFGHI', // this is the message id you are replying to, NOT USED WITH 'toList'
        'message' : 'This is my private chatter message'
    }
};

bridge.sendRequest(request, function (responseData) {
    console.log('chatterSendMessage: ' + responseData);

    if (responseData.type === "chatterSendMessageResponse") {
        console.log('chatterSendMessage: ' + responseData.data);
        // success actions - responseData.data contains the string "Ok" if sent successfully        
    } else if (responseData.type == 'error') {
        var errStr = responseData.data;
        console.log('A problem occurred:\n' + errStr);
    }
});