Salesforce - Lead & Opportunity

Objective

  • Fetch/Create/Update Lead from customer data

  • Create an Opportunity linked to the Lead

  • Build and send the relevant payload via EdgeTag

EdgeTag Salesforce Integration - Deployment & Salesforce Setup

This guide will help you set up and validate the EdgeTag integration with Salesforce and deploy it using EdgeTag's Webhook.

Salesforce Configuration

  1. Create a Salesforce Connected App

    1. Navigate to Setup:

      • Go to App Manager (under Setup).

      • Click New Connected App.

      • If not visible: Go to Apps -> External Client Apps -> Settings -> Connected Apps, then click New Connected App.

    2. Configure Your App:

      • Name: EdgeTag Integration (API Name auto-fills).

      • Enable OAuth Settings.

      • Callback URL: https://localhost:3000/callback

      • Selected OAuth Scopes:

        • Manage user data via APIs (api)

        • Perform requests on your behalf at any time (refresh_token, offline_access)

      • Edit OAuth Policies:

        • Permitted Users: Admin approved users are pre-authorized.

        • IP Relaxation: Relax IP restrictions (if needed).

        • Uncheck Require Proof Key for Code Exchange (PKCE).

      • Save the Connected App.

      • Copy Credentials:

        • In the app detail page, click Manage Consumer Details and copy:

        • Consumer Key

        • Consumer Secret

  2. Add a Custom Lookup Field to Opportunity

    • Go to: Setup -> Object Manager -> Opportunity -> Fields & Relationships-> New.

    • Choose: Data Type: Lookup Relationship, Related To: Lead Reference.

    • Enter:

      • Field Label: Lead Reference

      • Field Name: LeadReference__c

    • Complete: Follow the wizard steps, and add the field to your Opportunity Page Layout(s).

  3. Generate a Salesforce Refresh Token via OAuth

    • Authorize in Browser:

      Replace CONSUMER_CLIENT_ID in the URL below and paste in your browser:

      Code SnippetCopy

    • Approve the App: After approval, you'll be redirected to a URL like:

      Code SnippetCopy

      Extract the code parameter from the URL.

    • Exchange Code for Tokens:

      Use Postman or cURL to send:

      Code SnippetCopy

      Example cURL:

      Code SnippetCopy

      Copy the refresh_token from the response.

  4. Gather Credentials

    • Save these values for later use in EdgeTag setup:

    • SF_CLIENT_ID = your Connected App Consumer Key SF_CLIENT_SECRET = your Connected App Consumer Secret SF_REFRESH_TOKEN = refresh token from OAuth process

EdgeTag Deployment

  1. Access Your EdgeTag Project

  2. Configure Webhook Integration

    • Consent Categories: Ensure at least Strictly necessary is enabled.

    • Webhook Name: e.g., SF Lead & Opportunity.

    • Webhook URL: Leave blank (EdgeTag will auto-generate).

    • Starter Template: Choose Salesforce - Lead & Opportunity

  3. Set Secrets

    • In the secrets, set:

    • SF_CLIENT_ID = your consumer key

    • SF_CLIENT_SECRET = your consumer secret

    • SF_REFRESH_TOKEN = your refresh token

  4. Deploy

    • Click Save & Deploy (top right). EdgeTag will compile and activate the webhook.

Validation & Testing

  • Send a test lead: Use Shopify Order Createdarrow-up-right payload.

  • EdgeTag Logs: Make sure the script runs without exceptions.

  • In Salesforce:

    • Verify the Lead record is created or updated for the customer email.

    • Confirm an associated Opportunity named Order <orderId> was created and is linked to the Lead.

  • If you observe errors, contact the EdgeTag team.

Result

The script will create or update the Lead in Salesforce and create an Opportunity with the Lead referenced (LeadReference__c).

Last updated

Was this helpful?