/intercom-elixir

Elixir helpers for generating the Intercom snippet and interacting with the Intercom API

Primary LanguageElixir

This is a fork of the intercom library which is no longer maintained.

Intercom

An Elixir library for working with Intercom using the Intercom API.

Installation

Add intercom to your list of dependencies in mix.exs:

# Elixir version 1.13 or higher

def deps do
  [
    {:intercom, "~> 3.0", hex: :intercom_elixir}
  ]
end

# otherwise

def deps do
  [
    {:intercom, "~> 2.0", hex: :intercom_elixir}
  ]
end

Configuration

To get started you'll need to add your access_token to your config.exs file. You can also change the http_adapter used to make requests. This library uses HTTPoison by default.

See How to get your Access Token.

Keep your access token secret. It provides access to your private Intercom data and should be treated like a password.

config :intercom,
  access_token: "access_token_here..."
  http_adapter: HTTPoison

Usage

The full documentation is published to hexdocs.

This library provides functions for easy access to API endpoints. For example, User endpoints can be accessed like this:

# Get a user
{:ok, user} = Intercom.Users.get("a1b2")

# List users by `tag_id`
{:ok, %{"users" => users}} = Intercom.Users.list_by(tag_id: "a1b2")

# Insert or update a user
{:ok, upserted_user} = Intercom.Users.upsert(%{id: "a1b2", name: "Steve Buscemi"})

If there are endpoints in the API that aren't currently supported by this library, you can access them manually like this:

{:ok, data} = Intercom.API.call_endpoint(:post, "new_endpoint/a1b2", %{body_data: "here"})

Resources