Use the SDK to route Salesforce emails


Note: This article applies to PureCloud for Salesforce.

After you configure the routing of Salesforce emails in Salesforce, use our SDK in the managed package to route Salesforce emails through PureCloud for Salesforce. The SDK uses the Salesforce Apex programming language. You can set screen pops, modify interaction details, or add data to the activity records in Salesforce. 

Access our SDK through the Email class under the purecloud.SDK.Email and purecloud.Email namespaces. Use the purecloud.Email namespace to set information for subject, fromName, and fromAddress.

Note: This article is an advanced customization topic meant for developers familiar with Salesforce.

Prerequisites

Email class

Contains static methods to route Salesforce emails through PureCloud for Salesforce.

Namespace

purecloud.SDK.Email 

Usage

Use these methods to create PureCloud email objects that route Salesforce emails through PureCloud for Salesforce. These objects can contain data to set screen pops, modify interaction details, or add data to the activity records in Salesforce.

Example 1

This example shows how to do the following actions:

  • Route Salesforce emails to a specified queue.
  • Screen pop a specified Salesforce page.

Interaction details using Apex code

purecloud.SDK.Email.create('CustomerService', '500360000015OCJ');

Example 2

This example shows how to do the following actions:

  • Route Salesforce emails to agents in a specified queue who are assigned specified skills and language.
  • Screen pop a specified Salesforce page.
  • Add a case number to the interaction details.
  • Add a remote email address to the activity records in Salesforce.

Note: Because CaseNumber and contactEmailAddress are custom attributes, you must first add Participant.{CustomFieldName} to the Customize Interaction Details and Activity Field Mapping sections under Client Settings. For more information about Client Settings, see Managed package settings

Interaction details using Apex code

String[] skills = new List<String>();
skills.add('Warranties');
skills.add('Cellphone repair');

String language = 'English - Spoken';

Map<String, Object> attributes = new Map<String, Object>();
attributes.put('SF_URLPop', '500360000015OCJ');
attributes.put('CaseNumber', 'Case: 000149');
attributes.put('contactEmailAddress', 'john.smith@customer.com');

purecloud.SDK.Email.create('CustomerService', skills, language, attributes);

Email methods

The following are methods for Email.

  • create(queue, sfUrlPopValue)

    Routes Salesforce emails to a specified queue and screen pops a specified Salesforce page.

  • create(queue, skills, language, attributes)

    Routes Salesforce emails to agents in a specified queue who are assigned specified skills and language in your PureCloud organization, and uses the attributes parameter to perform actions.

  • create()

    Instantiates purecloud.Email objects. See the purecloud.Email tab.

 

create(queue, sfUrlPopValue)

Routes an email interaction to a specified queue and screen pops a specified Salesforce page.

Parameters

queue

Type: String

The queue argument is a queue in your PureCloud organization. This queue is the queue that you want Salesforce emails to route to. Maps to Call.QueueName in the interaction details.

sfUrlPopValue

Type: String

The sfUrlPopValue argument is the value in the URL of the Salesforce page that you want to screen pop when an interaction alerts.

 

create(queue, skills, language, attributes)

Routes Salesforce emails to agents in a specified queue who are assigned specified skills and language in your PureCloud organization, and uses the attributes parameter to perform actions.

Parameters

queue

Type: String

The queue argument is a queue in your PureCloud organization. This queue is the queue that you want Salesforce emails to route to. Maps to Call.QueueName in the interaction details.

skills

Type: List<String>

The skills argument is a list of skills in your PureCloud organization. This list of skills is associated with agents who you want to receive Salesforce emails.

language

Type: String

The language argument is a language skill in your PureCloud organization. This language skill is associated with agents who you want to receive Salesforce emails.

attributes

Type: Map<String, Object>

The attributes argument is a map of attributes that can include a Salesforce page or search result, or data to add to the interaction details or activity records in Salesforce.

Key Description Type Required Notes
SF_URLPop ID of the Salesforce page that you want to screen pop when an interaction alerts string Optional Use either SF_URLPop or SF_SearchValue, not both. For faster processing of screen pops, use SF_URLPop.
SF_SearchValue ID of the Salesforce search result that you want to screen pop when an interaction alerts string Optional Use either SF_URLPop or SF_SearchValue, not both. For faster processing of screen pops, use SF_URLPop.
{custom attribute} Data to interaction details or to activity records when interaction alerts string, integer, Boolean Optional

 

create()

