Skip to main content

travis pypi coveralls requiresio

Django integration for Intercom API

The aa-intercom package allows to

  • upload user data to Intercom including the last seen feature

  • push data to the Intercom API according to any event happening in your app

Installation

To use, add aa_intercom to your INSTALLED_APPS, and then migrate the project.

Setting up models

aa-intercom requires a few fields in the user model to be set. To make it work, you need to apply the aa_intercom.mixins.IntercomUserMixin to your custom user model (if you do not have your own custom user model set, check the documentation). The IntercomUserMixin.get_intercom_data() method can be overloaded to change the default user data sent to the Intercom API.

If you want to use the user last seen feature on Intercom, execute the following task right after the user logs in:

from aa_intercom.tasks import push_account_last_seen_tasks
push_account_last_seen_task.apply_async(args=[user.id], countdown=100)

Configuration

Another step is to add event types to project settings, for example:

INTERCOM_EVENT_TYPES = (
  ("example", _("Example Type")),
  ("generic", _("Generic Type"))
)

The last thing is to specify Intercom credentials in project settings:

INTERCOM_API_ACCESS_TOKEN = "your access token"

Make sure, you have the CACHES set (see: docs), and also as this app uses Celery, you need to have it configured.

To provide id prefix for Intercom user id, set INTERCOM_ID_PREFIX to desired value.

Using the IntercomEvent model

If you want to send any kind of event data to the Intercom API, create an instance of IntercomEvent filled with desired information, for example:

IntercomEvent.objects.create(
  user=request.user, type="generic", text_content=post.content,
  content_type=ContentType.objects.get_for_model(Post), object_id=post.id)

Then it will be automatically sent to the Intercom API. Unfortunately Intercom API has a tendency to go down often, therefore to make sure all events will be sent, setup a cronjob running the resend_intercom_events command which will push all remaining IntercomEvent objects to the API.

Sending unregistered user data

In case an upload of unregistered user data is needed, the aa_intercom.tasks.push_not_registered_user_data_task task can be used (email and name keys are required), for example:

push_not_registered_user_data_task.apply_async(args=[{
  "email": "test@arabel.la",
  "name": "Foo Bar",
  "pseudonym": "foobar"
}])

Commands

  • resend_intercom_events - resends all events (in case something went wrong, should be run chronically)

Support

  • Django 1.11

  • Python 2.7, 3.6

Metadata

Release files for aa-intercom 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for aa-intercom 1.0.1
File Interpreter ABI Platform
aa_intercom-1.0.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Release files / aa_intercom-1.0.1-py2.py3-none-any.whl

Download URL aa_intercom-1.0.1-py2.py3-none-any.whl
Size 17.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
6bac1fe9292d8b7881d50b3655268e3f8f3b83c6d7f0c93c86ad35a467d4cc90
BLAKE2b-256 checksum
How to use checksums
8add2c923898ed75f70e37d5f5eecee91c0de060260704c7b5a9344b539b0e88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

1.0.0

1 release file

0.0.2

1 release file

0.0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page