[Paid] Install Intercom.io

It’s fairly straightforward to set up, since Discourse provides the JSON and you can just read that client-side. I’m sure you could do it a more complicated way, but this is essentially how I’ve done it with Javascript. I modified my code slightly since you’re looking for email and name, but you should be able to just embed the below code under Customize > CSS/HTML and be up & running.

Note the two places in the code of YOUR_INTERCOM_APP_ID and YOUR_DISCOURSE_DOMAIN.

Also FYI the current Intercom Messenger doesn’t play well on iOS devices on Discourse. But they could be working on an updated Messenger. And if I were to have used an updated Intercom Messenger, I would say that it works very well on iOS now :wink:

<script>
$.getJSON("https://YOUR_DISCOURSE_DOMAIN/session/current.json", function(json){
    var currentusernamefromjson = String(json.current_user.username);
    var currentuserflname = String(json.current_user.name);
    var fulllinktojson = "https://YOUR_DISCOURSE_DOMAIN/users/" + currentusernamefromjson + ".json";
    $.getJSON(fulllinktojson, function(json){
        var currentuseremail = String(json.user.email);
              Intercom('boot', {    
                    app_id: "YOUR_INTERCOM_APP_ID",
                    email: currentuseremail,
                    name: currentuserflname
                });
    });
});

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