Use the SDK to route Salesforce emails

Note: This article applies to Genesys Cloud for Salesforce.

After you configure the routing of Salesforce emails in Salesforce, use our SDK in the managed package to route Salesforce emails through Genesys Cloud for Salesforce. The SDK uses the Salesforce Apex programming language. 

Note: This advanced customization article is intended for developers who are familiar with Salesforce.

Prerequisites

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.

Email class

Contains static methods to route Salesforce emails through Genesys Cloud for Salesforce.

Namespace

purecloud.SDK.Email

Usage

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

Email methods

The following methods are available for the Email class.

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

Parameters

Name Data type Description Notes
queue String Queue in your Genesys Cloud organization that you want Salesforce emails to route to. Maps to Call.QueueName in the interaction details.
sfUrlPopValue String Value in the URL of the Salesforce page that you want to screen pop when an interaction alerts.

Example

The following example shows how to perform these 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');

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

Parameters

Name Data type Description Notes
queue String Queue in your Genesys Cloud organization that you want the integration to route Salesforce emails to. Maps to Call.QueueName in the interaction details.
skills List<String> List of skills in your Genesys Cloud organization.  Associated with agents who you want to receive Salesforce emails.
language String Language skill in your Genesys Cloud organization.  Associated with agents who you want to receive Salesforce emails.
attributes Map<String, Object> See Attributes Map.

Attributes Map

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.

Parameters

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

Example

The following example shows how to perform these 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);

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

Email class

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

Namespace

purecloud.Email

Usage

Use these methods to create Genesys Cloud 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.

Email methods

The following methods are available for the Email class.

Creates Genesys Cloud interaction with defined instance attributes. 

Properties

Name Data type Description Notes
queue String Queue in your Genesys Cloud organization that you want the integration to route Salesforce emails to. Maps to Call.QueueName in the interaction details.
skills List<String> List of skills in your Genesys Cloud organization.  Associated with agents who you want to receive Salesforce emails.
language String Language skill in your Genesys Cloud organization.  Associated with agents who you want to receive Salesforce emails.
attributes Map<String, Object> See Attributes Map.
subject String Email subject line for the active interaction. Added to the interaction details when an interaction alerts. Maps to Email.Subject in the interaction details.
fromName String Remote name for the active interaction. Added to the interaction details when an interaction alerts. Maps to Call.RemoteName in the interaction details.
fromAddress String The remote email address for the active interaction. Added to the interaction details when an interaction alerts. Maps to Salesforce.DisplayAddress in the interaction details.

Attributes Map

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.

Parameters

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

Examples

The following examples show how to create an email object and use properties to perform these 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();

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

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