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
pfaffman
(Jay Pfaffman)
January 12, 2019, 1:35pm
3
Look at the howto topics about developing themes.
dax
(Daniela)
January 14, 2019, 5:24pm
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>
3 Likes
@Rob_Jeffrey have a look at our official Intercom plugin topic
7 Likes
Thanks for your reply! This worked great, genius
Ah great to know, in future discourse installs I will use the official plugin
dax
(Daniela)
January 29, 2019, 11:51am
13
We have also released some days ago a theme component for Intercom, you can take a look here
7 Likes