
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
intercom-client
Advanced tools
[](https://github.com/fern-api/fern) [](https://www.npmjs.com/package/intercom-client)
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.
The Intercom TypeScript library provides convenient access to the Intercom API from TypeScript.
The Intercom team is excited to announce a new and improved TypeScript SDK, currently available as an alpha
version. Check out the
API reference here.
During this time, we hope to gather feedback from the Intercom community to help drive the direction of the latest API changes.
Please feel free to leave in any suggestions in our open GitHub discussion to improve the experience for everyone!
npm i -s intercom-client@alpha
Instantiate and use the client with the following:
import { IntercomClient, Intercom } from "intercom-client";
const client = new IntercomClient({ token: "YOUR_TOKEN" });
await client.articles.create({
title: "Thanks for everything",
description: "Description of the Article",
body: "Body of the Article",
author_id: 1295,
state: Intercom.CreateArticleRequestState.Published,
});
The SDK exports all request and response types as TypeScript interfaces. Simply import them with the following namespace:
import { Intercom } from "intercom-client";
const request: Intercom.AdminsAwayRequest = {
...
};
List endpoints are paginated. The SDK provides an iterator so that you can simply loop over the items:
const result = await client.companies.list();
for await (const company of result) {
console.log(company.id);
}
You can also iterate page-by-page:
let page = await client.companies.list();
for (const company of page.data) {
console.log(company.id);
}
or manually:
while (page.hasNextPage()) {
page = page.getNextPage();
// ...
}
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error will be thrown.
import { IntercomError } from "intercom-client";
try {
await client.articles.create(...);
} catch (err) {
if (err instanceof IntercomError) {
console.log(err.statusCode);
console.log(err.message);
console.log(err.body);
}
}
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retriable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).
A request is deemed retriable when any of the following HTTP status codes is returned:
Use the maxRetries
request option to configure this behavior.
const response = await client.articles.create(..., {
maxRetries: 0 // override maxRetries at the request level
});
The SDK defaults to a 60 second timeout. Use the timeoutInSeconds
option to configure this behavior.
const response = await client.articles.create(..., {
timeoutInSeconds: 30 // override timeout to 30s
});
The SDK allows users to abort requests at any point by passing in an abort signal.
const controller = new AbortController();
const response = await client.articles.create(..., {
abortSignal: controller.signal
});
controller.abort(); // aborts the request
The SDK defaults to node-fetch
but will use the global fetch client if present. The SDK works in the following
runtimes:
The SDK provides a way for your to customize the underlying HTTP client / Fetch function. If you're running in an unsupported environment, this provides a way for you to break glass and ensure the SDK works.
import { IntercomClient } from "intercom-client";
const client = new IntercomClient({
...
fetcher: // provide your implementation here
});
While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!
On the other hand, contributions to the README are always very welcome!
FAQs
Official Node bindings to the Intercom API
The npm package intercom-client receives a total of 137,190 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
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.