Salesforce Listener

Salesforce Listener

With the Salesforce Listener Block, you can configure your flow to ingest files stored in Salesforce for processing within the Hyperscience application.

The Salesforce Listener Block is available in both SaaS and on-premise versions of the Hyperscience application.

Sample use cases

Block settings table

Name Required? Description
Topic Name Yes The name of the topic you configured in Salesforce for the Salesforce Listener
Associated Username Yes The username associated with the Salesforce Connected App or External Client App
Consumer Key Yes The Consumer Key from the Salesforce Connected App or External Client App
Private Key Yes The key generated during the authentication-configuration process.
The private key is a long string that begins with ----BEGIN PRIVATE KEY---- and ends with \n----END PRIVATE KEY----\n. Include both of these tags and all characters between them when entering the private key.
Sandbox Environment Yes Indicates whether the connected Salesforce instance is a sandbox environment

Setting up Salesforce Listener

Setup within Salesforce

Install and set up Hyperscience Package

  1. Install the Hyperscience package in the desired Salesforce org.
  2. Go to the Salesforce AppExchange’s Hyperscience Platform listing.
  3. Click the Get It Now button.
  4. Enter your details and click the Contact Me button.
  5. A Hyperscience representative will contact you and provide you with the Hyperscience package.
  6. Once you have the Hyperscience package, install it in the desired Salesforce org.
  7. Add Hyperscience Permission Set to users that should have access to the Hyperscience application.
  8. Enable the Query All Files permission.

Configure authentication

The steps required to configure the authentication for the connection depend on whether you’re using a Salesforce Connected App or an External Client App. The External Client App offers improved security and packaging options compared to Connected Apps.

Salesforce Connected App

Generate private key

  1. Create the private key (salesforce.key) and certificate (salesforce.crt) by running the following command:
openssl req -x509 -sha256 -nodes -days 36500 -newkey rsa:2048 -keyout salesforce.key -out salesforce.crt
  1. Copy the private key to your clipboard.
cat [private.key file] | sed 's/$/\n/' | tr -d '\n' | pbcopy
  1. Paste the private key into a text file and save it. Later, you will need to paste it into your Salesforce Listener Block within Hyperscience.

Create your JWT Connected App

  1. Log in to Salesforce and go to Setup.
  2. In the side navigation, go to Apps > App Manager and click New Connected App.
  3. Enter the information in the Basic Information section.
  4. In API (Enable OAuth Settings), complete the following steps:
    • Select Enable OAuth Settings.
    • In Callback URL, enter “http://localhost”.
    • Select Use digital signatures, and upload the salesforce.crt file that was generated when you created your private key.
    • In Selected OAuth Scopes, add the following permissions:
      • Manage user data via APIs (api)
      • Perform requests at any time (refresh_token, offline_access)
  5. Click Save.
  6. On the resulting page, click Manage.
  7. Click Edit Policies.
  8. In the OAuth policies section, change Permitted Users to Admin approved users are pre-authorized.
  9. Click Save.

Create and link the Salesforce topic

  1. Create a Streaming Channel or choose an existing one that you will use. Note that channel names in Salesforce should start with /u/.
  2. Obtain the ID of the streamingChannel.
  3. Create a record of Hyperscience__Channel_Object_Link__c.
Hyperscience__Channel_Object_Link__c channelObjectLink = new Hyperscience__Channel_Object_Link__c();
channelObjectLink.Hyperscience__Channel_Name__c = '/u/channelName';
channelObjectLink.Hyperscience__Channel_Id__c = 'channelId';
channelObjectLink.Hyperscience__Object_Api_Name__c = 'objectApiName';
insert channelObjectLink;

The above script creates a link between a Salesforce object and a Streaming channel.

After completing these steps, every time that a file is attached to a record of an object with API name objectApiName, a message will be published into the channel with the name /u/channelName and ID channelId.

Known limitations