Send a message to the Social25 API

Social25 gives you the possibility to send automated messages to a conversation from a Process / Flow / Apex through the Social25__Post_Message method. This article explains how to use this method.

Make sure you have the Conversation ID of the conversation to which you want to send the message

For more information on the Social25 API please visit https://documentation.social25.chat/#introduction

Call method from a Flow

Input

  1. Add an Action element in the Flow Builder

  2. Choose Social25__Post_Message

  3. Fill in the following 5 input values

Asynchronous

Should be set to TRUE or FALSE. If you trigger the Flow after a record insert/update, then it is mandatory to set this value to TRUE

Conversation ID

This is the conversation ID to which you want to send the message

Message Type

Currently only Text is supported

Use BulkWhen you want to send a lot of messages in one transaction you can set this option to TRUE. It will send all the messages in one callout. Be aware that you won't get a status result when this option is enabled.
Count Message As InboundBy default the Unread Messages count will reset after an outbound message. With this option set to TRUE the Unread Messages will increase with this message

Text Message

This is the text you want to send

Output

This action has the following output values, which are only available when the Asynchronous input is set to FALSE:

Message ID

This is the Heroku id of the message (not the Salesforce Id).

Status

The is the status of the message


Call method from Apex

It is also possible to call this method from Apex. This requires a list of Social25.Post_Message.PostMessageRequest objects. You need to set the following for every request object:

AsynchronousShould be set to TRUE or FALSE. If you want to call this method from a Trigger, you have to set it to TRUE
Conversation_idThis is the conversation ID to which you want to send the message to
TypeCurrently only Text is supported
Use_bulkWhen you want to send a lot of messages in one transaction you can set this option to TRUE. It will send all the messages in one callout. Be aware that you won't get a status result when this option is enabled.
Count_As_inboundBy default the Unread Messages count will reset after an outbound message. With this option set to TRUE the Unread Messages will increase with this message
TextThis is the text you want to send
//You can add multiple requests in one method call, for this a list is needed
List<Social25.Post_Message.PostMessageRequest> postMessageRequests = new List<Social25.Post_Message.PostMessageRequest>();

//Instantiate the request object 
Social25.Post_Message.PostMessageRequest postMessageRequest = new Social25.Post_Message.PostMessageRequest();
postMessageRequest.asynchronous = {true or false};
postMessageRequest.conversation_id = '{The conversation identifier}';
postMessageRequest.type = 'text';
postMessageRequest.use_bulk = {true or false};
postMessageRequest.count_as_inbound = {true or false};
postMessageRequest.text = '{The text you want to send}';

//Add the request object to the list
postMessageRequests.add(postMessageRequest);

//Call the 'Post Message' method, a list with the send messages are returned only when asynchronous was set to false, else you get an empty list
List<Social25.Post_Message.PostMessageResponse> responses = Social25.Post_Message.call(postMessageRequests);

for (Social25.Post_Message.PostMessageResponse postMessageResponse : responses) {
	String message_id = postMessageResponse.id;
	String message_status = postMessageResponse.status;
}

Related articles

On this page