Intercom integration with Discourse?

Hello all,

I have Intercom (https://www.intercom.com/) on my discourse site and I want to auto populate the email address as the user is already logged in with their email to the discouse forum (as its a closed community)

Intercom offer the following code in Ruby:

I’m guessing I cant use any server side code within the admin/customization panel in discourse its self but I am wondering if any one else has solved this problem before?

Thanks in advance, I really appreciate all responses.

Rob

1 Like

Look at the #howto topics about developing themes.

Hi Rob, I think you can do it if you add variables to the script, for example:

<script>
$.getJSON("/session/current.json", function(json) {
    var userusername = String(json.current_user.username);
    var currentname = String(json.current_user.name);
    var pathtojson = "/users/" + userusername + ".json";
    $.getJSON(pathtojson, function(json){
        var useremail = String(json.user.email);
        var createdatuser = String(json.user.created_at);

        window.intercomSettings = {
            app_id: '[APP_ID]',
            email: useremail,
            name: currentname,
            created_at: createdatuser,
            "discourse_username": userusername,
        };
    });
});
</script>
3 Likes

@Rob_Jeffrey have a look at our official Intercom plugin topic

6 Likes

Thanks for your reply! This worked great, genius

Ah great to know, in future discourse installs I will use the official plugin

We have also released some days ago a theme component for Intercom, you can take a look here

6 Likes