Discourse + Intercom (Current User Id)

Hello I am trying to setup Intercom (live chat - www.intercom.com). It allows me to insert code below which detects logged in users.

I have managed to install it and it works great… The issue is that the key variable used by intercom to detect the user is the email address. So if this is changed it wont work as expected.

The solution is to add a user_id that I can obtain from Discourse. This is explained here by intercom: What is user_id and why would I want to use it? | Help Center

Now I am sure this is a fairly easy fix… But I am struggling a little.

I believe I need to add the “current discourse user Id” to the code below but I am unsure how to do this… Please could I get some help with this if anyone knows how to do it.

I was thinking it would be something like this: user_id: “<%= current_user.id %>”, // User ID

But this is a complete guess!

Another option might be to set up Intercom as id provider?

So users will log into Discourse using Intercom credentials and that user account can be automatically synced with Discourse.

Using the basic Oauth plugin for Discourse. OAuth2 Basic Support


I have managed to install it but it seems the variables are wrong.