Skip to main content

Embedding Fin Messenger in your Salesforce portal

This guides you through the steps needed in order to install the Fin Messenger on a Salesforce webpage.

Updated yesterday

1) Install the package in Salesforce

To install Fin Messenger on a Salesforce webpage, we've created a package you can install, which simply creates a custom setting definition.

You'll need to install the package in your Salesforce environment, before following the steps below.

Or


2) Configure Fin Messenger Settings in Salesforce

Now you've installed the package in Salesforce, you'll have a new custom setting called "Fin Messenger Settings". We need access to these settings and enter the credentials to connect your Fin app.

A) Access Fin Messenger Settings

In Salesforce,

  • Go to Setup > Custom Settings

  • Open Fin Messenger Settings

  • Click Manage and

  • Click New

B) Configure the App ID Custom Field

The App ID you'll need to enter in Salesforce can be found in the Fin platform by going to Settings > General

Once you have your Fin App ID, add it to the App ID custom field in your Fin Messenger Custom Settings in Salesforce
​

C) Configure the JWT Secret Key Custom Field

The JWT Secret key you'll need to enter in Salesforce can be found in the Fin platform by going to Settings > Fin Messenger

Once you have your JWT Secret Key, add it to the JWT Secret Key custom field in your Fin Messenger Settings in Salesforce.
​


3) Configure content security policy (CSP)

Once you've got the Fin Messenger Settings configured in Salesforce, we need to setup the relevant CSP rules so that the Fin Messenger can boot securely.

A) Access Site Security & Privacy

In Salesforce:

  • Go to your Setup > Sites > (your site) builder

  • Open Settings > Security & Privacy

B) Configure Security Level

Set the Security Level to Relaxed CSP, this allows us to add a script to the HEAD markup in the next step.

C) Configure Trusted Sites for Scripts

You need to add two trusted sites,

  1. https://widget.intercom.io which loads the messenger &

  2. https://js.intercomcdn.com which loads additional assets for the messenger to boot successfully.

D) Configure Trusted URLs

You also need to configure Trusted URLs for your Salesforce organization for the messenger to work optimally.

  • Go to Setup > Trusted URLs

  • Add the URLs from this article with the relevant CSP directives.

  • CSP Context could be set to All or Experience Builder Sites


4) Copy and paste the head markup into your Salesforce portal

Add JS code linked below to your Head Markup.

  • It adds an event listener to listen for the finMessengerData CustomEvent.

  • Once received, It dynamically loads the Fin messenger with the encoded JWT & app_id.

<script>
window.addEventListener('finMessengerData', function (e) {
const finMessengerData = e.detail;

// Do not boot if no JWT
if (finMessengerData.jwt == null) {
return;
}

window.intercomSettings = {
app_id: finMessengerData.appId,
intercom_user_jwt: finMessengerData.jwt,
api_base: "https://api-iam.intercom.io"
};

loadIntercom(finMessengerData.appId);
});

function loadIntercom(appId){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/'+appId;var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(d.readyState==='complete'){l();}else{if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}}}
</script>

The api_base value will need to be updated based on your regional location, see the table below to pick the right value.

Regional Location

API Base to Set

US

https://api-iam.intercom.io

EU

https://api-iam.eu.intercom.io

Australia

https://api-iam.au.intercom.io


5) Go to your Salesforce webpage, and add the Fin Messenger component

In Salesforce:

  • Go to your Setup > Sites > (your site) builder

  • Drag and drop the component to your portal page to deploy it

6) Edit the Apex Class installed to control what user data is sent over to Fin

In Salesforce:

  • Go to your Setup > Apex Classes > JwtGenerator

  • Click Edit

You can,

  • Update the Salesforce query used to get the current user information.

  • Choose the relevant field and how userId is set to uniquely identify your users.

  • Append to additionalAttributes if you want to include more attributes in your user data sent over to Fin.

Did this answer your question?