# Discourse + Intercom (Current User Id)

**URL:** https://meta.discourse.org/t/discourse-intercom-current-user-id/188798
**Category:** Extras
**Created:** [May 1, 2021, 8:36am UTC](https://meta.discourse.org/t/discourse-intercom-current-user-id/188798 "2021-05-01T08:36:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Paul\_King1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/paul_king1/32/218888_2.png) [@Paul\_King1](https://meta.discourse.org/u/Paul_King1)
#### Post date: [May 1, 2021, 8:36am UTC](https://meta.discourse.org/t/discourse-intercom-current-user-id/188798/1 "2021-05-01T08:36:19Z")

</div>

Hello I am trying to setup Intercom (live chat - [www.intercom.com](http://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? | Intercom Help](https://www.intercom.com/help/en/articles/268-what-is-user_id-and-why-would-i-want-to-use-it)

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!

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/a/ea74c286a65fa42de44e914599ea3f042e01d499.png)

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [May 1, 2021, 8:51am UTC](https://meta.discourse.org/t/discourse-intercom-current-user-id/188798/2 "2021-05-01T08:51:45Z")

</div>

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.

> **[Setting up OAuth | Intercom and Fin Developer Platform](https://developers.intercom.com/docs/build-an-integration/learn-more/authentication/setting-up-oauth)**
>
> Faster resolutions, higher CSAT, and lighter support volumes with the only platform to combine the power of automation and human customer support.

Using the basic Oauth plugin for Discourse. [Discourse OAuth2 Basic](https://meta.discourse.org/t/oauth2-basic-support/33879)

---

<div class="post-metadata">

### Author: ![Paul\_King1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/paul_king1/32/218888_2.png) [@Paul\_King1](https://meta.discourse.org/u/Paul_King1)
#### Post date: [May 1, 2021, 11:15am UTC](https://meta.discourse.org/t/discourse-intercom-current-user-id/188798/3 "2021-05-01T11:15:00Z")

</div>

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

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/a/4a2dbf70e97bd366c4d7afd43c23bbe04365cbcc.png)
