Ruby bindings for the Intercom API (https://api.intercom.io).
For generating Intercom javascript script tags for Rails, please see https://github.com/intercom/intercom-rails
gem install intercom
Using bundler:
gem 'intercom'
Intercom.app_id = "my_app_iddd"
Intercom.api_key = "my-super-crazy-api-key"
The API supports:
POST,PUT,GET https://api.intercom.io/v1/users
POST,PUT,GET https://api.intercom.io/v1/users/messages
POST https://api.intercom.io/v1/users/impressions
POST https://api.intercom.io/v1/users/notes
user = Intercom::User.find_by_email("[email protected]")
user.custom_data["average_monthly_spend"] = 1234.56
user.save
user = Intercom::User.find_by_user_id("[email protected]")
user = Intercom::User.create(:email => "[email protected]", :name => "Bob Smith")
user = Intercom::User.new(params)
user.save
Intercom::User.all.count
Intercom::User.all.each {|user| puts %Q(#{user.email} - #{user.custom_data["average_monthly_spend"]}) }
Intercom::User.all.map {|user| user.email }
user = Intercom::User.find_by_email("[email protected]")
user.company = {:id => 6, :name => "Intercom"}
user.companies = [{:id => 6, :name => "Intercom"}, {:id => 9, :name => "Test Company"}]
You can also pass custom data within a company:
user.company = {:id => 6, :name => "Intercom", :referral_source => "Google"}
Intercom::Message.create(:email => "[email protected]", :body => "Example message from [email protected] to your application on Intercom.")
Intercom::Message.find(:email => "[email protected]", :thread_id => 123)
Intercom::Message.find_all(:email => "[email protected]")
Intercom::Message.mark_as_read(:email => "[email protected]", :thread_id => 123)
Intercom::Impression.create(:email => "[email protected]", :location => "/path/in/my/app", :user_ip => "1.2.3.4", :user_agent => "my-savage-iphone-app-0.1"
Intercom::Note.create(:email => "[email protected]", :body => "This is the text of the note")
Intercom::AuthenticationError
Intercom::ServerError
Intercom::ResourceNotFound