The Intercom Node SDK is currently in maintenance mode whilst we consider the best way to support it. We are not currently accepting new feature requests or actively working on the SDK.
Official Node bindings to the Intercom API
The Node SDK has been updated to support latest API version (2.6). 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-clientThis client is intended for server side use only. Please use the Intercom Javascript SDK for client-side operations.
Import Intercom:
import{Client}from'intercom-client';Create a client using access tokens:
constclient=newClient({tokenAuth: {token: 'my_token'}});This client library also supports passing in request options:
constclient=newClient({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:
constclient=newClient({tokenAuth: {token: 'my_token'}});client.useRequestOpts({headers: {'Intercom-Version': 2.6,},});If you are using the european instance of intercom and would like to call it directly and not be redirected through our US instance, you can set the baseUrl as follows:
constclient=newClient({tokenAuth: {token: 'my_token'}});client.useRequestOpts({baseURL: 'https://api.eu.intercom.io',});constadmin=awaitclient.admins.find({id: '123'});awaitclient.admins.away({adminId: '123',enableAwayMode: true,enableReassignMode: false,});awaitclient.admins.listAllActivityLogs({before: newDate('Fri, 17 Dec 2021 18:02:18 GMT');,after: newDate('Fri, 17 Dec 2021 18:02:18 GMT');,});constadmins=awaitclient.admins.list();constarticle=awaitclient.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',},},});constresponse=awaitclient.articles.find({id: '123'});constarticle=awaitclient.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',},},});awaitclient.articles.delete({id: '123'});constresponse=awaitclient.articles.list({page: 3,perPage: 12,});constcompany=awaitclient.companies.create({createdAt: dateToUnixTimestamp(newDate()),companyId: '46029',name: 'BestCompanyInc.',monthlySpend: 9001,plan: '1. Get pizzaid',size: 62049,website: 'http://the-best.one',industry: 'The Best One',customAttributes: {},});constcompany=awaitclient.companies.update({createdAt: dateToUnixTimestamp(newDate()),companyId: '46029',name: 'BestCompanyInc.',monthlySpend: 9001,plan: '1. Get pizzaid',size: 62049,website: 'http://the-best.one',industry: 'The Best One',customAttributes: {},});constcompany=awaitclient.companies.find({companyId: 123,});constcompany=awaitclient.companies.find({name: 'bruh moment inc.',});constcompany=awaitclient.companies.delete({id: 62049,});constcompanies=awaitclient.companies.list({page: 1,perPage: 35,order: Order.DESC,});constcompanies=awaitclient.companies.list({tagId: '1234',segmentId: '4567',});constcompanies=awaitclient.companies.scroll.each({});constcompanies=awaitclient.companies.scroll.next({scrollParam: '123_soleil',});constresponse=awaitclient.companies.attachContact({contactId: '123',companyId: '234',});constresponse=awaitclient.companies.detachContact({contactId: '123',companyId: '234',});constresponse=awaitclient.companies.listAttachedContacts({companyId: '123',page: 1,perPage: 15,});constresponse=awaitclient.companies.listAttachedSegments({companyId: '123',});constuser=awaitclient.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,});constlead=awaitclient.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,});constresponse=awaitclient.contacts.find({id: '123'});constresponse=awaitclient.contacts.update({id: '123',role: Role.USER,name: 'Roman The Bowling Fan',customAttributes: {callBrother: "Hey Niko, it's me – Roman. Let's go bowling!",},});constresponse=awaitclient.contacts.delete({id: '123'});constresponse=awaitclient.contacts.archive({id: '123'});constresponse=awaitclient.contacts.unarchive({id: '123'});constresponse=awaitclient.contacts.mergeLeadInUser({leadId: '123',userId: '234',});constresponse=awaitclient.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},},});constresponse=awaitclient.contacts.list({perPage: 5,startingAfter:
'WzE2MzU3NzU4NjkwMDAsIjYxODJiNjJhMDMwZTk4OTBkZWU4NGM5YiIsMl0=',});constresponse=awaitclient.contacts.list();constresponse=awaitclient.contacts.listAttachedCompanies({id: '123',perPage: 5,page: 1,});constresponse=awaitclient.contacts.listAttachedTags({id: '123'});constresponse=awaitclient.contacts.listAttachedSegments({id: '123'});constresponse=awaitclient.contacts.listAttachedEmailSubscriptions({id: '123',});constresponse=awaitclient.conversations.create({userId: '123',body: 'Hello darkness my old friend',});constresponse=awaitclient.conversations.find({id: '123',});constresponse=awaitclient.conversations.find({id: '123',inPlainText: true,});constresponse=awaitclient.conversations.update({
id,markRead: true,customAttributes: {anything: 'you want',},});constresponse=awaitclient.conversations.replyByIdAsUser({id: '098',body: 'blablbalba',intercomUserId: '123',attachmentUrls: '345',});constresponse=awaitclient.conversations.replyByIdAsAdmin({id: '098',adminId: '458',messageType: ReplyToConversationMessageType.NOTE,body: '<b>Bee C</b>',attachmentUrls: ['https://site.org/bebra.jpg'],});constresponse=awaitclient.conversations.replyByLastAsUser({body: 'blablbalba',intercomUserId: '123',attachmentUrls: '345',});constresponse=awaitclient.conversations.replyByLastAsAdmin({adminId: '458',messageType: ReplyToConversationMessageType.NOTE,body: '<b>Bee C</b>',attachmentUrls: ['https://site.org/bebra.jpg'],});constresponse=awaitclient.conversations.assign({id: '123',type: AssignToConversationUserType.TEAM,adminId: '456',assigneeId: '789',body: '<b>blablbalba</b>',});constresponse=awaitclient.conversations.assign({id: '123',withRunningAssignmentRules: true,});constresponse=awaitclient.conversations.snooze({id: '123',adminId: '234',snoozedUntil: '1501512795',});constresponse=awaitclient.conversations.close({id: '123',adminId: '456',body: "That's it...",});constresponse=awaitclient.conversations.open({id: '123',adminId: '234',});constresponse=awaitclient.conversations.attachContactAsAdmin({id: '123',adminId: '234',customer: {intercomUserId: '456',},});constresponse=awaitclient.conversations.attachContactAsAdmin({id: '123',userId: '234',customer: {intercomUserId: '456',},});constresponse=awaitclient.conversations.detachContactAsAdmin({conversationId: '123',contactId: '456',adminId: '789',});constresponse=awaitclient.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,},},});constresponse=awaitclient.conversations.list({startingAfter: 'WzE2NzA0MjI1MjkwMDAsMjQzMTY3NzA2ODcsMl0=',perPage: 10,});constresponse=awaitclient.conversations.redactConversationPart({type: RedactConversationPartType.CONVERSATION_PART,conversationId: '123',conversationPartId: '456',});constresponse=awaitclient.counts.forApp();constresponse=awaitclient.counts.countConversation();constresponse=awaitclient.counts.countAdminConversation();constresponse=awaitclient.counts.countUserSegment();constresponse=awaitclient.counts.countUserTag();constresponse=awaitclient.counts.countCompanySegment();constresponse=awaitclient.counts.countCompanyTag();constresponse=awaitclient.counts.countCompanyUser();constresponse=awaitclient.counts.countCompanyTag();constresponse=awaitclient.counts.countCompanyUser();constresponse=awaitclient.dataAttributes.create({name: 'list_cda',model: ModelType.CONTACT,dataType: DataType.STRING,description: 'You are either alive or dead',options: [{value: 'alive'},{value: 'dead'}],});constresponse=awaitclient.dataAttributes.update({id: '123',description: 'You are either alive or dead',options: [{value: 'alive'},{value: 'dead'}],archived: true,});constresponse=awaitclient.dataAttributes.list({model: ModelType.CONTACT,includeArchived: true,});constresponse=awaitclient.dataExport.create({createdAtAfter: 1527811200,createdAtBefore: 1530316800,});constresponse=awaitclient.dataExport.find({id: export.id})constresponse=awaitclient.dataExport.cancel({id: export.id})constresponse=awaitclient.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,},},});constresponse=awaitclient.events.listBy({userId: '1234',perPage: 2,summary: true,email: 'i_love_memes@gmail.com',});constcollection=awaitclient.helpCenter.collections.create({name: 'Thanks for everything',description: 'English description',translatedContent: {fr: {name: 'Allez les verts',description: 'French description',},},});constresponse=awaitclient.helpCenter.collections.find({id: '123'});constarticle=awaitclient.helpCenter.collections.update({id: '123',name: 'Thanks for everything',description: 'English description',translatedContent: {fr: {name: 'Allez les verts',description: 'French description',},},});awaitclient.helpCenter.collections.delete({id: '123',});constresponse=client.helpCenter.collections.list({page: 3,perPage: 12,});constcollection=awaitclient.helpCenter.sections.create({name: 'Thanks for everything',parentId: '1234',translatedContent: {fr: {name: 'Allez les verts',description: 'French description',},},});constresponse=awaitclient.helpCenter.sections.find({id: '123'});constarticle=awaitclient.helpCenter.sections.update({id: '123',name: 'Thanks for everything',parentId: '456',translatedContent: {fr: {name: 'Allez les verts',description: 'French description',},},});awaitclient.helpCenter.sections.delete({id: '123',});constresponse=client.helpCenter.sections.list({page: 3,perPage: 12,});constresponse=awaitclient.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',},});constresponse=awaitclient.messages.create({messageType: 'inapp',body: 'Look at me, I am a conversation now',from: {type: 'admin',id: '394051',},to: {type: 'user',id: '536e564f316c83104c000020',},createConversationWithoutContactReply: true,});constresponse=awaitclient.notes.create({adminId: '12345',body: 'Shiny',contactId: '5678',});constresponse=awaitclient.notes.find({id: '123'});constresponse=awaitclient.notes.list({contactId: '123',page: 2,perPage: 3,});constresponse=awaitclient.segments.find({id: '123',includeCount: true,});constresponse=awaitclient.segments.list({includeCount: true,});constresponse=awaitclient.subscriptions.listTypes();constresponse=awaitclient.phoneCallRedirect.create({phone: '+353871234567',});constresponse=awaitclient.tags.create({name: 'haven'});constresponse=awaitclient.tags.update({id: '123',name: 'haven'});constresponse=awaitclient.tags.delete({id: 'baz'});constresponse=awaitclient.tags.tagContact({contactId: '123',tagId: '234',});constresponse=awaitclient.tags.tagConversation({conversationId: '123',tagId: '456',adminId: '789',});constresponse=awaitclient.tags.tagCompanies({tagName: 'gutenTag',companiesIds: ['123','234','456'],});constresponse=awaitclient.tags.untagCompanies({tagName: 'gutenTag',companiesIds: ['123','234','456'],});constresponse=awaitclient.tags.untagConversation({conversationId: '123',tagId: '345',adminId: '678',});constresponse=awaitclient.tags.untagContact({contactId: '123',tagId: '345',});constresponse=awaitclient.tags.list();constresponse=awaitclient.teams.find({id: '123',});constresponse=awaitclient.teams.list();constresponse=awaitclient.visitors.find({id: '123'});OR
constresponse=awaitclient.visitors.find({userId: '123'});constresponse=awaitclient.visitors.update({userId: '123',name: 'anonymous bruh',customAttributes: {paid_subscriber: true,},});constresponse=awaitclient.visitors.delete({
id,});constresponse=awaitclient.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
yarn testCompile using babel:
yarn prepublishAdd 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.
