So, this is a question I keep hearing a lot in the answers community and I decided to pen on this topic so that users can easily look through this post and setup something similar by themselves.

Use Case :  Cases are one of the most extensively used elements when it comes to service cloud. The object as well as the users are heavily burdened with different types of tasks through out the lifespan of a case starting from it’s opening to its closure. So, why not simply automate at least a few of them so that you can have an extra cup of coffee ! Usually when you close a case, you tend to inform your customer by sending him a note regarding the case closure. Now, when you send this email from salesforce itself, you can automate the additional task of closing the case and even adding any additional details etc.

Tools to be used :  Process builder and Visual Workflow. To outline the end-to-end process, we will have a process setup which will look for any emails sent that are related to a Case record and if the email subject contains the keywords “Case Closed”, then we will trigger a flow to look the related Case record and update its status as “Closed”.

Implementation : So, we kick start by creating a flow to update the Case record when an email is sent. We will first setup the flow and then go back and create the process in the process builder so that we have the flow ready when we need to link it in the process builder.

  • Goto Setup > Build > Create > Workflow & Approvals > Flows.
  • Click “New Flow” which will open the flow designer where we need to design our flow
  • Now, we will need an input variable to our flow which will hold the ID of the case record which needs to be updated. So, let’s go ahead and create the input variable.
  • Click on the “Resources” tab and double-click “variable”. Populate the values into the pop-up box as shown below.


  • Now click on the “Palette” tab and drag the “Record update” palette to the right hand side.
  • Populate values into the pop-up box as below.



  • So, here basically we are checking if the ID value of the Case record is equal to the input variable that we had defined earlier.
  • If a case record is found which matches with the input value then, we also update the Status field in the Case with “Closed” value which is a picklist value.
  • Now click on the green arrow on the “Record update” element. This basically indicates that this is the start element of the flow.
  • Now click Save and save the flow as below.


Now Close the flow and click “Activate” beside the flow. So you have an Active flow built to update the case status to closed.

Our next step is to create a process to identify an email sent to a customer that will check if the subject contains the keywords “Case Closed”.

Let’s go ahead and build it.

  • Go-to Setup > Build > Create > Workflow & Approvals > Process builder
  • Click “New” and give your process a name and set the process to start when a “A record changes”.
  • Click “Add Object” and select the “Email Message” object with the criteria as seen below and click “Save”


  • Click “Add criteria” and set the criteria as seen below and click “Save”.
  • The filter criteria should be to check whether the field “Subject” contains the value “Case Closed”.


  • Click “Add action” in the immediate actions and define the action as seen below.
  • In the “Flow variables” section click “Add row” as we need to define the input parameter to our flow which is the ID of the case record which needs to be closed.
  • Remember that this value will be passed to the “InputCaseID” input variable which we had defined in the flow.
  • Note that “InputCaseID” in the process here will be referring to the “RelatedtoID” field in the Email message object as the Case Id will be stored in this field.


Now Click Save > Activate. That winds up the end-to-end process to automate the case closure. Your process is now connected to the flow and will automatically update the case status when an email is sent to the customer from Salesforce.

Test your process and flow:

  • Go to one of the existing open cases in your organization
  • At the bottom of the case detail page, you will find a “Send an Email” button in the Activity History section as seen below


Click on the button and you should see a template to send the email. Enter the required details and hit the “Send” button. Now go back and check the status of your case. You should see the case status updated to “Closed”.




Hope this works for you. Feel free to comment on this post if you have any doubts.

Happy using Processes and Flows !