Salesforce Lightning

Integration guide for leveraging your Salesforce Lightning customer data.

Objective

Deploy a 'Before registration' hook in Strivacity which can retrieve contact information from Salesforce Lightning ('Salesforce') and perform data comparisons before allowing customers to register.

Overview

In this example integration, we will be retrieving contacts from Salesforce. The 'Before registration' hook will check for a customer's primary email address (not email identifier) in Salesforce's database. The hook will only allow customer registration in Strivacity if their primary email matches a contact in Salesforce.

Prerequisites

General

  • Basic familiarity with nodejs, javascript, or similar languages

Salesforce side

  • Salesforce Lightning platform
  • New Salesforce Lightning application
    • Consumer Key and Consumer Secret of the application

πŸ›‘

Before creating a new application in Salesforce Lightning, go through the configuration steps in the next section.

Strivacity side

βœ…

Add the logic you see fit to our sample hook!

Configuration steps

Create a Salesforce app for integration

1) Go to Setup in Salesforce.

2) Navigate to 'App Manager' inside 'Apps' under Platform Tools in the side-menu.

3) Click 'New Connected App' in the top right corner.

4) Fill in Basic Information:

  • Name your new connected app
  • Add an API name
  • Enter a contact email

5) Select "Enable OAuth Settings".

6) Under API (Enable OAuth Settings)

  • Add a Callback URL for meeting configuration requirements.

βœ…

The callback URL can be a generic one, such ashttp://localhost:1717/redirect. The callback URL is not actually used when customers are authenticated but it's a required configuration by Salesforce.

  • In 'Available OAuth Scopes' select 'Manage user data via APIs'
  • AND click the 'Add' arrow to move it to selected scopes.

7) Save your configuration.

You will be redirected to your new connected application.

πŸ›‘

Don't navigate away from Manage Connected Apps just yet.

8) Capture the 'Consumer Key' and 'Consumer Secret'.

🚧

Consumer key and secret will not be available after you close this window.

Create a 'Before registration' hook from the Salesforce plugin

Our plugin library contains an off-the-shelf Salesforce event hook template that jumpstarts your integration process and allows you to customize it to your needs.

  1. In the Admin Console, go to Lifecycle Event Hooks.
  2. Click ' Add plugin'. You will be redirected to the plugin library.
  3. Click on the Salesforce logo. You can find it in the CRM section.
  4. There will be a pre-select for the event hook, so you only need to click 'Add'.
  5. Wait for the Salesforce hook template to be added.

🚧

If the Admin Console doesn't want to add the hook, it's most likely that the name of the hook is already taken. Click 'Edit' and you can modify the name of the event hook. Then continue with 'Try again'.

  1. If the hook has been successfully added, you can return to the list view with 'Back to plugin library', then 'Back to event hooks'.

Add dependencies

  1. Select the Salesforce event hook you've just added.
  2. In editor view, click on the cube icon on the top left corner of the IDE panel.
  3. Click 'Add dependency'.
  4. Search for and add the following packages:
  • nforce

This should appear in the dependencies list on the left.

Add dependencies option

Add dependencies option

πŸ“˜

Beta packages may not be stable. For best results use the latest stable package versions.

  1. Provide the Salesforce
    • username at SFDC_USER and
    • password at SFDC_PASSWORD
      you will authenticate with.
  2. Provide the
    • Consumer Key at SFDC_APP_CLIENT_ID
    • Consumer Secret at SFDC_APP_CLIENT_SECRET
      you've captured previously from the Salesforce connected app.
  3. Paste the Callback URL at SFDC_APP_REDIRECT_URI you've provided to the Salesforce connected app.

  1. Click 'Save'. You can return to the event hooks with the 'Back to event hooks' button.

πŸ“˜

Your hook's status will stay Non-Deployed until you add it to an application.

Create a Strivacity application

  1. Go to Applications and click 'Create Application'.
  2. Add a name, description, and define the mandatory properties of the application.
  3. Ensure the primaryEmail attribute of the selected Identity Store is mandatory.
  4. Scroll down to Lifecycle Event Hooks and assign your 'Before registration' hook to your Strivacity test application to integrate with Salesforce.
  5. Save your changes.

βœ…

Copy the test application's self-service URL.

Test your integration

  1. Go to an incognito browser.

πŸ“˜

Make sure only one incognito window is open as multiple windows share session information.

  1. Go to the self-service portal of the Strivacity application.
  2. Try to register a customer who:
  • has their email address registered in your Salesforce contacts. According to our example hook, this customer will be allowed registration.
  • doesn't have their email address in your Salesforce contacts. According to our example hook, this customer will be denied registration.

βœ…

Implement additional logic for customers denied registration.