Automate Salesforce case routing assignments


This tutorial describes a use case on how you can use Application Integration to automate the business process flow of routing and assigning a Salesforce customer case.

Overview

In this tutorial, you'll create an integration that uses a Salesforce trigger to subscribe to a case channel in Salesforce. A new case in Salesforce invokes the integration, which extracts the case ID and case type. Depending on the case type, a new issue or incident is created in Jira Cloud or ServiceNow, respectively.

Salesforce Case flow diagram Salesforce Case flow diagram

Objectives

This tutorial shows you how to complete the following tasks in your integration:

  • Set up Salesforce Trigger to invoke your integration.
  • Add and configure Connectors tasks for Salesforce, Jira Cloud, and ServiceNow connections.
  • Add and configure data mapping tasks to extract and map case details.

Costs

In this tutorial, you use the following billable components of Google Cloud:

The instructions in this tutorial are designed to keep your resource usage within the limits of Google Cloud's Always Free tier.

When you finish the tasks that are described in this document, you can avoid continued billing by deleting the resources that you created. For more information, see Clean up.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Create a service account:

    1. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    2. Select your project.
    3. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    4. Click Create and continue.
    5. Grant the following roles to the service account: Secret Manager Viewer (roles/secretmanager.viewer), Secret Manager Secret Accessor (roles/secretmanager).

      To grant a role, find the Select a role list, then select the role.

      To grant additional roles, click Add another role and add each additional role.

    6. Click Continue.
    7. Click Done to finish creating the service account.

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Make sure that billing is enabled for your Google Cloud project.

  7. Create a service account:

    1. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    2. Select your project.
    3. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    4. Click Create and continue.
    5. Grant the following roles to the service account: Secret Manager Viewer (roles/secretmanager.viewer), Secret Manager Secret Accessor (roles/secretmanager).

      To grant a role, find the Select a role list, then select the role.

      To grant additional roles, click Add another role and add each additional role.

    6. Click Continue.
    7. Click Done to finish creating the service account.

Prepare your environment

Verify Salesforce user setup

This tutorial assumes that you have an existing Salesforce developer account with the required user setup and permission set. Verify that your account has Change Data Capture (CDC) enabled. For information about creating a new account, see Set up an integration user.

Verify Jira Cloud account

This tutorial uses Jira Cloud. You can either use your existing Jira Cloud account or create a new one. Verify that your Jira Cloud project and boards are set up. For more information about Jira Cloud, see Jira software documentation.

Verify ServiceNow instance

This tutorial uses a ServiceNow free Personal Developer Instance (PDI). You can either use your existing ServiceNow instance or create a new one. Verify that your instance is active and note down its instance URL. For more information about PDI, see ServiceNow PDI documentation.

Configure connections

For this tutorial, you must configure the following connections in Integration Connectors:

Salesforce connection
Configure a Salesforce connection in Integration Connectors. For information on configuring a Salesforce connector, see Salesforce connector.
Jira Cloud connection
Configure a Jira Cloud connection in Integration Connectors using your project URL tp create Jira issues in your project. Make sure to note down the project ID and issue ID. For information on configuring a Jira Cloud connector, see Jira Cloud connector.
ServiceNow connection
Configure a ServiceNow connection in Integration Connectors using your instance URL to create incidents in ServiceNow. For information on configuring a ServiceNow connector, see ServiceNow connector.

Create integration

To create a new integration, perform the following steps:

  1. In the Google Cloud console, go to the Application Integration page.

    Go to Application Integration

  2. In the navigation menu, click Integrations. The Integrations List page appears.
  3. Click Create integration and provide the following details in the Create Integration page:
    1. Integration name: Enter salesforce-case-integration.
    2. Description: Enter Demo integration created for tutorial.
    3. Region: Select us-central1 from the list of supported regions.
    4. Click Create to open the integration editor.

Set up integration trigger

Once you have successfully created your integration, you can add and configure an integration trigger that invokes the integration for an identified event.

For this tutorial, a Salesforce trigger is used to invoke the integration for every new case that is created in Salesforce. To add and configure a Salesforce trigger in your salesforce-case-integration integration, do the following:

  1. In the integration editor, click Triggers to display a list of available triggers.
  2. Click and place the Salesforce trigger element in the integration editor.
  3. Select the Salesforce trigger element on the designer canvas to open the Salesforce trigger configuration pane.
  4. Configure the following fields under Trigger Input:
    1. Event type: Select Change Data Capture (CDC) from the drop-down list.
    2. Salesforce instance configuration: Click the + Add new Salesforce instance configuration option from the drop-down list.

      In the Add Salesforce instance configuration dialog, do the following:

      • Salesforce instance connection name: Enter a connection name for the Salesforce instance. For example, test.
      • Salesforce domain: Enter your Salesforce domain name. You can find this information from your Salesforce account > View profile page.
      • Authentication profile: Select an authentication profile. If you don't have an authentication profile, create a new profile. For information, see Create a new authentication profile.
      • Click Add.
    3. Salesforce channel configuration: Click the + Add new Salesforce channel configuration option from the drop-down list.

      In the Add Salesforce channel dialog, do the following:

      • Salesforce object name: Enter Case.
      • Click Add.
    4. Operation: Select Create from the drop-down list
    5. Changes to the properties are saved automatically.

