Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
intercom-client
Advanced tools
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://github.com/fern-api/fern) [![npm shield](https://img.shields.io/npm/v/intercom-client)](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
[![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 31,619 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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.