How to Create a Case in Salesforce

Overview

During the lifecycle of an interaction with a customer, partner, or even employee, you reach a point where you need to open a case in Salesforce. This can be to track a conversation, log an enhancement request, or log a support issue. Depending on your business rules, you might want to create the case as an automated process. In this tutorial, we discuss how to automate case creation as part of SmartFlows.

Build on the Past

If you have been following our tutorials, you are going to find this one is actually a continuation of something you may have already built. We are going to start with the tutorial we built for looking up a contact in Salesforce.

If you are unfamiliar with building flows, or just need a refresher, we recommend you start with a review of the SmartFlows Quick Start Guide.

A sample workflow with five actions

Let's look at how we created this flow.

Imitation is the Sincerest Form of Flattery

To help save us some time, we are going to copy our previous work.

From your previous SmartFlow, click Copy Flow in the Actions menu. This is going to create a copy of your flow. Update the name of the new flow to something that makes sense and click Save.

In the Actions Menu, the Copy Flow action, third action from the top of the list, is highlighted

Case Requirements

The required fields to open a case and the values to be used to fill in the fields can vary by Salesforce instance. Consult your Salesforce Administrator to determine what information is required.

Once you have determined the required values, you need to determine how you want to collect this information. We suggest creating a small matrix to help you map out the corresponding values.

For this tutorial, we are going to use the following fields required for a new case:

Default Values

Note: Default Values are fields that have the same value each time.

Field Default Value
Type

Based on department contacted

Support: Incident Management

Billing: Collections

Customer Service: Product Inquiry

Origin Phone
Status New
Owner Id All tickets are assigned to our bot owner: 005G0000001jrgg
Priority P3

Salesforce Provided Data

Note: Salesforce Provided Data is data derived from the caller’s information.

Field Where the Data is Located in Salesforce
AccountId Contact.AccountId
ContactId Contact.Id
SuppliedName Contact.Name
SuppliedEmail Contact.Email
SuppliedPhone Contact.Phone

Data I prompt the caller for:

Field Prompt
Subject "Please provide a short description of your problem"
Description "Please describe your issue in detail"

Gather Your Data

At this point, you need to update your flow to collect the data you need from the caller. This tutorial doesn't go into detail on how to collect this information. See your SmartFlows documentation for details on how to collect the required data using your preferred caller interface(e.g. Speech, DTMF, SMS).

For our example, all of our Salesforce supplied data comes from the work we completed in the previous tutorial. External Web Call action #5 sends a request to Salesforce to provide the necessary information based on the caller’s phone number. For the data we must prompt the caller to provide, we are going to collect this information using the Text to Speech capability of the Play Audio basic action and the Speech Recognition premium action. The text captured is stored in variables representing our Subject and Description (txtSubject and txtDescription).

The sample flow with nine actions

Creating Your Case

Once your flow is set to collect your data, you can now create the integration to create the case. Add another External Web Call action to the flow:

Five additional actions have been added to the end of the original sample workflow

Configure the action to include the required and any optional fields you want to include.

Configure the action Inputs as follows:

The configurations panel for an External Web Call action is shown, with sample values in each field

Add Headers

Add an Authorization Header. The value of this header should include the term Bearer as well as the Access token received in Action #4. (Bearer $EXTCALL_4.access_token)

Basic Auth

UserName: Leave Blank. The access token takes care of this for you

Password: Leave Blank. The access token takes care of this for you.

Method: POST

Timeout: The default is ten (10) seconds. This should be fine for your instance.

URL of Service: Set this to the URL of your Salesforce instance.

https://.my.salesforce.com/services/data/v39.0/sobjects/Case

Body

The body should contain all required and optional field name/value pairs you want to provide.

Copy
{
  "Type": "Incident Management",
  "Origin": "Phone",
  "Status": "New",
  "OwnerId": "005G0000001jrgM",
  "Subject": "$SPEECHREC_7.text",
  "Priority": "P3",
  "AccountId": "$EXTCALL_5.AccountId",
  "ContactId": "$EXTCALL_5.Id",
  "Description": "$SPEECHREC_9.text",
  "SuppliedName": "$EXTCALL_5.Name",
  "SuppliedEmail": "$EXTCALL_5.Email",
  "SuppliedPhone": "$EXTCALL_5.MobilePhone"
}

Response Variables

Results are returned in the following format:

Add the following response variable entries

Id: This contains the ID of the case created

Success: Contains a Boolean value indicating if the operation completed successfully

Errors: Contains an array of errors returned from the system

For more information on the Salesforce’s Case Creation API, see the Case API documentation.

Continue Your Flow

Congratulations, you can now create a case from within your SmartFlow. From here you would continue your flow. This might include thanking the user to reading back the case id to the user. From here you would continue developing your flow to match your required business flow.