Integrate with Salesforce

Integrate with Salesforce

To automate and manage your customer life cycle, you may want to integrate with Salesforce's customer relationship management solution. You can do this using a specialized rule template.

In this example, we will use a rule to record a new Salesforce Lead when a new user first authenticates. The rule will also send a notification for the new Lead to a specified Slack channel.

Prerequisites

Before connecting your Auth0 app to Salesforce, you must sign up for and configure your account with Salesforce.

Steps

To connect your app to Salesforce, you will:

  1. Set up your app in Salesforce

  2. Get your Salesforce credentials

  3. Get your Slack channel hook URL

  4. Create and activate a rule in Auth0

Set up your app in Salesforce

Create an app in Salesforce and generate credentials for it, using Salesforce's Create a Connected App documentation. During this process, Salesforce will generate a Consumer Key and Consumer Secret for your application; make note of these.

While setting up your app, make sure you use the following settings:

Field Value to Provide
App URL https://{yourDomain}
Callback URL https://{yourDomain}/login/callback

Find your Auth0 domain name for redirects

If your Auth0 domain name is not shown above and you are not using our custom domains feature, your domain name is your tenant name, plus .auth0.com. For example, if your tenant name were exampleco-enterprises, your Auth0 domain name would be exampleco-enterprises.auth0.com and your redirect URI would be https://exampleco-enterprises.auth0.com/login/callback.

If you are using custom domains, your redirect URI will have the following format: https://<YOUR CUSTOM DOMAIN>/login/callback.

To learn more, read Custom Domains.

Get your Salesforce credentials

You will also need to get your Salesforce username and password that you use to authenticate with the Salesforce API. This username will appear as the creator of the Lead.

Once you have retrieved your Salesforce username and password, keep these values on hand because we will use them in a future step.

Get your Slack channel hook URL

To send a notification for the new Lead to a specified Slack channel, you will need to get the Slack channel's hook URL from your Slack Workspace Integration.

To learn more, read Slack SSO Integration.

Make note of the Slack channel's hook URL because we will use it in the next step.

Create and activate a rule in Auth0

Set up a rule in Auth0. While setting up your rule, select the Create a New Lead in Salesforce on First Login template from the Webhook section, then use the following settings:

Variable Value
SFCOM_CLIENT_ID Consumer Key for the application you previously set up in Salesforce.
SFCOM_CLIENT_SECRET Consumer Secret for the application you previously set up in Salesforce.
USERNAME Username you use to authenticate with Salesforce's API.
PASSWORD Password you use to authenticate with Salesforce's API.
MY_SLACK_WEBHOOK_URL Hook URL for the Slack channel to which you want to send a notification of a new Salesforce Lead.

By default, your rule will be activated upon save.