Intercom Python SDK

5.0.1 · active · verified Fri Apr 17

The Python Intercom SDK (PyPI project name `python-intercom`, installs `intercom_python_sdk`) provides a convenient way to interact with the Intercom API. It allows developers to manage users, conversations, events, and more. The SDK is currently at version 5.0.1 and is regularly updated through automated API specification regenerations.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the IntercomClient using an environment variable for security and then fetch a list of users. Ensure `INTERCOM_ACCESS_TOKEN` is set in your environment.

import os
from intercom_python_sdk import IntercomClient

# Initialize the client with your Personal Access Token
# Recommended: Store token in an environment variable named INTERCOM_ACCESS_TOKEN
client = IntercomClient(personal_access_token=os.environ.get("INTERCOM_ACCESS_TOKEN", ""))

if not client.personal_access_token:
    print("Error: INTERCOM_ACCESS_TOKEN environment variable not set.")
    print("Please set it or pass your token directly to IntercomClient(personal_access_token='YOUR_TOKEN')")
else:
    try:
        # Example: List all users
        users_list = client.users.list_all(per_page=1)
        if users_list and users_list.data:
            print(f"Successfully retrieved {len(users_list.data)} user(s).")
            for user in users_list.data:
                print(f"  User ID: {user.id}, Email: {user.email}")
        else:
            print("No users found or an empty list was returned.")
    except Exception as e:
        print(f"An error occurred: {e}")

view raw JSON →