Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
intercom-client
Advanced tools
The intercom-client npm package is a Node.js client for the Intercom API. It allows developers to interact with Intercom's services programmatically, enabling functionalities such as managing users, sending messages, and handling conversations.
Managing Users
This feature allows you to create and manage users in your Intercom account. The code sample demonstrates how to create a new user with an email and name.
const Intercom = require('intercom-client');
const client = new Intercom.Client({ token: 'your_access_token' });
client.users.create({
email: 'test@example.com',
name: 'Test User'
}).then(response => {
console.log(response.body);
}).catch(error => {
console.error(error);
});
Sending Messages
This feature allows you to send messages to users. The code sample demonstrates how to send an in-app message from an admin to a user.
const Intercom = require('intercom-client');
const client = new Intercom.Client({ token: 'your_access_token' });
client.messages.create({
message_type: 'inapp',
body: 'Hello, this is a test message!',
from: {
type: 'admin',
id: 'admin_id'
},
to: {
type: 'user',
id: 'user_id'
}
}).then(response => {
console.log(response.body);
}).catch(error => {
console.error(error);
});
Handling Conversations
This feature allows you to list and manage conversations. The code sample demonstrates how to list all conversations for a specific admin.
const Intercom = require('intercom-client');
const client = new Intercom.Client({ token: 'your_access_token' });
client.conversations.list({
type: 'admin',
admin_id: 'admin_id'
}).then(response => {
console.log(response.body);
}).catch(error => {
console.error(error);
});
The hubspot-api package provides a client for interacting with HubSpot's API. Similar to intercom-client, it allows for managing contacts, sending messages, and handling conversations. However, it is specific to HubSpot's CRM and marketing tools.
The zendesk-node-api package is a client for the Zendesk API. It offers functionalities for managing tickets, users, and other support-related tasks. While it shares some similarities with intercom-client in terms of user and conversation management, it is tailored for Zendesk's customer support platform.
The freshdesk-api package provides a client for interacting with Freshdesk's API. It allows for managing tickets, contacts, and conversations, similar to intercom-client. However, it is designed specifically for Freshdesk's customer support and helpdesk services.
Official Node bindings to the Intercom API
The Node SDK has been updated to support latest API version (2.4). The update also contains requested features, such like Typescript support. You can find more information on how-to migrate and what has changed in the migration guide.
yarn add intercom-client
This client is intended for server side use only. Please use the Intercom Javascript SDK for client-side operations.
yarn test
Compile using babel:
yarn prepublish
Import Intercom:
import { Client } from './dist/index';
Create a client using access tokens:
const client = new Client({ tokenAuth: { token: 'my_token' } });
This client library also supports passing in request
options:
const client = new Client({ tokenAuth: { token: 'my_token' } });
client.useRequestOpts({
baseURL: 'http://local.test-server.com',
});
Note that certain request options (such as json
, and certain headers
names cannot be overriden).
We version our API (see the "Choose Version" section of the API & Webhooks Reference for details). You can specify which version of the API to use when performing API requests using request options:
const client = new Client({ tokenAuth: { token: 'my_token' } });
client.useRequestOpts({
headers: {
'Intercom-Version': 2.4,
},
});
const admin = await client.admins.find({ id: '123' });
await client.admins.away({
adminId: '123',
enableAwayMode: true,
enableReassignMode: false,
});
await client.admins.listAllActivityLogs({
before: new Date('Fri, 17 Dec 2021 18:02:18 GMT');,
after: new Date('Fri, 17 Dec 2021 18:02:18 GMT');,
});
const admins = await client.admins.list();
const article = await client.articles.create({
title: 'Thanks for everything',
description: 'English description',
body: '<p>This is the body in html</p>',
authorId: 1,
state: 'published',
parentId: 1,
parentType: 'collection',
translatedContent: {
fr: {
title: 'Allez les verts',
description: 'French description',
body: '<p>French body in html</p>',
author_id: 1,
state: 'published',
},
},
});
const response = await client.articles.find({ id: '123' });
const article = await client.articles.update({
id: '123',
title: 'Thanks for everything',
description: 'English description',
body: '<p>This is the body in html</p>',
authorId: 1,
state: 'published',
parentId: 1,
parentType: 'collection',
translatedContent: {
fr: {
title: 'Allez les verts',
description: 'French description',
body: '<p>French body in html</p>',
author_id: 1,
state: 'published',
},
},
});
await client.articles.delete({ id: '123' });
const response = await client.articles.list({
page: 3,
perPage: 12,
});
const company = await client.companies.create({
createdAt: dateToUnixTimestamp(new Date()),
companyId: '46029',
name: 'BestCompanyInc.',
monthlySpend: 9001,
plan: '1. Get pizzaid',
size: 62049,
website: 'http://the-best.one',
industry: 'The Best One',
customAttributes: {},
});
const company = await client.companies.create({
createdAt: dateToUnixTimestamp(new Date()),
companyId: '46029',
name: 'BestCompanyInc.',
monthlySpend: 9001,
plan: '1. Get pizzaid',
size: 62049,
website: 'http://the-best.one',
industry: 'The Best One',
customAttributes: {},
});
const company = await client.companies.find({
companyId: 123,
});
const company = await client.companies.find({
name: 'bruh moment inc.',
});
const company = await client.companies.delete({
id: 62049,
});
const companies = await client.companies.list({
page: 1,
perPage: 35,
order: Order.DESC,
});
const companies = await client.companies.list({
tagId: '1234',
segmentId: '4567',
});
const companies = await client.companies.scroll.each({});
const companies = await client.companies.scroll.next({
scrollParam: '123_soleil',
});
const response = await client.companies.attachContact({
contactId: '123',
companyId: '234',
});
const response = await client.companies.detachContact({
contactId: '123',
companyId: '234',
});
const response = await client.companies.listAttachedContacts({
companyId: '123',
page: 1,
perPage: 15,
});
const response = await client.companies.listAttachedSegments({
companyId: '123',
});
const user = await client.contacts.createUser({
externalId: '536e564f316c83104c000020',
phone: '+48370044567',
name: 'Niko Bellic',
avatar: 'https://nico-from-gta-iv.com/lets_go_bowling.jpg',
signedUpAt: 1638203719,
lastSeenAt: 1638203720,
ownerId: '536e564f316c83104c000021',
isUnsubscribedFromEmails: true,
});
const lead = await client.contacts.createLead({
phone: '+48370044567',
name: 'Roman Bellic',
avatar: 'https://nico-from-gta-iv.com/lets_go_bowling_yey.jpg',
signedUpAt: 1638203719,
lastSeenAt: 1638203720,
ownerId: '536e564f316c83104c000021',
isUnsubscribedFromEmails: true,
});
const response = await client.contacts.find({ id: '123' });
const response = await client.contacts.update({
id: '123',
role: Role.USER,
name: 'Roman The Bowling Fan',
customAttributes: {
callBrother: "Hey Niko, it's me – Roman. Let's go bowling!",
},
});
const response = await client.contacts.delete({ id: '123' });
const response = await client.contacts.archive({ id: '123' });
const response = await client.contacts.unarchive({ id: '123' });
const response = await client.contacts.mergeLeadInUser({
leadId: '123',
userId: '234',
});
const response = await client.contacts.search({
data: {
query: {
operator: Operators.AND,
value: [
{
operator: Operators.AND,
value: [
{
field: 'updated_at',
operator: Operators.GREATER_THAN,
value: 1560436650,
},
{
field: 'conversation_rating.rating',
operator: Operators.EQUALS,
value: 1,
},
],
},
{
operator: Operators.OR,
value: [
{
field: 'updated_at',
operator: Operators.GREATER_THAN,
value: 1560436650,
},
{
field: 'conversation_rating.rating',
operator: Operators.EQUALS,
value: 2,
},
],
},
],
},
pagination: {
per_page: 5,
starting_after:
'WzE2MzU4NjA2NDgwMDAsIjYxODJiNjJlNDM4YjdhM2EwMWE4YWYxNSIsMl0=',
},
sort: { field: 'name', order: SearchContactOrderBy.ASC },
},
});
const response = await client.contacts.list({
perPage: 5,
startingAfter:
'WzE2MzU3NzU4NjkwMDAsIjYxODJiNjJhMDMwZTk4OTBkZWU4NGM5YiIsMl0=',
});
const response = await client.contacts.list();
const response = await client.contacts.listAttachedCompanies({
id: '123',
perPage: 5,
page: 1,
});
const response = await client.contacts.listAttachedTags({ id: '123' });
const response = await client.contacts.listAttachedSegments({ id: '123' });
const response = await client.contacts.listAttachedEmailSubscriptions({
id: '123',
});
const response = await client.conversations.create({
userId: '123',
body: 'Hello darkness my old friend',
});
const response = await client.conversations.find({
id: '123',
});
const response = await client.conversations.find({
id: '123',
inPlainText: true,
});
const response = await client.conversations.update({
id,
markRead: true,
customAttributes: {
anything: 'you want',
},
});
const response = await client.conversations.replyByIdAsUser({
id: '098',
body: 'blablbalba',
intercomUserId: '123',
attachmentUrls: '345',
});
const response = await client.conversations.replyByIdAsAdmin({
id: '098',
adminId: '458',
messageType: ReplyToConversationMessageType.NOTE,
body: '<b>Bee C</b>',
attachmentUrls: ['https://site.org/bebra.jpg'],
});
const response = await client.conversations.replyByLastAsUser({
body: 'blablbalba',
intercomUserId: '123',
attachmentUrls: '345',
});
const response = await client.conversations.replyByLastAsAdmin({
adminId: '458',
messageType: ReplyToConversationMessageType.NOTE,
body: '<b>Bee C</b>',
attachmentUrls: ['https://site.org/bebra.jpg'],
});
const response = await client.conversations.assign({
id: '123',
type: AssignToConversationUserType.TEAM,
adminId: '456',
assigneeId: '789',
body: '<b>blablbalba</b>',
});
const response = await client.conversations.assign({
id: '123',
withRunningAssignmentRules: true,
});
const response = await client.conversations.snooze({
id: '123',
adminId: '234',
snoozedUntil: '1501512795',
});
const response = await client.conversations.close({
id: '123',
adminId: '456',
body: "That's it...",
});
const response = await client.conversations.open({
id: '123',
adminId: '234',
});
const response = await client.conversations.attachContactAsAdmin({
id: '123',
adminId: '234',
customer: {
intercomUserId: '456',
},
});
const response = await client.conversations.attachContactAsAdmin({
id: '123',
userId: '234',
customer: {
intercomUserId: '456',
},
});
const response = await client.conversations.detachContactAsAdmin({
conversationId: '123',
contactId: '456',
adminId: '789',
});
const response = await client.conversations.search({
data: {
query: {
operator: Operators.AND,
value: [
{
operator: Operators.AND,
value: [
{
field: 'updated_at',
operator: Operators.GREATER_THAN,
value: 1560436650,
},
{
field: 'conversation_rating.rating',
operator: Operators.EQUALS,
value: 1,
},
],
},
{
operator: Operators.OR,
value: [
{
field: 'updated_at',
operator: Operators.GREATER_THAN,
value: 1560436650,
},
{
field: 'conversation_rating.rating',
operator: Operators.EQUALS,
value: 2,
},
],
},
],
},
pagination: {
per_page: 5,
starting_after:
'WzE2MzU4NjA2NDgwMDAsIjYxODJiNjJlNDM4YjdhM2EwMWE4YWYxNSIsMl0=',
},
sort: {
field: 'name',
order: SearchConversationOrderBy.DESC,
},
},
});
const response = await client.conversations.list({
order: Order.DESC,
sort: SortBy.UpdatedAt,
page: 1,
perPage: 10,
});
const response = await client.conversations.redactConversationPart({
type: RedactConversationPartType.CONVERSATION_PART,
conversationId: '123',
conversationPartId: '456',
});
const response = await client.counts.forApp();
const response = await client.counts.countConversation();
const response = await client.counts.countAdminConversation();
const response = await client.counts.countUserSegment();
const response = await client.counts.countUserTag();
const response = await client.counts.countCompanySegment();
const response = await client.counts.countCompanyTag();
const response = await client.counts.countCompanyUser();
const response = await client.counts.countCompanyTag();
const response = await client.counts.countCompanyUser();
const response = await client.dataAttributes.create({
name: 'list_cda',
model: ModelType.CONTACT,
dataType: DataType.STRING,
description: 'You are either alive or dead',
options: [{ value: 'alive' }, { value: 'dead' }],
});
const response = await client.dataAttributes.update({
id: '123',
description: 'You are either alive or dead',
options: [{ value: 'alive' }, { value: 'dead' }],
archived: true,
});
const response = await client.dataAttributes.list({
model: ModelType.CONTACT,
includeArchived: true,
});
const response = await client.events.create({
eventName: 'placed-order',
createdAt: 1389913941,
userId: 'f4ca124298',
metadata: {
order_date: 1392036272,
stripe_invoice: 'inv_3434343434',
order_number: {
value: '3434-3434',
url: 'https://example.org/orders/3434-3434',
},
price: {
currency: 'usd',
amount: 2999,
},
},
});
const response = await client.events.listBy({
userId: '1234',
perPage: 2,
summary: true,
email: 'i_love_memes@gmail.com',
});
const collection = await client.helpCenter.collections.create({
name: 'Thanks for everything',
description: 'English description',
translatedContent: {
fr: {
name: 'Allez les verts',
description: 'French description',
},
},
});
const response = await client.helpCenter.collections.find({ id: '123' });
const article = await client.helpCenter.collections.update({
id: '123',
name: 'Thanks for everything',
description: 'English description',
translatedContent: {
fr: {
name: 'Allez les verts',
description: 'French description',
},
},
});
await client.helpCenter.collections.delete({
id: '123',
});
const response = client.helpCenter.collections.list({
page: 3,
perPage: 12,
});
const collection = await client.helpCenter.sections.create({
name: 'Thanks for everything',
parentId: '1234',
translatedContent: {
fr: {
name: 'Allez les verts',
description: 'French description',
},
},
});
const response = await client.helpCenter.sections.find({ id: '123' });
const article = await client.helpCenter.sections.update({
id: '123',
name: 'Thanks for everything',
parentId: '456',
translatedContent: {
fr: {
name: 'Allez les verts',
description: 'French description',
},
},
});
await client.helpCenter.sections.delete({
id: '123',
});
const response = client.helpCenter.sections.list({
page: 3,
perPage: 12,
});
const response = await client.messages.create({
messageType: 'email',
subject: 'This is our demand now',
body: 'Destroy ponies',
template: 'plain',
from: {
type: 'admin',
id: '394051',
},
to: {
type: 'user',
id: '536e564f316c83104c000020',
},
});
const response = await client.notes.create({
adminId: '12345',
body: 'Shiny',
contactId: '5678',
});
const response = await client.notes.find({ id: '123' });
const response = await client.notes.list({
contactId: '123',
page: 2,
perPage: 3,
});
const response = await client.segments.find({
id: '123',
includeCount: true,
});
const response = await client.segments.list({
includeCount: true,
});
const response = await client.tags.create({ name: 'haven' });
const response = await client.tags.update({ id: '123', name: 'haven' });
const response = await client.tags.delete({ id: 'baz' });
const response = await client.tags.tagContact({
contactId: '123',
tagId: '234',
});
const response = await client.tags.tagConversation({
conversationId: '123',
tagId: '456',
adminId: '789',
});
const response = await client.tags.tagCompanies({
tagName: 'gutenTag',
companiesIds: ['123', '234', '456'],
});
const response = await client.tags.tagCompanies({
tagName: 'gutenTag',
companiesIds: ['123', '234', '456'],
});
const response = await client.tags.untagConversation({
conversationId: '123',
tagId: '345',
adminId: '678',
});
const response = await client.tags.untagContact({
contactId: '123',
tagId: '345',
});
const response = await client.tags.list();
const response = await client.teams.find({
id: '123',
});
const response = await client.teams.list();
const response = await client.visitors.find({ id: '123' });
OR
const response = await client.visitors.find({ userId: '123' });
const response = await client.visitors.update({
userId: '123',
name: 'anonymous bruh',
customAttributes: {
paid_subscriber: true,
},
});
const response = await client.visitors.delete({
id,
});
const response = await client.visitors.mergeToContact({
visitor: {
id: '123',
},
user: {
userId: '123',
},
type: Role.USER,
});
intercom-node
provides a helper for using identity verification:
import { IdentityVerification } from 'intercom-client';
IdentityVerification.userHash({
secretKey: 's3cre7',
identifier: 'jayne@serenity.io',
});
Apache-2.0
Add tests! Your patch won't be accepted if it doesn't have tests.
Document any change in behaviour. Make sure the README and any other relevant documentation are kept up-to-date.
Create topic branches. Don't ask us to pull from your master branch.
One pull request per feature. If you want to do more than one thing, send multiple pull requests.
Send coherent history. Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before sending them to us.
FAQs
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fintercom%2Fintercom-node) [![npm shield](ht
The npm package intercom-client receives a total of 68,689 weekly downloads. As such, intercom-client popularity was classified as popular.
We found that intercom-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.