Map trigger payload to Salesforce connector

When the integration is invoked using the Salesforce trigger, you extract the case ID and map it to a Salesforce connector to retrieve additional details of the case.

Connect to the Salesforce account

Perform the following steps to add and configure a Connectors task to retrieve the case details using the Salesforce connection:

  1. In the integration editor, click Tasks to display a list of available tasks.
  2. Click and place the Connectors element in the integration editor.
  3. Select the Connectors task element on the designer to view the Connectors task configuration pane.
  4. Click and rename the Connectors label to Fetch Salesforce Data.
  5. Click Configure connector.
  6. Do the following in the Connectors Task Editor page:
    1. Under Select connection, choose the us-central1 region.
    2. Select your Salesforce connection from the list of available connections.
    3. Click Next.
    4. Under Type, choose Entities.
    5. Under Set entities/actions, select Case from the list of available entities and then select Get as the Operation.
    6. Click Done to complete the connection configuration and close the pane.

Extract and map case ID

A Data Mapping task is used to map and extract the case details between that Salesforce trigger and the Salesforce connector.

To add and configure the data mapping in your integration, do the following:

  1. In the integration editor, click Tasks to display a list of available tasks.
  2. Click and place the Data Mapping element in the integration editor.
  3. Select the Data Mapping element on the designer to view the task configuration pane.
  4. Click and rename the Data Mapping task to Get Case ID.
  5. Click Open Data Mapping Editor.

    The Data Mapping Editor lets you map input variables to the desired output variables, using the available transformation functions. The output is then available as a variable to any other integration task or trigger. For more details on mapping variables, see Add a mapping.

  6. Map the trigger —SalesforceTriggerCdcRecordID—output variable to the auto-generated connector—entityId(Fetch Salesforce Data)—input variable.

    Once your mapping is complete, close the pane. Any changes will be autosaved.

  7. Add an edge connection from the Salesforce trigger to the Get Case ID task.
  8. Add an edge connection from the Get Case ID task to the Fetch Salesforce Data connector.

Extract case type

Once you retrieve all the case details from the Salesforce connector, you extract the case type and route it to Jira Cloud or ServiceNow application.

To extract the Salesforce case type, do the following:

  1. In the integration editor, click Tasks to display a list of available tasks.
  2. Click and place the Data Mapping element in the integration editor.
  3. Click the Data Mapping element on the designer to view the task configuration pane.
  4. Click and rename the Data Mapping task to Get case type.
  5. Click Open Data Mapping Editor.
  6. Click + Add new variable and create the following output variable:
    Output variable name Data type
    sf_case_type STRING
  7. Create the following mapping between the Salesforce connector payload variable and the local variable:
    Input Output
    connectorOutputPayload (Fetch Salesforce Data)
    .GET_PROPERTY("Type")
                
    sf_case_type

    Once your mapping is complete, close the pane. Any changes will be autosaved.

  8. Add an edge connection from the Fetch Salesforce Data connector to the Get case type task.

Create new Jira issue

Once you have extracted the Salesforce case type, and if the case is of type: Engineering, then route it to Jira Cloud as a new issue.

Connect to Jira project

Perform the following steps to configure a Connectors task that creates a new issue in your Jira project:

  1. In the integration editor, click Tasks to display a list of available tasks.
  2. Click and place the Connectors element in the integration editor.
  3. Click the Connectors task element on the designer to view the Connectors task configuration pane.
  4. Click and rename the Connectors to Create issue in Jira.
  5. Click Configure connector.
  6. Do the following in the Connectors Task Editor page:
    1. Under Select connection, choose the us-central1 region.
    2. Select your Jira Cloud connection from the list of available connections.
    3. Click Next.
    4. Under Type, choose Entities.
    5. Under Set entities/actions, select Issues from the list of available entities and then select Create as the Operation.
    6. Click Done to complete the connection configuration and close the pane.

Transform and map issue details

