Intercom integration with Discourse?


(Rob Jeffrey) #1

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


(Jay Pfaffman) #3

Look at the #howto topics about developing themes.


(Daniela) #4

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>

(Vinoth Kannan) #9

@Rob_Jeffrey have a look at our official Intercom plugin topic