intercom-client 2.11.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +873 -396
  2. package/dist/admin/admin.types.d.ts +13 -0
  3. package/dist/admin/admin.types.d.ts.map +1 -0
  4. package/dist/admin/admin.types.js +3 -0
  5. package/dist/admin/admin.types.js.map +1 -0
  6. package/dist/admin.d.ts +48 -0
  7. package/dist/admin.d.ts.map +1 -0
  8. package/dist/admin.js +40 -41
  9. package/dist/admin.js.map +1 -0
  10. package/dist/client.d.ts +67 -0
  11. package/dist/client.d.ts.map +1 -0
  12. package/dist/client.js +230 -239
  13. package/dist/client.js.map +1 -0
  14. package/dist/common/common.types.d.ts +91 -0
  15. package/dist/common/common.types.d.ts.map +1 -0
  16. package/dist/common/common.types.js +29 -0
  17. package/dist/common/common.types.js.map +1 -0
  18. package/dist/company/company.types.d.ts +37 -0
  19. package/dist/company/company.types.d.ts.map +1 -0
  20. package/dist/company/company.types.js +3 -0
  21. package/dist/company/company.types.js.map +1 -0
  22. package/dist/company.d.ts +67 -0
  23. package/dist/company.d.ts.map +1 -0
  24. package/dist/company.js +110 -83
  25. package/dist/company.js.map +1 -0
  26. package/dist/contact/contact.types.d.ts +80 -0
  27. package/dist/contact/contact.types.d.ts.map +1 -0
  28. package/dist/contact/contact.types.js +3 -0
  29. package/dist/contact/contact.types.js.map +1 -0
  30. package/dist/contact.d.ts +130 -0
  31. package/dist/contact.d.ts.map +1 -0
  32. package/dist/contact.js +155 -81
  33. package/dist/contact.js.map +1 -0
  34. package/dist/conversation/conversation.types.d.ts +144 -0
  35. package/dist/conversation/conversation.types.d.ts.map +1 -0
  36. package/dist/conversation/conversation.types.js +50 -0
  37. package/dist/conversation/conversation.types.js.map +1 -0
  38. package/dist/conversation.d.ts +176 -0
  39. package/dist/conversation.d.ts.map +1 -0
  40. package/dist/conversation.js +287 -48
  41. package/dist/conversation.js.map +1 -0
  42. package/dist/dataAttribute/dataAttribute.types.d.ts +32 -0
  43. package/dist/dataAttribute/dataAttribute.types.d.ts.map +1 -0
  44. package/dist/dataAttribute/dataAttribute.types.js +18 -0
  45. package/dist/dataAttribute/dataAttribute.types.js.map +1 -0
  46. package/dist/dataAttribute.d.ts +33 -0
  47. package/dist/dataAttribute.d.ts.map +1 -0
  48. package/dist/dataAttribute.js +49 -0
  49. package/dist/dataAttribute.js.map +1 -0
  50. package/dist/errors/badResponse.error.d.ts +9 -0
  51. package/dist/errors/badResponse.error.d.ts.map +1 -0
  52. package/dist/errors/badResponse.error.js +21 -0
  53. package/dist/errors/badResponse.error.js.map +1 -0
  54. package/dist/event/event.types.d.ts +29 -0
  55. package/dist/event/event.types.d.ts.map +1 -0
  56. package/dist/event/event.types.js +3 -0
  57. package/dist/event/event.types.js.map +1 -0
  58. package/dist/event.d.ts +41 -0
  59. package/dist/event.d.ts.map +1 -0
  60. package/dist/event.js +42 -45
  61. package/dist/event.js.map +1 -0
  62. package/dist/index.d.ts +8 -0
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +25 -76
  65. package/dist/index.js.map +1 -0
  66. package/dist/message/message.types.d.ts +17 -0
  67. package/dist/message/message.types.d.ts.map +1 -0
  68. package/dist/message/message.types.js +11 -0
  69. package/dist/message/message.types.js.map +1 -0
  70. package/dist/message.d.ts +30 -0
  71. package/dist/message.d.ts.map +1 -0
  72. package/dist/message.js +32 -31
  73. package/dist/message.js.map +1 -0
  74. package/dist/scroll.d.ts +24 -0
  75. package/dist/scroll.d.ts.map +1 -0
  76. package/dist/scroll.js +67 -79
  77. package/dist/scroll.js.map +1 -0
  78. package/dist/segment/segment.types.d.ts +11 -0
  79. package/dist/segment/segment.types.d.ts.map +1 -0
  80. package/dist/segment/segment.types.js +3 -0
  81. package/dist/segment/segment.types.js.map +1 -0
  82. package/dist/segment.d.ts +22 -0
  83. package/dist/segment.d.ts.map +1 -0
  84. package/dist/segment.js +26 -36
  85. package/dist/segment.js.map +1 -0
  86. package/dist/subscription/subscription.types.d.ts +19 -0
  87. package/dist/subscription/subscription.types.d.ts.map +1 -0
  88. package/dist/subscription/subscription.types.js +10 -0
  89. package/dist/subscription/subscription.types.js.map +1 -0
  90. package/dist/tag/tag.types.d.ts +6 -0
  91. package/dist/tag/tag.types.d.ts.map +1 -0
  92. package/dist/tag/tag.types.js +3 -0
  93. package/dist/tag/tag.types.js.map +1 -0
  94. package/dist/tag.d.ts +52 -0
  95. package/dist/tag.d.ts.map +1 -0
  96. package/dist/tag.js +93 -57
  97. package/dist/tag.js.map +1 -0
  98. package/dist/team/team.types.d.ts +7 -0
  99. package/dist/team/team.types.d.ts.map +1 -0
  100. package/dist/team/team.types.js +3 -0
  101. package/dist/team/team.types.js.map +1 -0
  102. package/dist/team.d.ts +18 -0
  103. package/dist/team.d.ts.map +1 -0
  104. package/dist/team.js +23 -0
  105. package/dist/team.js.map +1 -0
  106. package/dist/util/time.d.ts +3 -0
  107. package/dist/util/time.d.ts.map +1 -0
  108. package/dist/util/time.js +6 -0
  109. package/dist/util/time.js.map +1 -0
  110. package/dist/util/url.d.ts +3 -0
  111. package/dist/util/url.d.ts.map +1 -0
  112. package/dist/util/url.js +9 -0
  113. package/dist/util/url.js.map +1 -0
  114. package/package.json +57 -48
  115. package/dist/bulk.js +0 -55
  116. package/dist/counts.js +0 -88
  117. package/dist/customer.js +0 -33
  118. package/dist/note.js +0 -43
  119. package/dist/snippet.js +0 -121
  120. package/dist/user-data.js +0 -105
  121. package/dist/user.js +0 -120
  122. package/dist/visitor.js +0 -54
package/README.md CHANGED
@@ -1,27 +1,30 @@
1
1
  # intercom-node
2
- > Official Node bindings to the Intercom API
3
2
 