To transform the case details and map it to a Jira issue, do the following:

  1. In the integration editor, click Tasks to display a list of available tasks.
  2. Click and place the Data Mapping element in the integration editor.
  3. Click the Data Mapping element on the designer to view the task configuration pane.
  4. Click and rename the Data Mapping task to Mapping for issue creation.
  5. Click Open Data Mapping Editor.
  6. Click + Add new variable and create the following variables:
    Variable name Data type Default value
    jira_project-id STRING
    JIRA_PROJECT_ID
    Replace JIRA_PROJECT_ID with your Jira project ID.
    jira_issue_type_id STRING
    JIRA_ISSUE_TYPE_ID
    Replace JIRA_ISSUE_TYPE_ID with any of the following issue type ID:
    • 1000 - for Epic
    • 1001 - for Story
    • 1002 - for Task
    • 1003 - for Sub-task
    • 1004 - for Bug
  7. Create the following mapping:
    Input Output
    "{ "IssueTypeId": jira_issue_type_id, "ProjectId": jira_project_id }"
    .TO_JSON()
    .SET_PROPERTY(
    connectorOutputPayload.Description (Fetch Salesforce Data),  
    "Description"
    )
    .SET_PROPERTY(
    connectorOutputPayload.Subject (Fetch Salesforce Data),  
    "Summary"
    )
                 
    connectorInputPayload (Create issue in Jira)

    Once your mapping is complete, close the pane. Any changes will be autosaved.

  8. Add an edge connection from the Mapping for issue creation task to the Create issue in Jira connector.

Create new ServiceNow incident

If the extracted case from Salesforce is of type: Sales, then route it to ServiceNow as a new incident.

Connect to ServiceNow

Perform the following steps to configure a Connectors task that create a new incident to your ServiceNow instance:

  1. In the integration editor, click Tasks to display a list of available tasks.
  2. Click and place the Connectors element in the integration editor.
  3. Click the Connectors task element on the designer to view the Connectors task configuration pane.
  4. Click and rename the Connectors to Create incident in ServiceNow.
  5. Click Configure connector.
  6. Do the following in the Connectors Task Editor page:
    1. Under Select connection, choose the us-central1 region.
    2. Select your ServiceNow connection from the list of available connections.
    3. Click Next.
    4. Under Type, choose Entities.
    5. Under Set entities/actions, select incident from the list of available entities and then select Create as the Operation.
    6. Click Done to complete the connection configuration and close the pane.

Transform and map incident details

To transform the case details and map it to a ServiceNow incident, do the following:

  1. In the integration editor, click Tasks to display a list of available tasks.
  2. Click and place the Data Mapping element in the integration editor.
  3. Click the Data Mapping element on the designer to view the task configuration pane.
  4. Click and rename the Data Mapping task to Mapping for incident creation.
  5. Click Open Data Mapping Editor.
  6. Click + Add new variable and create the following input variables:
  7. Create the following mapping:
    Input Output
    "{}"
    .TO_JSON()
    .SET_PROPERTY(
    connectorOutputPayload.Description (Fetch Salesforce Data),  
    "description"
    )
    .SET_PROPERTY(
    connectorOutputPayload.Subject (Fetch Salesforce Data),  
    "short_description"
    )
                 
    connectorInputPayload (Create incident in ServiceNow)

    Once your mapping is complete, close the pane. Any changes will be autosaved.

  8. Add an edge connection from the Mapping for incident creation task to the Create incident in ServiceNow connector.

Add edge condition

An edge condition lets you specify the conditions that must be met for control of an integration to pass to the task connected by the edge. Now that you have added and configured and the required tasks, you can add an edge condition to define the flow of the integration.

The following edge condition controls the flow of the integration based on the type of the Salesforce case:

  1. Add an edge connection from the Get case type task to the Mapping for issue creation task with the following edge condition:
      $sf_case_type$ = "Engineering"
  2. Add another edge connection from the Get case type task to the Mapping for incident creation task with the following edge condition:
      $sf_case_type$ = "Sales"

Sample integration flow

The following figure shows a sample layout of the integration created using this tutorial.

Sample image showing the integration flow Sample image showing the integration flow

Publish and test the integration

To publish the integration click Publish in the integration editor toolbar.

Upon successfully publishing your integration, you can view and inspect the execution logs of the published integration. To view logs, click image showing the icon for execution logsView execution logs for this integration. The Execution Logs page appears.

Test case 1: To check if a Jira issue is created for an enginnering case

Test the integration by logging in to the Salesforce instance and creating a new case. You must enter Engineering in the Type field while creating the case.

To verify the success of your integration:

Go to your Jira Cloud account.

  • Check to confirm if a new issue is created in your project containing the Salesforce case description and summary.

Test case 2: To check if a ServiceNow incident is created for a sales case

Test the integration by logging in to the Salesforce instance and creating a new case. You must enter Sales in the Type field while creating the case.

To verify the success of your integration:

Go to your ServiceNow instance.

  • Check to confirm if a new incident is created in your instance containing the Salesforce case description and summary.

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this tutorial, unpublish the integration and delete the connections created in Integration Connectors.

  • To unpublish this integration, click Unpublish in the integration editor toolbar. See Delete integrations for more information.
  • For information about how to delete a connection, see Manage connectors.