API wrapper for intercom written in Python
Project description
intercom-python
intercom-python is an API wrapper for intercom, written in Python.
This library uses Oauth2 for authentication.
Installing
pip install intercom-python
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:
- Get authorization URL
url = client.authorization_url(redirect_uri)
- Get access token using code
response = client.get_access_token(code)
- 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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for intercom_python_2-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfd9690869704d4d18c7b5e9b89c3147c198e5f2bf5ef582f12638e6f3ec4589 |
|
MD5 | 3cde1da64a02c72cc358755b4c3d9fd1 |
|
BLAKE2b-256 | 38ce1c2c15fce733b92d4c213f60f448690e95ab3e2e231daced2de7e1c8d321 |