Giter Site home page Giter Site logo

gearplug / intercom-python Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 9 KB

intercom-python is an API wrapper for intercom, written in Python.

License: MIT License

Python 100.00%
api intercom oauth oauth2 python requests wrapper conversations lead tags

intercom-python's Introduction

intercom-python

intercom-python is an API wrapper for intercom, written in Python.
This library uses Oauth2 for authentication.

Installing

pip install intercom-python-2

Usage

# if you have an access token:
from intercom.client import Client
client = Client(access_token=access_token)
# if you are using Oauth2 to get an access_token:
from intercom.client import Client
client = Client(client_id=client_id, client_secret=client_secret)

To obtain and set an access token:

  1. Get authorization URL
url = client.authorization_url(redirect_uri)
  1. Get access token using code
response = client.get_access_token(code)
  1. Set access token
client.set_token(access_token)

Check more information about Intercom Oauth: https://developers.intercom.com/building-apps/docs/setting-up-oauth

Get current user

me = client.get_current_user()

List all admins

admins = client.list_all_admins()

List data attributes

# model options are: contact, company, conversation
data_atts = client.list_data_attributes(model, include_archived=False)

List tags

tags = client.list_tags()

Contacts

- List all contacts

contacts = client.list_all_contacts()

- Filter contacts

# field options: https://developers.intercom.com/intercom-api-reference/reference/searchcontacts
contacts = client.filter_contacts(field, operator, value)
# operator options: =, !=, IN, NIN, <, >, ~, !~, ^, $

- Create contact

# role options are: 'user' and 'lead'
# signed_up_at and last_seen_at use epoch time stamp. For example: 1685986703 equals Monday, 5 June 2023 17:38:23
# custom_attributes dict structure:
#     {"field_name": "field_value", "field_name": "field_value", ...}
contact = client.create_contact(
    role: str, 
    email: str, 
    external_id: str = None,
    phone: str = None,
    name: str = None,
    avatar: str = None,
    signed_up_at: int = None,
    last_seen_at: int = None,
    owner_id: int = None,
    unsubscribed: bool = None,
    custom_attributes: dict = None
)

- Add tag to contact

response = client.add_tag_to_contact(contact_id, tag_id)

- Create a note

text = "this is a note"
response = client.create_note(contact_id, text)

intercom-python's People

Contributors

ingmferrer avatar juanrios15 avatar

Stargazers

 avatar

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.