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 will discuss how to automate case creation as part of an Atmosphere® SmartFlow.

Build on the Past

If you have been following our tutorials, you are going to find that 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 contact in Salesforce.

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

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 and click Save.

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 which values are required, you need to determine how you wish 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 populate the following fields required for a new case:

Default Values

Note: Default Values are fields that will 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 will be 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 will 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 will need to update your flow to collect the data you need from the caller. This tutorial will not go into detail on how to collect this information. Please 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 will come from the work we completed in the previous tutorial. External Web Call action #5 will send 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 will be stored into variables representing our Subject and Description (txtSubject and txtDescription).

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:

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

Configure the action Inputs as follows:

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 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 of the required and optional field name /value pairs you wish 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 will be returned in the following format:

Add the following response variable entries

Id: This will contain 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, check out 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.