Articles on: Auth & Payment Portal

How to add Intercom to my Portal?

Adding Intercom is a great idea to get in touch with your customers, provide customer support and also enrich your CRM.

PluginLab lets you add a custom script for your Authentication and Payment Portal.

We'll see how you can use this feature to integrate Intercom and add the user's email, name and id to your favorite CRM.


Prerequisite



You must have configured your PluginLab authentication portal first. You can follow this guide to do it.


Getting started



You first have to create an account to https://intercom.com
Choose their integration with code and copy your intercom app id

You don't need to copy their whole script since we'll provide an enhanced version :)

Copy the app id and script


Then go to PluginLab > Plugin Settings > Portal Script
Paste the following code, by replacing <YOUR_APP_ID> by your actual intercom app id in the <head> input.

<script>
window.addEventListener('onPluginLabMember', (event) => {
    // the member can be either null or contain many fields
    const member = event.detail;

    window.intercomSettings = {
        api_base: "https://api-iam.intercom.io",
        app_id: <YOUR_APP_ID>,
        name: member?.name,
        email: member?.email,
    };
   
    // We changed a bit their code so it's prefilled with your app id variable
    (function(){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/${window.intercomSettings.app_id}`;var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(document.readyState==='complete'){l();}else if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})();
}, { once: true });
</script>


What does the script do?



The script will be loaded when PluginLab has populated the user info (or null) in the window.

If the user exists, it will automatically set the needed user information in your intercom CRM.

As a result:

the user will see the intercom chatbox
your will get the user info in your CRM


Intercom Chatbox

User added into Intercom


Feeling lost?



If you need any help, feel free to reach out to us using the chatbox at the bottom right corner

Updated on: 28/07/2023

Was this article helpful?

Share your feedback

Cancel

Thank you!