How to change Conversation State during conversation
It is now possible to change the conversation state on an ongoing conversation.
Conversation States
Open
When the conversation state is Open it is possible to send messages as usual:
Auto_Bot
During this state an automated process or a bot is answering the messages, it is not possible to manually send messages:
However, a user which has the custom permission Social25.Allow Change Conversation State assigned can press the Take over conversation button to put the conversation to the Open state:
Blocked
While the conversation is in Blocked state it is not possible to send and receive message within this conversation:
Permissions
Not every user is allowed to perform changes on the conversation state. To give a user permission to do this you have to assign the Custom Permission (on the User Profile or Permission Set) Social25.Allow Change Conversation State. This makes the buttons to do this visible:
Change state from Flow
Input
Add an Action element in the Flow Builder
Choose Put Conversation
Fill in the following 4 input values
Conversation ID | This is the conversation ID from which you want to change the state |
---|---|
Action | Should be set to change_state |
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 |
State | Should be set to one of the following numeric values:
|
Change state from Apex
It is also possible to call this method from Apex. This requires a list of Social25.Put_Conversation.PutConversationRequest objects. You need to set the following for every request object:
Conversation ID | This is the conversation ID from which you want to change the state |
---|---|
Action | Should be set to change_state |
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 |
State | Should be set to one of the following numeric values:
|
//You can add multiple requests in one method call, for this a list is needed
List<Social25.Put_Conversation.PutConversationRequest> putConversationRequests = new List<Social25.Put_Conversation.PutConversationRequest>();
//Instantiate the request object
Social25.Put_Conversation.PutConversationRequest putConversationRequest = new Social25.Put_Conversation.PutConversationRequest();
putConversationRequest.conversation_id = '{The conversation identifier}';
putConversationRequest.action = 'change_state';
putConversationRequest.asynchronous = {true or false};
putConversationRequest.state = {one of the numeric values as described above};
//Add the request object to the list
putConversationRequests.add(putConversationRequest);
//Call the 'call' method from Put_Conversation, a list with the results are returned only when asynchronous was set to false, else you get an empty list
List<Social25.Put_Conversation.PutConversationResponse> responses = Social25.Put_Conversation.call(putConversationRequests);
for (Social25.Put_Conversation.PutConversationResponse putConversationResponse : responses) {
String conversation_id = putConversationResponse.id;
Integer statusCode = putConversationResponse.statusCode;
}
On this page: |
---|