How To Integrate Intercom With Ruby on Rails

Yashu Mittal

Intercom is a popular marketing and consumer communication tool. With the help of this guide you will be able to integrate intercom no time.

I assume you have:

We will use Intercom-rails gem.

Pros & Cons



Step 1

Obtain app id from

Step 2

Add intercom-rails gem to your Gemfile:

gem 'intercom-rails'

Then run

bundle install

Use your app id to generate a config file

rails generate intercom:config APP-ID

Step 3

Initializer is saved as config/initializers/intercom.rb, here is where all the customization is done.

config.app_id = ENV["INTERCOM_APP_ID"] || "sOm3th1ng"

Remember to remove hard coded APP-ID from initializer, it should be stored either in git ignored config file or as environmental variable.

By default, intercom script is added on every page where current user can be identified, this behavior can be changed by either limiting chat insertion for a specific controller:

skip_after_action :intercom_rails_auto_include

Or chat can also be added for unidentified users:

config.include_for_logged_out_users = true

Step 4

Further customization. Intercom offers some really interesting options.

Method that defines current user can be associated with Intercom via:

config.user.current = { some_method }

Custom data can be associated with user:

config.user.custom_data = {
 plan: { |user| },
 happy_user: { |user| user.happy? }

Users can be grouped in order to treat them as if they were from a single company: = { company_method }

Intercom by default adds button to active chat, to override this behaviour add: = :custom

Now each element with id of Intercom will act as an activator, further customization of CSS selector can be achieved with:

config.inbox.custom_activator = '.intercom-link'

Check out their documentation to know more about Intercom integration.

Response to “How To Integrate Intercom With Ruby on Rails”

Stay current

Sign up for our newsletter, and we'll send you news and tutorials on business, growth, web design, coding and more!