Code Monkey home page Code Monkey logo

tap-intercom's Introduction

tap-intercom

This is a Singer tap that produces JSON-formatted data following the Singer spec.

This tap:

Streams

admins

companies

  • Endpoint: https://api.intercom.io/companies
  • Primary key fields: id
  • Foreign key fields: segments > id, tags > id
  • Replication strategy: INCREMENTAL (query all, filter results)
    • Bookmark: updated_at (date-time)
  • Transformations: de-nest segments, tags

company_attributes reference#list-customer-data-attributes)

company_segments

conversations

  • Endpoint: https://api.intercom.io/conversations
  • Primary key fields: id
  • Foreign key fields: assignee > id, author > id, customer > id, customers > id, teammate > id, tags > id, user > id
  • Replication strategy: INCREMENTAL (query all, filter results)
    • Sort: updated_at asc
    • Bookmark: updated_at (date-time)
  • Transformations: de-nest customers, tags

conversation_parts

  • Endpoint: https://api.intercom.io/conversations/{conversation_id}
  • Primary key fields: id
  • Foreign key fields: conversation_id, author > id
  • Replication strategy: FULL_TABLE (ALL for each changed parent Conversation)
  • Transformations: Conversation parts with parent conversation_id

customer_attributes

leads

  • Endpoint: https://api.intercom.io/contacts
  • Primary key fields: id
  • Foreign key fields: companies > id, segments > id, tags > id
  • Replication strategy: INCREMENTAL (query all or filtered? TBD)
    • Sort: updated_at asc?
    • Bookmark query field: updated_since? TBD
    • Bookmark: updated_at (date-time)
  • Transformations: de-nest companies, segments, social_profiles, tags

segments

  • Endpoint: https://api.intercom.io/segments
  • Primary key fields: id
  • Foreign key fields: none
  • Replication strategy: INCREMENTAL (query all, filter results)
    • Bookmark: updated_at (date-time)
  • Transformations: none

tags

  • Endpoint: https://api.intercom.io/tags
  • Primary key fields: id
  • Foreign key fields: none
  • Replication strategy: FULL_TABLE
  • Transformations: none

teams

  • Endpoint: https://api.intercom.io/teams
  • Primary key fields: id
  • Foreign key fields: admin_ids
  • Replication strategy: FULL_TABLE
  • Transformations: none

users

  • Endpoint: https://api.intercom.io/users
  • Primary key fields: id
  • Foreign key fields: companies > id, segments > id, tags > id
  • Replication strategy: INCREMENTAL (query filtered)
    • Sort: updated_at asc
    • Bookmark query field: updated_since
    • Bookmark: updated_at (date-time)
  • Transformations: de-nest companies, segments, social_profiles, tags

Authentication