Instantiates purecloud.Email objects. See purecloud.Email tab. 

Email class

Represents a PureCloud email interaction. Contains methods to route Salesforce emails through PureCloud for Salesforce.

Namespace

purecloud.Email 

Usage

Use these methods to create PureCloud email objects. These objects can contain data to set screen pops, modify interaction details, or add data to the activity records in Salesforce. These objects can also set information for subject, fromName, and fromAddress.

Examples

These examples show how to create an email object and use properties to do the following actions:

  • Route Salesforce emails to agents in a specified queue who are assigned skills and languages, or route Salesforce emails to agents using an Architect inbound email flow with assigned skills and languages.
  • Screen pop a specified Salesforce page.
  • Add a case number to the interaction details.
  • Add a remote email address to the activity records in Salesforce.
  • Add the subject, fromName, and fromAddress properties to the interaction details.

Note: Because CaseNumber and contactEmailAddress are custom attributes, you must first add Participant.{CustomFieldName} to the Customize Interaction Details and Activity Field Mapping sections under Client Settings. For more information about Client Settings, see Managed package settings

Interaction details using Apex code

Example using queue to route Salesforce emails

String[] skills = new List<String>();
skills.add('Warranties');
skills.add('Cellphone repair');

Map<String, Object> attributes = new Map<String, Object>();
attributes.put('SF_URLPop', '500360000015OCJ');
attributes.put('CaseNumber', 'Case: 000149');
attributes.put('contactEmailAddress', 'john.smith@customer.com');

purecloud.Email email = purecloud.SDK.Email.create();
email.queue = 'CustomerService';
email.skills = skills;
email.language = 'English - Spoken';
email.attributes = attributes;
email.subject = 'Warranty Question'; 
email.fromName = 'John Smith'; 
email.fromAddress = 'john.smith@customer.com'; 
email.create();

Example using an inbound email flow to route Salesforce emails

Map<String, Object> attributes = new Map<String, Object>();
attributes.put('SF_URLPop', '500360000015OCJ');
attributes.put('CaseNumber', 'Case: 000149');
attributes.put('contactEmailAddress', 'john.smith@customer.com');

purecloud.Email email = purecloud.SDK.Email.create();
email.flow = 'RouteEmails';
email.attributes = attributes;
email.subject = 'Warranty Question'; 
email.fromName = 'John Smith'; 
email.fromAddress = 'john.smith@customer.com'; 
email.create();

Email methods

The following are methods for Email.

  • create()

    Creates PureCloud interaction with defined instance attributes. 

 

create()

Creates PureCloud interaction with defined instance attributes. 

Properties

queue

Type: String

The queue property is a queue in your PureCloud organization. This queue is the queue that you want Salesforce emails to route to. Maps to Call.QueueName in the interaction details.

skills

Type: List<String>

The skills property is a list of skills in your PureCloud organization. This list of skills is associated with agents who you want to receive Salesforce emails. 

language

Type: String

The language property is a language skill in your PureCloud organization. This language skill is associated with agents who you want to receive Salesforce emails.

attributes

Type: Map<String, Object>

The attributes property is a map of attributes that can include a Salesforce page or search result, or data to add to the interaction details or activity records in Salesforce.

Key Description Type Required Notes
SF_URLPop ID of the Salesforce page that you want to screen pop when an interaction alerts string Optional Use either SF_URLPop or SF_SearchValue, not both. For faster processing of screen pops, use SF_URLPop.
SF_SearchValue ID of the Salesforce search result that you want to screen pop when an interaction alerts string Optional Use either SF_URLPop or SF_SearchValue, not both. For faster processing of screen pops, use SF_URLPop.
{custom attribute} Data added to interaction details or to activity records when interaction alerts string, integer, Boolean Optional

subject

Type: String

The subject property is the email subject line for the active interaction. This email subject line is added to the interaction details when an interaction alerts. Maps to Email.Subject in the interaction details.

fromName

Type: String

The fromName property is the remote name for the active interaction. This remote name is added to the interaction details when an interaction alerts. Maps to Call.RemoteName in the interaction details.

fromAddress

Type: String

The fromAddress property is the remote email address for the active interaction. This remote email address is added to the interaction details when an interaction alerts. Maps to Salesforce.DisplayAddress in the interaction details.

For more information, see Configure the routing of Salesforce emails, Use Process Builder to route Salesforce emails, and About Routing of Salesforce Emails

For more information about the integration, see About PureCloud for Salesforce.