4
- [![Circle CI](https://circleci.com/gh/intercom/intercom-node.png?style=badge)](https://circleci.com/gh/intercom/intercom-node)
3
+ [![Circle CI](https://circleci.com/gh/intercom/intercom-node.png?style=shield)](https://circleci.com/gh/intercom/intercom-node)
4
+ [![npm](https://img.shields.io/npm/v/intercom-client)](https://www.npmjs.com/package/intercom-client)
5
+ ![Intercom API Version](https://img.shields.io/badge/Intercom%20API%20Version-2.4-blue)
6
+ ![Typescript Supported](https://img.shields.io/badge/Typescript-Supported-lightgrey)
5
7
 
6
- [![npm version](https://badge.fury.io/js/intercom-client.svg)](http://badge.fury.io/js/intercom-client)
8
+ > Official Node bindings to the [Intercom API](https://api.intercom.io/docs)
7
9
 
8
- ## Installation
10
+ ## Project Updates
11
+
12
+ ## Breaking changes
9
13
 
10
- [![docker_image 1](https://cloud.githubusercontent.com/assets/15954251/17524401/5743439e-5e56-11e6-8567-d3d9da1727da.png)](https://hub.docker.com/r/intercom/sdk-images/) <br>
11
- Try out our [Docker Image (Beta)](https://hub.docker.com/r/intercom/sdk-images/) to help you get started more quickly. <br>
12
- It should make it easier to get setup with the SDK and start interacting with the API. <br>
13
- (Note, this is in Beta and is for testing purposes only, it should not be used in production)
14
+ 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](https://github.com/intercom/intercom-node/wiki/Migration-guide).
15
+
16
+ ## Installation
14
17
 
15
18
  ```bash
16
- npm install intercom-client
19
+ yarn add intercom-client
17
20
  ```
18
21
 
19
- **This client is intended for server side use only. Please use the [Intercom Javascript SDK](https://developers.intercom.com/v2.0/docs/intercom-javascript) for client-side operations.**
22
+ **This client is intended for server side use only. Please use the [Intercom Javascript SDK](https://developers.intercom.com/v2.4/docs/intercom-javascript) for client-side operations.**
20
23
 
21
24
  ## Testing
22
25
 
23
26
  ```bash
24
- npm test
27
+ yarn test
25
28
  ```
26
29
 
27
30
  ## Running the code locally
@@ -29,596 +32,1070 @@ npm test
29
32
  Compile using babel:
30
33
 
31
34
  ```bash
32
- gulp babel
35
+ yarn prepublish
33
36
  ```
34
37
 
35
- Require Intercom:
38
+ ## Usage
36
39
 
37
- ```node
38
- var Intercom = require('./dist/index');
40
+ Import Intercom:
41
+
42
+ ```typescript
43
+ import { Client } from './dist/index';
39
44
  ```
40
45
 
41
- ## Usage
46
+ Create a client using access tokens:
42
47
 
43
- Require Intercom:
48
+ ```typescript
49
+ const client = new Client({ tokenAuth: { token: 'my_token' } });
50
+ ```
44
51
 
45
- ```node
46
- var Intercom = require('intercom-client');
52
+ ## Request Options
53
+
54
+ This client library also supports passing in [`request` options](https://github.com/axios/axios#request-config):
55
+
56
+ ```typescript
57
+ const client = new Client({ tokenAuth: { token: 'my_token' } });
58
+ client.useRequestOpts({
59
+ baseURL: 'http://local.test-server.com',
60
+ });
47
61
  ```
48
62
 
49
- Create a client:
50
- #### Using Access Tokens
63
+ Note that certain request options (such as `json`, and certain `headers` names cannot be overriden).
51
64
 
52
- ```node
53
- var client = new Intercom.Client({ token: 'my_token' });
65
+ ### Setting the API version
66
+
67
+ We version our API (see the "Choose Version" section of the [API & Webhooks Reference](https://developers.intercom.com/intercom-api-reference/reference) for details). You can specify which version of the API to use when performing API requests using request options:
68
+
69
+ ```typescript
70
+ const client = new Client({ tokenAuth: { token: 'my_token' } });
71
+ client.useRequestOpts({
72
+ headers: {
73
+ 'Intercom-Version': 2.4,
74
+ },
75
+ });
54
76
  ```
55
77
 
56
- ## Callbacks
78
+ ## Examples
57
79
 
58
- This client library supports two kinds of callbacks:
80
+ ### Admins
59
81
 
60
- ```node
61
- client.users.list(function (d) {
62
- // d is the response from the server
82
+ #### [Retrieve admin](https://developers.intercom.com/intercom-api-reference/reference/view-an-admin)
83
+
84
+ ```typescript
85
+ const admin = await client.admins.find({ id: '123' });
86
+ ```
87
+
88
+ #### [Set Admin away](https://developers.intercom.com/intercom-api-reference/reference/set-admin-away-mode)
89
+
90
+ ```typescript
91
+ await client.admins.away({
92
+ adminId: '123',
93
+ enableAwayMode: true,
94
+ enableReassignMode: false,
63
95
  });
96
+ ```
64
97
 
65
- // Or
98
+ #### [List all activity logs](https://developers.intercom.com/intercom-api-reference/reference/view-admin-activity-logs)
66
99
 
67
- client.users.list(function (err, d) {
68
- // err is an error response object, or null
69
- // d is a successful response object, or null
100
+ ```typescript
101
+ await client.admins.listAllActivityLogs({
102
+ before: new Date('Fri, 17 Dec 2021 18:02:18 GMT');,
103
+ after: new Date('Fri, 17 Dec 2021 18:02:18 GMT');,
70
104
  });
71
105
  ```
72
106
 
73
- ## Promises
107
+ #### [List all admins](https://developers.intercom.com/intercom-api-reference/reference/list-admins)
74
108
 
75
- This client library also supports using Promises instead of callbacks:
109
+ ```typescript
110
+ const admins = await client.admins.list();
111
+ ```
76
112
 
77
- ```node
78
- client.users.create({ email: 'foo@bar.com' }).then(function (r) {
79
- // ...
113
+ ### Articles
114
+
115
+ #### [Create an article](https://developers.intercom.com/intercom-api-reference/reference/create-an-article)
116
+
117
+ ```typescript
118
+ const article = await client.articles.create({
119
+ title: 'Thanks for everything',
120
+ description: 'English description',
121
+ body: '<p>This is the body in html</p>',
122
+ authorId: 1,
123
+ state: 'published',
124
+ parentId: 1,
125
+ parentType: 'collection',
126
+ translatedContent: {
127
+ fr: {
128
+ title: 'Allez les verts',
129
+ description: 'French description',
130
+ body: '<p>French body in html</p>',
131
+ author_id: 1,
132
+ state: 'published',
133
+ },
134
+ },
80
135
  });
81
136
  ```
82
137
 
83
- ## Request Options
138
+ #### [Retrieve an article](https://developers.intercom.com/intercom-api-reference/reference/retrieve-an-article)
139
+
140
+ ```typescript
141
+ const response = await client.articles.find({ id: '123' });
142
+ ```
143
+
144
+ #### [Update an article](https://developers.intercom.com/intercom-api-reference/reference/update-an-article)
145
+
146
+ ```typescript
147
+ const article = await client.articles.update({
148
+ id: '123',
149
+ title: 'Thanks for everything',
150
+ description: 'English description',
151
+ body: '<p>This is the body in html</p>',
152
+ authorId: 1,
153
+ state: 'published',
154
+ parentId: 1,
155
+ parentType: 'collection',
156
+ translatedContent: {
157
+ fr: {
158
+ title: 'Allez les verts',
159
+ description: 'French description',
160
+ body: '<p>French body in html</p>',
161
+ author_id: 1,
162
+ state: 'published',
163
+ },
164
+ },
165
+ });
166
+ ```
84
167
 
85
- This client library also supports passing in [`request` options](https://github.com/request/request#requestoptions-callback):
168
+ #### [Delete an article](https://developers.intercom.com/intercom-api-reference/reference/delete-an-article)
86
169
 
87
- ```node
88
- var client = new Intercom.Client({ token: 'my_token' });
89
- client.useRequestOpts({
90
- baseUrl: 'http://local.test-server.com',
91
- // Uses the forever-agent / http(s).Agent({keepAlive:true})
92
- forever: true
170
+ ```typescript
171
+ await client.articles.delete({ id: '123' });
172
+ ```
173
+
174
+ #### [List all articles](https://developers.intercom.com/intercom-api-reference/reference/list-all-articles)
175
+
176
+ ```typescript
177
+ const response = await client.articles.list({
178
+ page: 3,
179
+ perPage: 12,
93
180
  });
94
181
  ```
95
182
 
96
- Note that certain request options (such as `json`, and certain `headers` names cannot be overriden).
183
+ ### Companies
97
184
 
185
+ #### [Create a company](https://developers.intercom.com/intercom-api-reference/reference/create-or-update-company)
98
186
 
99
- ## Users
187
+ ```typescript
188
+ const company = await client.companies.create({
189
+ createdAt: dateToUnixTimestamp(new Date()),
190
+ companyId: '46029',
191
+ name: 'BestCompanyInc.',
192
+ monthlySpend: 9001,
193
+ plan: '1. Get pizzaid',
194
+ size: 62049,
195
+ website: 'http://the-best.one',
196
+ industry: 'The Best One',
197
+ customAttributes: {},
198
+ });
199
+ ```
100
200
 
101
- ```node
102
- // Create a user
103
- client.users.create({
104
- email: 'jayne@serenity.io',
105
- custom_attributes: {
106
- foo: 'bar'
107
- }
108
- }, callback);
109
-
110
- // Update a user
111
- client.users.update({
112
- email: 'jayne@serenity.io',
113
- custom_attributes: {
114
- foo: 'bar'
115
- }
116
- }, callback);
201
+ #### [Update a company](https://developers.intercom.com/intercom-api-reference/reference/update-a-company)
202
+
203
+ ```typescript
204
+ const company = await client.companies.create({
205
+ createdAt: dateToUnixTimestamp(new Date()),
206
+ companyId: '46029',
207
+ name: 'BestCompanyInc.',
208
+ monthlySpend: 9001,
209
+ plan: '1. Get pizzaid',
210
+ size: 62049,
211
+ website: 'http://the-best.one',
212
+ industry: 'The Best One',
213
+ customAttributes: {},
214
+ });
117
215
  ```
118
216
 
119
- ```node
120
- // Create/update a user with custom attributes
121
- client.users.create({ email: 'jayne@serenity.io', custom_attributes: { invited_friend: true } }, callback);
217
+ #### [Retrieve a company](https://developers.intercom.com/intercom-api-reference/reference/view-a-company)
218
+
219
+ ##### By id
220
+
221
+ ```typescript
222
+ const company = await client.companies.find({
223
+ companyId: 123,
224
+ });
122
225
  ```
123
226
 
124
- ```node
125
- // List users
126
- client.users.list(callback);
227
+ ##### By name
228
+
229
+ ```typescript
230
+ const company = await client.companies.find({
231
+ name: 'bruh moment inc.',
232
+ });
127
233
  ```
128
234
 
129
- ```node
130
- // List users by tag or segment
131
- client.users.listBy({ tag_id: 'haven' }, callback);
235
+ #### [Delete a company](https://developers.intercom.com/intercom-api-reference/reference/delete-a-company)
236
+
237
+ ```typescript
238
+ const company = await client.companies.delete({
239
+ id: 62049,
240
+ });
132
241
  ```
133
242
 
134
- ```node
135
- // Scroll through users list
136
- client.users.scroll.each({}, function(res) {
137
- // if you return a promise from your callback, the client will only scroll
138
- // after this promise has resolved
139
- new Bluebird((resolve) => {
140
- setTimeout(() => {
141
- console.log(res.body.users.length);
142
- // Your custom logic
143
- resolve();
144
- }, 500)
145
- })
243
+ #### [List all companies](https://developers.intercom.com/intercom-api-reference/reference/list-companies)
244
+
245
+ ##### With pagination
246
+
247
+ ```typescript
248
+ const companies = await client.companies.list({
249
+ page: 1,
250
+ perPage: 35,
251
+ order: Order.DESC,
146
252
  });
253
+ ```
147
254
 
255
+ ##### With TagId and SegmentId
256
+
257
+ ```typescript
258
+ const companies = await client.companies.list({
259
+ tagId: '1234',
260
+ segmentId: '4567',
261
+ });
148
262
  ```
149
263
 
150
- ```node
151
- // Find user by id
152
- client.users.find({ id: '55b9eaf' }, callback);
264
+ #### [Scroll over companies](https://developers.intercom.com/intercom-api-reference/reference/iterating-over-all-companies)
153
265
 
154
- // Find user by user_id
155
- client.users.find({ user_id: 'foobar' }, callback);
266
+ ##### Using infinite scroll
156
267
 
157
- // Find user by email
158
- client.users.find({ email: 'jayne@serenity.io' }, callback);
268
+ ```typescript
269
+ const companies = await client.companies.scroll.each({});
159
270
  ```
160
271
 
161
- ```node
162
- // Archive user by id (https://developers.intercom.com/intercom-api-reference/reference#archive-a-user)
163
- client.users.archive({ id: '1234' }, callback);
272
+ ##### Using manual scroll
273
+
274
+ ```typescript
275
+ const companies = await client.companies.scroll.next({
276
+ scrollParam: '123_soleil',
277
+ });
164
278
  ```
165
279
 
166
- ```node
167
- // Permanently delete a user by id (https://developers.intercom.com/intercom-api-reference/reference#delete-users)
168
- const intercomUserId = '123'
169
- client.users.requestPermanentDeletion(intercomUserId, callback);
280
+ #### [Attach a contact](https://developers.intercom.com/intercom-api-reference/reference/attach-contact-to-company)
281
+
282
+ ```typescript
283
+ const response = await client.companies.attachContact({
284
+ contactId: '123',
285
+ companyId: '234',
286
+ });
170
287
  ```
171
288
 
172
- ```node
173
- // Permanently delete a user by id in params
174
- client.users.requestPermanentDeletionByParams({ id: '55b9eaf' }, callback);
289
+ #### [Detach a contact](https://developers.intercom.com/intercom-api-reference/reference/detach-contact-from-company)
290
+
291
+ ```typescript
292
+ const response = await client.companies.detachContact({
293
+ contactId: '123',
294
+ companyId: '234',
295
+ });
296
+ ```
175
297
 
176
- // Permanently delete a user by user_id
177
- client.users.requestPermanentDeletionByParams({ user_id: 'foobar' }, callback);
298
+ #### [List attached contacts](https://developers.intercom.com/intercom-api-reference/reference/list-company-contacts)
178
299
 
179
- // Permanently delete a user by email
180
- client.users.requestPermanentDeletionByParams({ email: 'jayne@serenity.io' }, callback);
300
+ ```typescript
301
+ const response = await client.companies.listAttachedContacts({
302
+ companyId: '123',
303
+ page: 1,
304
+ perPage: 15,
305
+ });
181
306
  ```
182
307
 
183
- ## Leads
308
+ #### [List attached segments](https://developers.intercom.com/intercom-api-reference/reference/list-attached-segments-1)
184
309
 
185
- ```node
186
- // Create a contact
187
- client.leads.create(function (r) {
188
- console.log(r);
310
+ ```typescript
311
+ const response = await client.companies.listAttachedSegments({
312
+ companyId: '123',
189
313
  });
314
+ ```
315
+
316
+ ### Contacts
317
+
318
+ #### [Create Contact](https://developers.intercom.com/intercom-api-reference/reference/create-contact)
319
+
320
+ ##### With User Role
190
321
 
191
- // Create a contact with attributes
192
- client.leads.create({ email: 'jayne@serenity.io' }, function (r) {
193
- console.log(r);
322
+ ```typescript
323
+ const user = await client.contacts.createUser({
324
+ externalId: '536e564f316c83104c000020',
325
+ phone: '+48370044567',
326
+ name: 'Niko Bellic',
327
+ avatar: 'https://nico-from-gta-iv.com/lets_go_bowling.jpg',
328
+ signedUpAt: 1638203719,
329
+ lastSeenAt: 1638203720,
330
+ ownerId: '536e564f316c83104c000021',
331
+ isUnsubscribedFromEmails: true,
194
332
  });
195
333
  ```
196
334
 
197
- ```node
198
- // Update a contact by id
199
- client.leads.update({ id: '5435345', email: 'wash@serenity.io' }, callback);
335
+ ##### With Lead Role
336
+
337
+ ```typescript
338
+ const lead = await client.contacts.createLead({
339
+ phone: '+48370044567',
340
+ name: 'Roman Bellic',
341
+ avatar: 'https://nico-from-gta-iv.com/lets_go_bowling_yey.jpg',
342
+ signedUpAt: 1638203719,
343
+ lastSeenAt: 1638203720,
344
+ ownerId: '536e564f316c83104c000021',
345
+ isUnsubscribedFromEmails: true,
346
+ });
200
347
  ```
201
348
 
202
- ```node
203
- // List contacts
204
- client.leads.list(callback);
349
+ #### [Retrieve a Contact](https://developers.intercom.com/intercom-api-reference/reference/get-contact)
350
+
351
+ ```typescript
352
+ const response = await client.contacts.find({ id: '123' });
205
353
  ```
206
354
 
207
- ```node
208
- // Scroll through contacts list
209
- client.leads.scroll.each({}, function(res) {
210
- // if you return a promise from your callback, the client will only scroll
211
- // after this promise has resolved
212
- new Bluebird((resolve) => {
213
- setTimeout(() => {
214
- console.log(res.body.contacts.length);
215
- // Your custom logic
216
- resolve();
217
- }, 500)
218
- })
355
+ #### [Update a Contact](https://developers.intercom.com/intercom-api-reference/reference/update-contact)
356
+
357
+ ```typescript
358
+ const response = await client.contacts.update({
359
+ id: '123',
360
+ role: Role.USER,
361
+ name: 'Roman The Bowling Fan',
362
+ customAttributes: {
363
+ callBrother: "Hey Niko, it's me – Roman. Let's go bowling!",
364
+ },
219
365
  });
220
366
  ```
221
367
 
222
- ```node
223
- // List contacts by email
224
- client.leads.listBy({ email: 'wash@serenity.io' }, callback);
368
+ #### [Delete a Contact](https://developers.intercom.com/intercom-api-reference/reference/delete-contact)
369
+
370
+ ```typescript
371
+ const response = await client.contacts.delete({ id: '123' });
225
372
  ```
226
373
 
374
+ #### [Archive a Contact](https://developers.intercom.com/intercom-api-reference/reference/archive-a-contact)
227
375
 
228
- ```node
229
- // Find contact by id
230
- client.leads.find({ id: '5342423' }, callback);
376
+ ```typescript
377
+ const response = await client.contacts.archive({ id: '123' });
231
378
  ```
232
379
 
233
- ```node
234
- // Delete contact by id
235
- client.leads.delete({ id: '5342423' }, callback);
380
+ #### [Unarchive a Contact](https://developers.intercom.com/intercom-api-reference/reference/unarchive-a-contact)
381
+
382
+ ```typescript
383
+ const response = await client.contacts.unarchive({ id: '123' });
236
384
  ```
237
385
 
238
- ```node
239
- // Convert Leads into Users
240
- var conversion = {
241
- contact: { user_id: '1234-5678-9876' },
242
- user: { email: 'mal@serenity.io' }
243
- };
244
- client.leads.convert(conversion, callback);
386
+ #### [Merge two Contacts](https://developers.intercom.com/intercom-api-reference/reference/merge-contact)
387
+
388
+ ```typescript
389
+ const response = await client.contacts.mergeLeadInUser({
390
+ leadId: '123',
391
+ userId: '234',
392
+ });
245
393
  ```
246
394
 
247
- ## Customers
395
+ #### [Search for contacts](https://developers.intercom.com/intercom-api-reference/reference/search-for-contacts)
396
+
397
+ ```typescript
398
+ const response = await client.contacts.search({
399
+ data: {
400
+ query: {
401
+ operator: Operators.AND,
402
+ value: [
403
+ {
404
+ operator: Operators.AND,
405
+ value: [
406
+ {
407
+ field: 'updated_at',
408
+ operator: Operators.GREATER_THAN,
409
+ value: 1560436650,
410
+ },
411
+ {
412
+ field: 'conversation_rating.rating',
413
+ operator: Operators.EQUALS,
414
+ value: 1,
415
+ },
416
+ ],
417
+ },
418
+ {
419
+ operator: Operators.OR,
420
+ value: [
421
+ {
422
+ field: 'updated_at',
423
+ operator: Operators.GREATER_THAN,
424
+ value: 1560436650,
425
+ },
426
+ {
427
+ field: 'conversation_rating.rating',
428
+ operator: Operators.EQUALS,
429
+ value: 2,
430
+ },
431
+ ],
432
+ },
433
+ ],
434
+ },
435
+ pagination: {
436
+ per_page: 5,
437
+ starting_after:
438
+ 'WzE2MzU4NjA2NDgwMDAsIjYxODJiNjJlNDM4YjdhM2EwMWE4YWYxNSIsMl0=',
439
+ },
440
+ sort: { field: 'name', order: SearchContactOrderBy.ASC },
441
+ },
442
+ });
443
+ ```
248
444
 
249
- ```node
250
- // Search for customers
251
- client.customers.search({
252
- query: { field: 'name', operator: '=', name: 'Alice'},
253
- sort: { field: 'name', order: 'ascending'},
254
- pagination: { per_page: 10 }
255
- }, callback);
445
+ #### [List all Contacts](https://developers.intercom.com/intercom-api-reference/reference/list-contacts)
446
+
447
+ ##### With cursor
448
+
449
+ ```typescript
450
+ const response = await client.contacts.list({
451
+ perPage: 5,
452
+ startingAfter:
453
+ 'WzE2MzU3NzU4NjkwMDAsIjYxODJiNjJhMDMwZTk4OTBkZWU4NGM5YiIsMl0=',
454
+ });
256
455
  ```
257
456
 
258
- ## Visitors
457
+ ##### Without a cursor
259
458
 
260
- ```node
261
- // Update a visitor by id
262
- client.visitors.update({ id: '5435345', email: 'wash@serenity.io' }, callback);
459
+ ```typescript
460
+ const response = await client.contacts.list();
263
461
  ```
264
462
 
265
- ```node
266
- // Find visitor by id or user_id
267
- client.visitors.find({ id: '5342423' }, callback);
268
- client.visitors.find({ user_id: '5b868511-ca3b-4eac-8d26-cfd82a83ac76' }, callback);
463
+ #### [List attached companies](https://developers.intercom.com/intercom-api-reference/reference/list-companies-of-contact)
464
+
465
+ ```typescript
466
+ const response = await client.contacts.listAttachedCompanies({
467
+ id: '123',
468
+ perPage: 5,
469
+ page: 1,
470
+ });
269
471
  ```
270
472
 
271
- ```node
272
- // Delete visitor by id
273
- client.visitors.delete({ id: '5342423' }, callback);
473
+ #### [List attached tags](https://developers.intercom.com/intercom-api-reference/reference/list-tags-of-contact)
474
+
475
+ ```typescript
476
+ const response = await client.contacts.listAttachedTags({ id: '123' });
274
477
  ```
275
478
 
276
- ```node
277
- // Convert visitors into Users
278
- var conversion = {
279
- visitor: { user_id: '1234-5678-9876' },
280
- user: { email: 'mal@serenity.io' },
281
- type: "user"
282
- };
283
- client.visitors.convert(conversion, callback);
479
+ #### [List attached segments](https://developers.intercom.com/intercom-api-reference/reference/list-attached-segments)
480
+
481
+ ```typescript
482
+ const response = await client.contacts.listAttachedSegments({ id: '123' });
284
483
  ```
285
484
 
286
- ```node
287
- // Convert visitors into Lead
288
- var conversion = {
289
- visitor: { user_id: '1234-5678-9876' },
290
- type: "lead"
291
- };
292
- client.visitors.convert(conversion, callback);
485
+ #### [List attached email subscriptions](https://developers.intercom.com/intercom-api-reference/reference/list-attached-email-subscriptions)
486
+
487
+ ```typescript
488
+ const response = await client.contacts.listAttachedEmailSubscriptions({
489
+ id: '123',
490
+ });
293
491
  ```
294
492
 
493
+ ### Conversations
295
494
 
296
- ## Companies
495
+ #### [Create a conversation](https://developers.intercom.com/intercom-api-reference/reference/create-a-conversation)
297
496
 
298
- ```node
299
- // Create/update a company
300
- client.companies.create({ company_id: '1234', name: 'serenity' }, function (r) {
301
- console.log(r);
497
+ ```typescript
498
+ const response = await client.conversations.create({
499
+ userId: '123',
500
+ body: 'Hello darkness my old friend',
302
501
  });
303
502
  ```
304
503
 
305
- ```node
306
- // List companies
307
- client.companies.list(callback);
504
+ #### [Retrieve a conversation](https://developers.intercom.com/intercom-api-reference/reference/retrieve-a-conversation)
505
+
506
+ ##### Formatted text
507
+
508
+ ```typescript
509
+ const response = await client.conversations.find({
510
+ id: '123',
511
+ });
308
512
  ```
309
513
 
310
- ```node
311
- // List companies by tag or segment
312
- client.companies.listBy({ tag_id: 'haven' }, callback);
514
+ ##### As plain text
515
+
516
+ ```typescript
517
+ const response = await client.conversations.find({
518
+ id: '123',
519
+ inPlainText: true,
520
+ });
313
521
  ```
314
522
 
315
- ```node
316
- // Scroll through companies list
317
- client.companies.scroll.each({}, function(res) {
318
- // if you return a promise from your callback, the client will only scroll
319
- // after this promise has resolved
320
- new Bluebird((resolve) => {
321
- setTimeout(() => {
322
- console.log(res.body.companies.length);
323
- // Your custom logic
324
- resolve();
325
- }, 500)
326
- })
523
+ #### [Update a conversation](https://developers.intercom.com/intercom-api-reference/reference/update-a-conversation)
524
+
525
+ ```typescript
526
+ const response = await client.conversations.update({
527
+ id,
528
+ markRead: true,
529
+ customAttributes: {
530
+ anything: 'you want',
531
+ },
327
532
  });
328
533
  ```
329
534
 
535
+ #### [Reply to a conversation](https://developers.intercom.com/intercom-api-reference/reference/reply-to-a-conversation)
330
536
 
331
- ```node
332
- // Find company by id
333
- client.companies.find({ id: '1234' }, callback);
537
+ ##### By id
538
+
539
+ ###### As user
540
+
541
+ ```typescript
542
+ const response = await client.conversations.replyByIdAsUser({
543
+ id: '098',
544
+ body: 'blablbalba',
545
+ intercomUserId: '123',
546
+ attachmentUrls: '345',
547
+ });
334
548
  ```
335
549
 
336
- ```node
337
- // List company users by id or company_id
338
- client.companies.listUsers({ id: '1234' }, callback);
339
- client.companies.listUsers({ company_id: '1234' }, callback);
550
+ ###### As admin
551
+
552
+ ```typescript
553
+ const response = await client.conversations.replyByIdAsAdmin({
554
+ id: '098',
555
+ adminId: '458',
556
+ messageType: ReplyToConversationMessageType.NOTE,
557
+ body: '<b>Bee C</b>',
558
+ attachmentUrls: ['https://site.org/bebra.jpg'],
559
+ });
340
560
  ```
341
561
 
562
+ ##### By last conversation
342
563
 
343
- ## Events
564
+ ###### As user
344
565
 
345
- Note: events will work when identified by 'email'. The `event_name` and `created_at` params are both required. Either `user_id` OR `email` is required.
566
+ ```typescript
567
+ const response = await client.conversations.replyByLastAsUser({
568
+ body: 'blablbalba',
569
+ intercomUserId: '123',
570
+ attachmentUrls: '345',
571
+ });
572
+ ```
346
573
 
347
- ```node
348
- // Create a event
349
- client.events.create({
350
- event_name: 'Foo',
351
- created_at: 1439826340,
352
- user_id: 'bar',
353
- metadata: { type: 'baz' }
354
- }, function (d) {
355
- console.log(d);
574
+ ###### As admin
575
+
576
+ ```typescript
577
+ const response = await client.conversations.replyByLastAsAdmin({
578
+ adminId: '458',
579
+ messageType: ReplyToConversationMessageType.NOTE,
580
+ body: '<b>Bee C</b>',
581
+ attachmentUrls: ['https://site.org/bebra.jpg'],
356
582
  });
357
583
  ```
358
584
 
359
- ```node
360
- // List events by user
361
- client.events.listBy({
362
- type: 'user',
363
- user_id: 'bar'
364
- }, callback);
585
+ #### [Assign a conversation](https://developers.intercom.com/intercom-api-reference/reference/assign-a-conversation)
586
+
587
+ ##### As team without assignment rules
588
+
589
+ ```typescript
590
+ const response = await client.conversations.assign({
591
+ id: '123',
592
+ type: AssignToConversationUserType.TEAM,
593
+ adminId: '456',
594
+ assigneeId: '789',
595
+ body: '<b>blablbalba</b>',
596
+ });
365
597
  ```
366
598
 
367
- ## Counts
599
+ ##### As team with assignment rules
368
600
 
369
- ```node
370
- client.counts.appCounts(callback);
601
+ ```typescript
602
+ const response = await client.conversations.assign({
603
+ id: '123',
604
+ withRunningAssignmentRules: true,
605
+ });
606
+ ```
371
607
 
372
- client.counts.conversationCounts(callback);
608
+ #### [Snooze a conversation](https://developers.intercom.com/intercom-api-reference/reference/snooze-a-conversation)
373
609
 
374
- client.counts.conversationAdminCounts(callback);
610
+ ```typescript
611
+ const response = await client.conversations.snooze({
612
+ id: '123',
613
+ adminId: '234',
614
+ snoozedUntil: '1501512795',
615
+ });
616
+ ```
617
+
618
+ #### [Close a conversation](https://developers.intercom.com/intercom-api-reference/reference/close-a-conversation)
619
+
620
+ ```typescript
621
+ const response = await client.conversations.close({
622
+ id: '123',
623
+ adminId: '456',
624
+ body: "That's it...",
625
+ });
626
+ ```
375
627
 
376
- client.counts.userTagCounts(callback);
628
+ #### [Open a conversation](https://developers.intercom.com/intercom-api-reference/reference/open-a-conversation)
377
629
 
378
- client.counts.userSegmentCounts(callback);
630
+ ```typescript
631
+ const response = await client.conversations.open({
632
+ id: '123',
633
+ adminId: '234',
634
+ });
635
+ ```
379
636
 
380
- client.counts.companyTagCounts(callback);
637
+ #### [Attach a contact to group conversation](https://developers.intercom.com/intercom-api-reference/reference/adding-to-group-conversations-as-admin)
381
638
 
382
- client.counts.companySegmentCounts(callback);
639
+ ##### As admin, using intercomUserid
383
640
 
384
- client.counts.companyUserCounts(callback);
641
+ ```typescript
642
+ const response = await client.conversations.attachContactAsAdmin({
643
+ id: '123',
644
+ adminId: '234',
645
+ customer: {
646
+ intercomUserId: '456',
647
+ },
648
+ });
385
649
  ```
386
650
 
387
- ## Admins
651
+ ##### As contact, using intercomUserid
388
652
 
389
- ```node
390
- // List admins
391
- client.admins.list(callback);
653
+ ```typescript
654
+ const response = await client.conversations.attachContactAsAdmin({
655
+ id: '123',
656
+ userId: '234',
657
+ customer: {
658
+ intercomUserId: '456',
659
+ },
660
+ });
392
661
  ```
393
662
 
394
- ```node
395
- // Find current admin (only works with OAuth tokens)
396
- client.admins.me(callback);
663
+ #### [Delete a contact from group conversation as admin](https://developers.intercom.com/intercom-api-reference/reference/deleting-from-group-conversations)
664
+
665
+ ```typescript
666
+ const response = await client.conversations.detachContactAsAdmin({
667
+ conversationId: '123',
668
+ contactId: '456',
669
+ adminId: '789',
670
+ });
397
671
  ```
398
672
 
673
+ #### [Search for conversations](https://developers.intercom.com/intercom-api-reference/reference/search-for-conversations)
674
+
675
+ ```typescript
676
+ const response = await client.conversations.search({
677
+ data: {
678
+ query: {
679
+ operator: Operators.AND,
680
+ value: [
681
+ {
682
+ operator: Operators.AND,
683
+ value: [
684
+ {
685
+ field: 'updated_at',
686
+ operator: Operators.GREATER_THAN,
687
+ value: 1560436650,
688
+ },
689
+ {
690
+ field: 'conversation_rating.rating',
691
+ operator: Operators.EQUALS,
692
+ value: 1,
693
+ },
694
+ ],
695
+ },
696
+ {
697
+ operator: Operators.OR,
698
+ value: [
699
+ {
700
+ field: 'updated_at',
701
+ operator: Operators.GREATER_THAN,
702
+ value: 1560436650,
703
+ },
704
+ {
705
+ field: 'conversation_rating.rating',
706
+ operator: Operators.EQUALS,
707
+ value: 2,
708
+ },
709
+ ],
710
+ },
711
+ ],
712
+ },
713
+ pagination: {
714
+ per_page: 5,
715
+ starting_after:
716
+ 'WzE2MzU4NjA2NDgwMDAsIjYxODJiNjJlNDM4YjdhM2EwMWE4YWYxNSIsMl0=',
717
+ },
718
+ sort: {
719
+ field: 'name',
720
+ order: SearchConversationOrderBy.DESC,
721
+ },
722
+ },
723
+ });
399
724
  ```
400
- // Find admin by ID
401
- client.admins.find('123456789', callback);
725
+
726
+ #### [List all conversations](https://developers.intercom.com/intercom-api-reference/reference/list-conversations)
727
+
728
+ ```typescript
729
+ const response = await client.conversations.list({
730
+ query: {
731
+ order: Order.DESC,
732
+ sort: SortBy.UpdatedAt,
733
+ page: 1,
734
+ perPage: 10,
735
+ },
736
+ });
402
737
  ```
403
738
 
404
- ## Tags
739
+ #### [Redact a conversation](https://developers.intercom.com/intercom-api-reference/reference/redact-a-conversation-part)
405
740
 
406
- ```node
407
- // Create a tag
408
- client.tags.create({ name: 'haven' }, callback);
741
+ ```typescript
742
+ const response = await client.conversations.redactConversationPart({
743
+ type: RedactConversationPartType.CONVERSATION_PART,
744
+ conversationId: '123',
745
+ conversationPartId: '456',
746
+ });
409
747
  ```
410
748
 
411
- ```node
412
- // Tag a user by id
413
- client.tags.tag({ name: 'haven', users: [{ id: '54645654' }] }, callback);
749
+ ### Data Attributes
750
+
751
+ #### [Create Data Attribute](https://developers.intercom.com/intercom-api-reference/reference/create-data-attributes)
752
+
753
+ ```typescript
754
+ const response = await client.dataAttributes.create({
755
+ name: 'list_cda',
756
+ model: ModelType.CONTACT,
757
+ dataType: DataType.STRING,
758
+ description: 'You are either alive or dead',
759
+ options: [{ value: 'alive' }, { value: 'dead' }],
760
+ });
414
761
  ```
415
762
 
416
- ```node
417
- // Tag a company by id
418
- client.tags.tag({ name: 'haven', companies: [{ id: '54645654' }] }, callback);
763
+ #### [Update Data Attribute](https://developers.intercom.com/intercom-api-reference/reference/update-data-attributes)
764
+
765
+ ```typescript
766
+ const response = await client.dataAttributes.update({
767
+ id: '123',
768
+ description: 'You are either alive or dead',
769
+ options: [{ value: 'alive' }, { value: 'dead' }],
770
+ archived: true,
771
+ });
419
772
  ```
420
773
 
421
- ```node
422
- // Untag a user by id
423
- client.tags.untag({ name: 'haven', users: [{ id: '5345342' }] }, callback);
774
+ #### [List all Data Attributes](https://developers.intercom.com/intercom-api-reference/reference/list-data-attributes)
775
+
776
+ ```typescript
777
+ const response = await client.dataAttributes.list({
778
+ model: ModelType.CONTACT,
779
+ includeArchived: true,
780
+ });
424
781
  ```
425
782
 
426
- ```node
427
- // List tags
428
- client.tags.list(callback);
783
+ ### Events
784
+
785
+ #### [Submit a data event](https://developers.intercom.com/intercom-api-reference/reference/list-data-attributes)
786
+
787
+ ```typescript
788
+ const response = await client.events.create({
789
+ eventName: 'placed-order',
790
+ createdAt: 1389913941,
791
+ userId: 'f4ca124298',
792
+ metadata: {
793
+ order_date: 1392036272,
794
+ stripe_invoice: 'inv_3434343434',
795
+ order_number: {
796
+ value: '3434-3434',
797
+ url: 'https://example.org/orders/3434-3434',
798
+ },
799
+ price: {
800
+ currency: 'usd',
801
+ amount: 2999,
802
+ },
803
+ },
804
+ });
429
805
  ```
430
806
 
431
- ```node
432
- // Delete a tag by id
433
- client.tags.delete({ id: '130963' }, callback);
807
+ #### [List all data events](https://developers.intercom.com/intercom-api-reference/reference/list-user-events)
808
+
809
+ ```typescript
810
+ const response = await client.events.listBy({
811
+ userId: '1234',
812
+ perPage: 2,
813
+ summary: true,
814
+ email: 'i_love_memes@gmail.com',
815
+ });
434
816
  ```
435
817
 
436
- ## Segments
818
+ ### Help Center - Collections
437
819
 
438
- ```node
439
- // List segments
440
- client.segments.list(callback);
820
+ #### [Create a collection](https://developers.intercom.com/intercom-api-reference/reference/create-a-collection)
821
+
822
+ ```typescript
823
+ const collection = await client.helpCenter.collections.create({
824
+ name: 'Thanks for everything',
825
+ description: 'English description',
826
+ translatedContent: {
827
+ fr: {
828
+ name: 'Allez les verts',
829
+ description: 'French description',
830
+ },
831
+ },
832
+ });
441
833
  ```
442
834
 
443
- ```node
444
- // Find segment by id
445
- client.segments.find({ id: '55719a4a' }, callback);
835
+ #### [Retrieve a collection](https://developers.intercom.com/intercom-api-reference/reference/retrieve-a-collection)
836
+
837
+ ```typescript
838
+ const response = await client.helpCenter.collections.find({ id: '123' });
446
839
  ```
447
840
 
448
- ## Messages
841
+ #### [Update a collection](https://developers.intercom.com/intercom-api-reference/reference/update-a-collection)
449
842
 
450
- ```node
451
- // Admin initiated messages:
452
- // Sending an email to a User
453
- var message = {
454
- message_type: "email",
455
- subject: "Hey",
456
- body: "Ponies, cute small horses or something more sinister?",
457
- template: "plain",
458
- from: {
459
- type: "admin",
460
- id: "21599"
461
- },
462
- to: {
463
- type: "user",
464
- id: "55c1ce1def857c31f80001af"
465
- }
466
- }
467
-
468
- client.messages.create(message, callback);
843
+ ```typescript
844
+ const article = await client.helpCenter.collections.update({
845
+ id: '123',
846
+ name: 'Thanks for everything',
847
+ description: 'English description',
848
+ translated_content: {
849
+ fr: {
850
+ name: 'Allez les verts',
851
+ description: 'French description',
852
+ },
853
+ },
854
+ });
469
855
  ```
470
856
 
471
- ```node
472
- // Creating a user-initiated message:
473
- var message = {
474
- from: {
475
- type: "user",
476
- id: "55c1ce1def857c31f80001af"
477
- },
478
- body: "Howdy"
479
- }
857
+ #### [Delete a collection](https://developers.intercom.com/intercom-api-reference/reference/delete-a-collection)
858
+
859
+ ```typescript
860
+ await client.helpCenter.collections.delete({
861
+ id: '123',
862
+ });
863
+ ```
480
864
 
481
- client.messages.create(message, callback);
865
+ #### [List all collections](https://developers.intercom.com/intercom-api-reference/reference/list-all-collections)
866
+
867
+ ```typescript
868
+ const response = client.helpCenter.collections.list({
869
+ page: 3,
870
+ perPage: 12,
871
+ });
482
872
  ```
483
873
 
484
- ## Conversations
874
+ ## Help Center - Sections
485
875
 
486
- Listing conversations ([documentation](https://developers.intercom.com/intercom-api-reference/reference#list-conversations)):
876
+ #### [Create a section](https://developers.intercom.com/intercom-api-reference/reference/create-a-section)
487
877
 
488
- ```node
489
- client.conversations.list({ type: 'admin', admin_id: 21599 }, callback);
878
+ ```typescript
879
+ const collection = await client.helpCenter.sections.create({
880
+ name: 'Thanks for everything',
881
+ parent_id: '1234',
882
+ translatedContent: {
883
+ fr: {
884
+ name: 'Allez les verts',
885
+ description: 'French description',
886
+ },
887
+ },
888
+ });
490
889
  ```
491
890
 
891
+ #### [Retrieve a section](https://developers.intercom.com/intercom-api-reference/reference/retrieve-a-section)
492
892
 
493
- ```node
494
- // Fetch a conversation
495
- client.conversations.find({ id: '1062682196' }, callback);
893
+ ```typescript
894
+ const response = await client.helpCenter.sections.find({ id: '123' });
496
895
  ```
497
896
 
498
- ```node
499
- // Reply to a conversation
500
- var reply = {
501
- id: '1039067180',
502
- intercom_user_id: '55b26822ce97179e52001334',
503
- body: 'Some reply :)',
504
- type: 'user',
505
- message_type: 'comment'
506
- };
507
-
508
- client.conversations.reply(reply, callback);
509
-
510
- // Reply to a conversation with attachments
511
- var reply = {
512
- id: '1039067180',
513
- intercom_user_id: '55b26822ce97179e52001334',
514
- body: 'Some reply :)',
515
- type: 'user',
516
- message_type: 'comment',
517
- attachment_urls: ['http://www.example.com/myattachment.jpg']
518
- };
519
-
520
- client.conversations.reply(reply, callback);
897
+ #### [Update a section](https://developers.intercom.com/intercom-api-reference/reference/update-a-section)
898
+
899
+ ```typescript
900
+ const article = await client.helpCenter.sections.update({
901
+ id: '123',
902
+ name: 'Thanks for everything',
903
+ parent_id: '456',
904
+ translated_content: {
905
+ fr: {
906
+ name: 'Allez les verts',
907
+ description: 'French description',
908
+ },
909
+ },
910
+ });
521
911
  ```
522
912
 
523
- ```node
524
- // Assign a conversation to an admin
525
- var assignment = {
526
- id: '13879167940',
527
- type: 'admin',
528
- admin_id: '1309092',
529
- assignee_id: '1723471',
530
- message_type: 'assignment'
531
- };
913
+ #### [Delete a section](https://developers.intercom.com/intercom-api-reference/reference/delete-a-section)
532
914
 
533
- client.conversations.reply(assignment, callback);
915
+ ```typescript
916
+ await client.helpCenter.sections.delete({
917
+ id: '123',
918
+ });
919
+ ```
534
920
 
535
- // Assign a conversation to unassigned
536
- var assignment = {
537
- id: '13879167940',
538
- type: 'admin',
539
- admin_id: '1309092',
540
- assignee_id: '0',
541
- message_type: 'assignment'
542
- }
921
+ #### [List all sections](https://developers.intercom.com/intercom-api-reference/reference/list-all-sections)
543
922
 
544
- client.conversations.reply(assignment, callback);
923
+ ```typescript
924
+ const response = client.helpCenter.sections.list({
925
+ page: 3,
926
+ perPage: 12,
927
+ });
545
928
  ```
546
929
 
547
- ```node
548
- // Mark a conversation as read
549
- client.conversations.markAsRead({ id: '1039067180' }, callback);
930
+ ### Messages
931
+
932
+ #### [Create a message](https://developers.intercom.com/intercom-api-reference/reference/admin-initiated-conversation)
933
+
934
+ ```typescript
935
+ const response = await client.messages.create({
936
+ messageType: 'email',
937
+ subject: 'This is our demand now',
938
+ body: 'Destroy ponies',
939
+ template: 'plain',
940
+ from: {
941
+ type: 'admin',
942
+ id: '394051',
943
+ },
944
+ to: {
945
+ type: 'user',
946
+ id: '536e564f316c83104c000020',
947
+ },
948
+ });
550
949
  ```
551
950
 
552
- ## Notes
951
+ ### Segments
553
952
 
554
- ```node
555
- // Create a note
556
- var note = {
557
- admin_id: 21599,
558
- body: 'Hello notes!',
559
- user: {
560
- id: '55b26822ce97179e52001334'
561
- }
562
- };
953
+ #### [Retrieve a segment](https://developers.intercom.com/intercom-api-reference/reference/view-a-segment)
563
954
 
564
- client.notes.create(note, callback);
955
+ ```typescript
956
+ const response = await client.segments.find({
957
+ id: '123',
958
+ includeCount: true,
959
+ });
565
960
  ```
566
961
 
567
- ```node
568
- // List notes by user
569
- client.notes.list({ email: 'bob@intercom.io' }, callback);
962
+ #### [List all segments](https://developers.intercom.com/intercom-api-reference/reference/list-segments)
963
+
964
+ ```typescript
965
+ const response = await client.segments.list({
966
+ includeCount: true,
967
+ });
570
968
  ```
571
969
 
572
- ```node
573
- //Fetch a note
574
- client.notes.find({ id: '3342887' }, callback);
970
+ ### Tags
971
+
972
+ #### [Create or update a tag](https://developers.intercom.com/intercom-api-reference/reference/create-and-update-tags)
973
+
974
+ ##### Create
975
+
976
+ ```typescript
977
+ const response = await client.tags.create({ name: 'haven' });
575
978
  ```
576
979
 
577
- ## Pagination
980
+ ##### Update
578
981
 
579
- When listing, the Intercom API may return a pagination object:
982
+ ```typescript
983
+ const response = await client.tags.update({ id: '123', name: 'haven' });
984
+ ```
580
985
 
581
- ```json
582
- {
583
- "pages": {
584
- "next": "..."
585
- }
586
- }
986
+ #### [Delete a tag](https://developers.intercom.com/intercom-api-reference/reference/delete-a-tag)
987
+
988
+ ```typescript
989
+ const response = await client.tags.delete({ id: 'baz' });
587
990
  ```
588
991
 
589
- You can grab the next page of results using the client:
992
+ #### [Attach a contact](https://developers.intercom.com/intercom-api-reference/reference/tag-contact)
590
993
 
591
- ```node
592
- client.nextPage(response.pages, callback);
994
+ ```typescript
995
+ const response = await client.tags.tagContact({
996
+ contactId: '123',
997
+ tagId: '234',
998
+ });
999
+ ```
1000
+
1001
+ #### [Attach a conversation](https://developers.intercom.com/intercom-api-reference/reference/attach-a-tag-to-a-conversation)
1002
+
1003
+ ```typescript
1004
+ const response = await client.tags.tagConversation({
1005
+ conversationId: '123',
1006
+ tagId: '456',
1007
+ adminId: '789',
1008
+ });
593
1009
  ```
594
1010
 
595
- ## Identity verification
1011
+ #### [Tag companies](https://developers.intercom.com/intercom-api-reference/reference/tag-companies)
1012
+
1013
+ ```typescript
1014
+ const response = await client.tags.tagCompanies({
1015
+ tagName: 'gutenTag',
1016
+ companiesIds: ['123', '234', '456'],
1017
+ });
1018
+ ```
1019
+
1020
+ #### [Untag companies](https://developers.intercom.com/intercom-api-reference/reference/untag-companies)
1021
+
1022
+ ```typescript
1023
+ const response = await client.tags.tagCompanies({
1024
+ tagName: 'gutenTag',
1025
+ companiesIds: ['123', '234', '456'],
1026
+ });
1027
+ ```
1028
+
1029
+ #### [Untag conversation](https://developers.intercom.com/intercom-api-reference/reference/detach-a-tag-from-a-conversation)
1030
+
1031
+ ```typescript
1032
+ const response = await client.tags.untagConversation({
1033
+ conversationId: '123',
1034
+ tagId: '345',
1035
+ adminId: '678',
1036
+ });
1037
+ ```
1038
+
1039
+ #### [Untag contact](https://developers.intercom.com/intercom-api-reference/reference/untag-contact)
1040
+
1041
+ ```typescript
1042
+ const response = await client.tags.untagContact({
1043
+ contactId: '123',
1044
+ tagId: '345',
1045
+ });
1046
+ ```
1047
+
1048
+ #### [List all tags](https://developers.intercom.com/intercom-api-reference/reference/list-tags-for-an-app)
1049
+
1050
+ ```typescript
1051
+ const response = await client.tags.list();
1052
+ ```
1053
+
1054
+ ### Teams
1055
+
1056
+ #### [Retrieve a team](https://developers.intercom.com/intercom-api-reference/reference/view-a-team)
1057
+
1058
+ ```typescript
1059
+ const response = await client.teams.find({
1060
+ id: '123',
1061
+ });
1062
+ ```
1063
+
1064
+ #### [List all teams](https://developers.intercom.com/intercom-api-reference/reference/list-teams)
1065
+
1066
+ ```typescript
1067
+ const response = await client.teams.list();
1068
+ ```
1069
+
1070
+ ### Identity verification
596
1071
 
597
1072
  `intercom-node` provides a helper for using [identity verification](https://docs.intercom.com/configure-intercom-for-your-product-or-site/staying-secure/enable-identity-verification-on-your-web-product):
598
1073
 
599
- ``` node
1074
+ ```node
600
1075
  import { IdentityVerification } from 'intercom-client';
601
1076
 
602
- IdentityVerification.userHash({secretKey: 's3cre7', identifier: 'jayne@serenity.io'});
1077
+ IdentityVerification.userHash({
1078
+ secretKey: 's3cre7',
1079
+ identifier: 'jayne@serenity.io',
1080
+ });
603
1081
  ```
604
1082
 
605
1083
  ## License
606
1084
 
607
1085
  Apache-2.0
608
1086
 
609
-
610
1087
  ## Pull Requests
611
1088
 
612
- - **Add tests!** Your patch won't be accepted if it doesn't have tests.
1089
+ - **Add tests!** Your patch won't be accepted if it doesn't have tests.
613
1090
 
614
- - **Document any change in behaviour**. Make sure the README and any other
615
- relevant documentation are kept up-to-date.
1091
+ - **Document any change in behaviour**. Make sure the README and any other
1092
+ relevant documentation are kept up-to-date.
616
1093
 
617
- - **Create topic branches**. Don't ask us to pull from your master branch.
1094
+ - **Create topic branches**. Don't ask us to pull from your master branch.
618
1095
 
619
- - **One pull request per feature**. If you want to do more than one thing, send
620
- multiple pull requests.
1096
+ - **One pull request per feature**. If you want to do more than one thing, send
1097
+ multiple pull requests.
621
1098
 
622
- - **Send coherent history**. Make sure each individual commit in your pull
623
- request is meaningful. If you had to make multiple intermediate commits while
624
- developing, please squash them before sending them to us.
1099
+ - **Send coherent history**. Make sure each individual commit in your pull
1100
+ request is meaningful. If you had to make multiple intermediate commits while
1101
+ developing, please squash them before sending them to us.