Quick Start

  1. Install

    Clone this repository, and then install using setup.py. We recommend using a virtualenv:

    > virtualenv -p python3 venv
    > source venv/bin/activate
    > python setup.py install
    OR
    > cd .../tap-intercom
    > pip install .
  2. Dependent libraries The following dependent libraries were installed.

    > pip install singer-python
    > pip install singer-tools
    > pip install target-stitch
    > pip install target-json
    
  3. Create your tap's config.json file. Intercom Authentication Types explains how to get an access_token. Make sure your OAuth Scope allows Read access to the endpoints above. Additionally, your App should use API Version v1.4. request_timeout is the time for which request should wait to get response. It is an optional parameter and default request_timeout is 300 seconds.

    {
        "access_token": "YOUR_API_ACCESS_TOKEN",
        "start_date": "2019-01-01T00:00:00Z",
        "request_timeout": 300,
        "user_agent": "tap-intercom <api_user_email@your_company.com>"
    }

    Optionally, also create a state.json file. currently_syncing is an optional attribute used for identifying the last object to be synced in case the job is interrupted mid-stream. The next run would begin where the last job left off.

    {
        "currently_syncing": "teams",
        "bookmarks": {
            "users": "2019-09-27T22:34:39.000000Z",
            "companies": "2019-09-28T15:30:26.000000Z",
            "conversations": "2019-09-28T18:23:53Z",
            "segments": "2019-09-27T22:40:30.000000Z",
            "company_segments": "2019-09-27T22:41:24.000000Z",
            "leads": "2019-09-27T22:16:30.000000Z"
        }
    }
  4. Run the Tap in Discovery Mode This creates a catalog.json for selecting objects/fields to integrate:

    tap-intercom --config config.json --discover > catalog.json

    See the Singer docs on discovery mode here.

  5. Run the Tap in Sync Mode (with catalog) and write out to state file

    For Sync mode:

    > tap-intercom --config tap_config.json --catalog catalog.json > state.json
    > tail -1 state.json > state.json.tmp && mv state.json.tmp state.json

    To load to json files to verify outputs:

    > tap-intercom --config tap_config.json --catalog catalog.json | target-json > state.json
    > tail -1 state.json > state.json.tmp && mv state.json.tmp state.json

    To pseudo-load to Stitch Import API with dry run:

    > tap-intercom --config tap_config.json --catalog catalog.json | target-stitch --config target_config.json --dry-run > state.json
    > tail -1 state.json > state.json.tmp && mv state.json.tmp state.json
  6. Test the Tap

    While developing the intercom tap, the following utilities were run in accordance with Singer.io best practices: Pylint to improve code quality:

    > pylint tap_intercom -d missing-docstring -d logging-format-interpolation -d too-many-locals -d too-many-arguments

    Pylint test resulted in the following score:

    Your code has been rated at 9.73/10

    To check the tap and verify working:

    > tap-intercom --config tap_config.json --catalog catalog.json | singer-check-tap > state.json
    > tail -1 state.json > state.json.tmp && mv state.json.tmp state.json

    Check tap resulted in the following:

    The output is valid.
    It contained 127 messages for 10 streams.
    
        10 schema messages
        92 record messages
        25 state messages
    
    Details by stream:
    +---------------------+---------+---------+
    | stream              | records | schemas |
    +---------------------+---------+---------+
    | admins              | 12      | 1       |
    | company_attributes  | 226     | 1       |
    | customer_attributes | 61      | 1       |
    | segments            | 5       | 1       |
    | teams               | 5       | 1       |
    | tags                | 404     | 1       |
    | company_segments    | 3       | 1       |
    | conversations       | 2284    | 1       |
    | conversation_parts  | 52610   | 48      |
    | leads               | 480     | 1       |
    | users               | 6231    | 1       |
    | companies           | 7182    | 1       |
    +---------------------+---------+---------+

    To run unit tests run the following command:

    python -m nose
    

Copyright © 2019 Stitch

tap-intercom's People

Contributors

asaf-erlich avatar bryantgray avatar cosimon avatar dmosorast avatar dscoleman avatar dsprayberry avatar hpatel41 avatar jacobrobertbaca avatar jeffhuth-bytecode avatar kallan357 avatar krispersonal avatar kspeer825 avatar leslievandemark avatar loeakaodas avatar nickcivili avatar prijendev avatar rdeshmukh15 avatar rushit0122 avatar savan-chovatiya avatar shantanu73 avatar zachharris1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tap-intercom's Issues

Error in the conversations schema

The schema conversations has a property called custom_attributes. This is an object with properties that vary from one record to the other. Right now, there are 2 properties of this object that have been added to it: "issue_type" and "type". Those are actually the examples provided in the Intercom API's documentation and are not properties we should expect to find
Capture d’écran 2023-01-16 à 17 10 18

Instead, we should not provide any properties to custom_attributes and return a jsonb that the end user will be able to parse themselves.

Issue with conversation_parts

The tap uses API version 2.5, which returns "comment" for many conversation_parts part_types that should have more detail (e.g. conversation_attribute_updated_by_admin, operator_workflow_event, and other more detailed assignment events). The part_types are much more granular in 2.6.

Conversation Parts sync using updated_at field

