npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@musicplayce/intercom-ts

v0.0.12

Published

Intercom SDK made with Typescript intended for server-side use.

Downloads

57

Readme

This SDK is intended for server-side use only. Intercom offers their official Javascript SDK for client-side operations.

npm version Commitizen friendly

Table of Contents

Getting Started

Currently the SDK only supports Intercom API Version 2.0

Installing

Using npm:

npm install @musicplayce/intercom-ts

Using yarn:

yarn add @musicplayce/intercom-ts

Usage

Import the SDK into your project:

import IntercomClient from '@musicplayce/intercom-ts';

// or use require
const IntercomClient = require('@musicplayce/intercom-ts');

Initialize a new client:

const client = new IntercomClient({ token: 'YOUR_API_TOKEN_HERE' });

console.log(client.intercomVersion); // '2.0'

Contacts

Create:

	const create = await client.contacts.create({
		role: 'user',
		external_id: 'ID IDENTIFIER IN YOUR SYSTEM',
		email: '[email protected]',
		phone: '+5562999999999',
		name: 'Node Test User',
		avatar: 'URL TO AVATAR',
		signed_up_at: 1213313,
		last_seen_at: 123123,
		custom_attributes: {
			custom_attr1: 'custom_attribute_1',
			custom_attr2: 'custom_attribute_2'
		}
	});

Update:

	const update = await client.contacts.update('', {
		role: 'user',
		external_id: '',
		email: '[email protected]',
		custom_attributes: {
			plan: 'free'
		}
	});

Delete:

	const deleted = await client.contacts.delete('5ea1c76499abcb4afe7fb83f');

Find By Id:

	const findById = await client.contacts.find({
		id: '5ea1c76499abcb4afe7fb83f' // Intercom Id
	});

Find By Email:

	const findByEmail = await client.contacts.find({
		email: '[email protected]'
	});

Find By External Id:

	const findByExternalId = await client.contacts.find({
		external_id: '5ea1c76499abcb4afe7fb83f'
	});

Search Single Filter:

	const searchSingleFilter = await client.contacts.search({
		field: 'custom_attributes.salesforce_status',
		operator: '~',
		value: 'open'
	});

Search Multiple Filter:

	const searchMultipleFilters = await client.contacts.search({
		operator: 'AND',
		value: [
			{
				field: 'custom_attributes.social_network',
				operator: '=',
				value: 'facebook'
			},
			{
				field: 'custom_attributes.social_network',
				operator: '=',
				value: 'twitter'
			},
			{
				field: 'custom_attributes.social_network',
				operator: '=',
				value: 'instagram'
			}
		]
	});

Search Nested Filter:

	const searchNestedFilters = await client.contacts.search({
		operator: 'AND',
		value: [
			{
				operator: 'OR',
				value: [
					{
						field: 'created_at',
						operator: '>',
						value: 1560436650
					},
					{
						field: 'signed_up_at',
						operator: '>',
						value: 1560436784
					}
				]
			},
			{
				operator: 'OR',
				value: [
					{
						field: 'custom_attributes.salseforce_status',
						operator: '~',
						value: 'Open'
					},
					{
						field: 'custom_attributes.salesforce_object_type',
						operator: '=',
						value: 'Lead'
					}
				]
			}
		]
	});

Events

Create:

	const event = await client.events.create({
		event_name: 'click',
		created_at: 1571069751,
		email: '[email protected]',
		metadata: {
			clicked: true
		}
	});

List customer events:

	const eventList = await client.events.list({ email: '5ea1c76499abcb4afe7fb83f' })
	const eventList = await client.events.list({ intercom_user_id: '5ea1c76499abcb4afe7fb83f' })

According to the Intercom API you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days

Built With

  • Typescript - Typescript enables JavaScript developers to use highly-productive development tools and practices like static checking and code refactoring when developing JavaScript applications.
  • Axios - Promise based HTTP client for the browser and node.js.
  • lodash - A modern JavaScript utility library delivering modularity, performance, & extras.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Author(s)

  • Gustavo Quinta - Initial work - MoonTory

License

This project is licensed under the MIT License - see the LICENSE.md file for details