Suggest using the updated_at field for conversation_parts replication, its a large dataset in general so full replication is fairly onerous. Im using airbyte to do the tap and updated_at does not seem to be available for that table

ModuleNotFoundError: No module named 'tap_intercom'

I'm trying to build a Docker image to connect Intercom to BigQuery. My Dockerfile is as follows:

FROM python:3
RUN apt-get update
# Configs
COPY ./configs /configs
RUN git clone https://github.com/singer-io/tap-intercom
RUN pip install virtualenv
RUN virtualenv -p python /virtualenvs/intercom
RUN /bin/bash -c "source /virtualenvs/intercom/bin/activate && python /tap-intercom/setup.py install && deactivate"
RUN /virtualenvs/intercom/bin/tap-intercom --config /configs/intercom-config.json --catalog /configs/intercom-catalog.json > /configs/state.json
ENTRYPOINT /bin/bash

After running
docker build --tag singer .
it fails with this traceback:

=> ERROR [8/8] RUN /virtualenvs/intercom/bin/tap-intercom --config /configs/intercom-config.json --catalog /conf  0.5s
------
 > [8/8] RUN /virtualenvs/intercom/bin/tap-intercom --config /configs/intercom-config.json --catalog /configs/intercom-catalog.json > /configs/state.json:
#12 0.431 Traceback (most recent call last):
#12 0.431   File "/virtualenvs/intercom/bin/tap-intercom", line 33, in <module>
#12 0.431     sys.exit(load_entry_point('tap-intercom==1.1.3', 'console_scripts', 'tap-intercom')())
#12 0.431   File "/virtualenvs/intercom/bin/tap-intercom", line 25, in importlib_load_entry_point
#12 0.431     return next(matches).load()
#12 0.431   File "/usr/local/lib/python3.9/importlib/metadata.py", line 77, in load
#12 0.431     module = import_module(match.group('module'))
#12 0.431   File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
#12 0.431     return _bootstrap._gcd_import(name[level:], package, level)
#12 0.432   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
#12 0.432   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
#12 0.432   File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
#12 0.432 ModuleNotFoundError: No module named 'tap_intercom'
------
executor failed running [/bin/sh -c /virtualenvs/intercom/bin/tap-intercom --config /configs/intercom-config.json --catalog /configs/intercom-catalog.json > /configs/state.json]: exit code: 1

I've tried different python versions and it didn't help. What might be the reason for this behavior?

Export subscription types and opt-ins / opt-outs of users

Intercom has added subscription granularity. This is explained in this article

https://www.intercom.com/help/en/articles/5181083-manage-multiple-email-lists-with-granular-subscriptions

The REST APi allows extracting subscription types for users using additional requests

It is not documented in their data model schema, but you can find the REST definition there : https://developers.intercom.com/docs/references/rest-api/api.intercom.io/Subscription-Types/

For a user, getting subscription types is done via : /contacts/{contact_id}/subscriptions

It is not clear if we can know when a given user subscription types are edited and if this reflects on the usr updated_at field. I have asked Intercom this question (and maybe they can reply here)

User "tags" column is not properly updating

We are currently syncing user data from Intercom to our warehouse using the stitch integration, however we're running into issues with the tags field not being up to date.

The tags field is stored as a JSON object; it seems that when a new tag is added, the user record is not updated and a re-sync is not triggered by Stitch. This is evidenced by the updated_at timestamp, which doesn't increment when a new tag is added to a user.

Is it possible to trigger updates to the user record whenever the contents of the tags array changes?

tap-intercom always returns empty results regardless what's in the config file

Reproduce:

  1. clone repo
  2. python3 setup.py install
  3. mv config.json.example config.json
  4. add real access_token to config.json and edit date
  5. create catalog tap-intercom --config config.json --discover > catalog.json
  6. Run tap-intercom --config config.json --catalog catalog.json

The output is always:

INFO last/currently syncing stream: None
INFO Skipping stream: admins
INFO Skipping stream: companies
INFO Skipping stream: company_attributes
INFO Skipping stream: company_segments
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.