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.
- package/README.md +873 -396
- package/dist/admin/admin.types.d.ts +13 -0
- package/dist/admin/admin.types.d.ts.map +1 -0
- package/dist/admin/admin.types.js +3 -0
- package/dist/admin/admin.types.js.map +1 -0
- package/dist/admin.d.ts +48 -0
- package/dist/admin.d.ts.map +1 -0
- package/dist/admin.js +40 -41
- package/dist/admin.js.map +1 -0
- package/dist/client.d.ts +67 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +230 -239
- package/dist/client.js.map +1 -0
- package/dist/common/common.types.d.ts +91 -0
- package/dist/common/common.types.d.ts.map +1 -0
- package/dist/common/common.types.js +29 -0
- package/dist/common/common.types.js.map +1 -0
- package/dist/company/company.types.d.ts +37 -0
- package/dist/company/company.types.d.ts.map +1 -0
- package/dist/company/company.types.js +3 -0
- package/dist/company/company.types.js.map +1 -0
- package/dist/company.d.ts +67 -0
- package/dist/company.d.ts.map +1 -0
- package/dist/company.js +110 -83
- package/dist/company.js.map +1 -0
- package/dist/contact/contact.types.d.ts +80 -0
- package/dist/contact/contact.types.d.ts.map +1 -0
- package/dist/contact/contact.types.js +3 -0
- package/dist/contact/contact.types.js.map +1 -0
- package/dist/contact.d.ts +130 -0
- package/dist/contact.d.ts.map +1 -0
- package/dist/contact.js +155 -81
- package/dist/contact.js.map +1 -0
- package/dist/conversation/conversation.types.d.ts +144 -0
- package/dist/conversation/conversation.types.d.ts.map +1 -0
- package/dist/conversation/conversation.types.js +50 -0
- package/dist/conversation/conversation.types.js.map +1 -0
- package/dist/conversation.d.ts +176 -0
- package/dist/conversation.d.ts.map +1 -0
- package/dist/conversation.js +287 -48
- package/dist/conversation.js.map +1 -0
- package/dist/dataAttribute/dataAttribute.types.d.ts +32 -0
- package/dist/dataAttribute/dataAttribute.types.d.ts.map +1 -0
- package/dist/dataAttribute/dataAttribute.types.js +18 -0
- package/dist/dataAttribute/dataAttribute.types.js.map +1 -0
- package/dist/dataAttribute.d.ts +33 -0
- package/dist/dataAttribute.d.ts.map +1 -0
- package/dist/dataAttribute.js +49 -0
- package/dist/dataAttribute.js.map +1 -0
- package/dist/errors/badResponse.error.d.ts +9 -0
- package/dist/errors/badResponse.error.d.ts.map +1 -0
- package/dist/errors/badResponse.error.js +21 -0
- package/dist/errors/badResponse.error.js.map +1 -0
- package/dist/event/event.types.d.ts +29 -0
- package/dist/event/event.types.d.ts.map +1 -0
- package/dist/event/event.types.js +3 -0
- package/dist/event/event.types.js.map +1 -0
- package/dist/event.d.ts +41 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +42 -45
- package/dist/event.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -76
- package/dist/index.js.map +1 -0
- package/dist/message/message.types.d.ts +17 -0
- package/dist/message/message.types.d.ts.map +1 -0
- package/dist/message/message.types.js +11 -0
- package/dist/message/message.types.js.map +1 -0
- package/dist/message.d.ts +30 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/message.js +32 -31
- package/dist/message.js.map +1 -0
- package/dist/scroll.d.ts +24 -0
- package/dist/scroll.d.ts.map +1 -0
- package/dist/scroll.js +67 -79
- package/dist/scroll.js.map +1 -0
- package/dist/segment/segment.types.d.ts +11 -0
- package/dist/segment/segment.types.d.ts.map +1 -0
- package/dist/segment/segment.types.js +3 -0
- package/dist/segment/segment.types.js.map +1 -0
- package/dist/segment.d.ts +22 -0
- package/dist/segment.d.ts.map +1 -0
- package/dist/segment.js +26 -36
- package/dist/segment.js.map +1 -0
- package/dist/subscription/subscription.types.d.ts +19 -0
- package/dist/subscription/subscription.types.d.ts.map +1 -0
- package/dist/subscription/subscription.types.js +10 -0
- package/dist/subscription/subscription.types.js.map +1 -0
- package/dist/tag/tag.types.d.ts +6 -0
- package/dist/tag/tag.types.d.ts.map +1 -0
- package/dist/tag/tag.types.js +3 -0
- package/dist/tag/tag.types.js.map +1 -0
- package/dist/tag.d.ts +52 -0
- package/dist/tag.d.ts.map +1 -0
- package/dist/tag.js +93 -57
- package/dist/tag.js.map +1 -0
- package/dist/team/team.types.d.ts +7 -0
- package/dist/team/team.types.d.ts.map +1 -0
- package/dist/team/team.types.js +3 -0
- package/dist/team/team.types.js.map +1 -0
- package/dist/team.d.ts +18 -0
- package/dist/team.d.ts.map +1 -0
- package/dist/team.js +23 -0
- package/dist/team.js.map +1 -0
- package/dist/util/time.d.ts +3 -0
- package/dist/util/time.d.ts.map +1 -0
- package/dist/util/time.js +6 -0
- package/dist/util/time.js.map +1 -0
- package/dist/util/url.d.ts +3 -0
- package/dist/util/url.d.ts.map +1 -0
- package/dist/util/url.js +9 -0
- package/dist/util/url.js.map +1 -0
- package/package.json +57 -48
- package/dist/bulk.js +0 -55
- package/dist/counts.js +0 -88
- package/dist/customer.js +0 -33
- package/dist/note.js +0 -43
- package/dist/snippet.js +0 -121
- package/dist/user-data.js +0 -105
- package/dist/user.js +0 -120
- 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
|
-
[](https://circleci.com/gh/intercom/intercom-node)
|
|
4
|
+
[](https://www.npmjs.com/package/intercom-client)
|
|
5
|
+

|
|
6
|
+

|
|
5
7
|
|
|
6
|
-
[
|
|
8
|
+
> Official Node bindings to the [Intercom API](https://api.intercom.io/docs)
|
|
7
9
|
|
|
8
|
-
##
|
|
10
|
+
## Project Updates
|
|
11
|
+
|
|
12
|
+
## Breaking changes
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
35
|
+
yarn prepublish
|
|
33
36
|
```
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
## Usage
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
Import Intercom:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { Client } from './dist/index';
|
|
39
44
|
```
|
|
40
45
|
|
|
41
|
-
|
|
46
|
+
Create a client using access tokens:
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
```typescript
|
|
49
|
+
const client = new Client({ tokenAuth: { token: 'my_token' } });
|
|
50
|
+
```
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
50
|
-
#### Using Access Tokens
|
|
63
|
+
Note that certain request options (such as `json`, and certain `headers` names cannot be overriden).
|
|
51
64
|
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
##
|
|
78
|
+
## Examples
|
|
57
79
|
|
|
58
|
-
|
|
80
|
+
### Admins
|
|
59
81
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
98
|
+
#### [List all activity logs](https://developers.intercom.com/intercom-api-reference/reference/view-admin-activity-logs)
|
|
66
99
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
107
|
+
#### [List all admins](https://developers.intercom.com/intercom-api-reference/reference/list-admins)
|
|
74
108
|
|
|
75
|
-
|
|
109
|
+
```typescript
|
|
110
|
+
const admins = await client.admins.list();
|
|
111
|
+
```
|
|
76
112
|
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
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
|
-
|
|
168
|
+
#### [Delete an article](https://developers.intercom.com/intercom-api-reference/reference/delete-an-article)
|
|
86
169
|
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
183
|
+
### Companies
|
|
97
184
|
|
|
185
|
+
#### [Create a company](https://developers.intercom.com/intercom-api-reference/reference/create-or-update-company)
|
|
98
186
|
|
|
99
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
227
|
+
##### By name
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
const company = await client.companies.find({
|
|
231
|
+
name: 'bruh moment inc.',
|
|
232
|
+
});
|
|
127
233
|
```
|
|
128
234
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
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
|
-
|
|
155
|
-
client.users.find({ user_id: 'foobar' }, callback);
|
|
266
|
+
##### Using infinite scroll
|
|
156
267
|
|
|
157
|
-
|
|
158
|
-
client.
|
|
268
|
+
```typescript
|
|
269
|
+
const companies = await client.companies.scroll.each({});
|
|
159
270
|
```
|
|
160
271
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
client.
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
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
|
-
|
|
180
|
-
client.
|
|
300
|
+
```typescript
|
|
301
|
+
const response = await client.companies.listAttachedContacts({
|
|
302
|
+
companyId: '123',
|
|
303
|
+
page: 1,
|
|
304
|
+
perPage: 15,
|
|
305
|
+
});
|
|
181
306
|
```
|
|
182
307
|
|
|
183
|
-
|
|
308
|
+
#### [List attached segments](https://developers.intercom.com/intercom-api-reference/reference/list-attached-segments-1)
|
|
184
309
|
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
```
|
|
229
|
-
|
|
230
|
-
client.leads.find({ id: '5342423' }, callback);
|
|
376
|
+
```typescript
|
|
377
|
+
const response = await client.contacts.archive({ id: '123' });
|
|
231
378
|
```
|
|
232
379
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
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
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
-
|
|
457
|
+
##### Without a cursor
|
|
259
458
|
|
|
260
|
-
```
|
|
261
|
-
|
|
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
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
client.
|
|
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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
-
|
|
495
|
+
#### [Create a conversation](https://developers.intercom.com/intercom-api-reference/reference/create-a-conversation)
|
|
297
496
|
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
client.
|
|
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
|
-
|
|
564
|
+
###### As user
|
|
344
565
|
|
|
345
|
-
|
|
566
|
+
```typescript
|
|
567
|
+
const response = await client.conversations.replyByLastAsUser({
|
|
568
|
+
body: 'blablbalba',
|
|
569
|
+
intercomUserId: '123',
|
|
570
|
+
attachmentUrls: '345',
|
|
571
|
+
});
|
|
572
|
+
```
|
|
346
573
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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
|
-
|
|
599
|
+
##### As team with assignment rules
|
|
368
600
|
|
|
369
|
-
```
|
|
370
|
-
client.
|
|
601
|
+
```typescript
|
|
602
|
+
const response = await client.conversations.assign({
|
|
603
|
+
id: '123',
|
|
604
|
+
withRunningAssignmentRules: true,
|
|
605
|
+
});
|
|
606
|
+
```
|
|
371
607
|
|
|
372
|
-
|
|
608
|
+
#### [Snooze a conversation](https://developers.intercom.com/intercom-api-reference/reference/snooze-a-conversation)
|
|
373
609
|
|
|
374
|
-
|
|
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
|
-
|
|
628
|
+
#### [Open a conversation](https://developers.intercom.com/intercom-api-reference/reference/open-a-conversation)
|
|
377
629
|
|
|
378
|
-
|
|
630
|
+
```typescript
|
|
631
|
+
const response = await client.conversations.open({
|
|
632
|
+
id: '123',
|
|
633
|
+
adminId: '234',
|
|
634
|
+
});
|
|
635
|
+
```
|
|
379
636
|
|
|
380
|
-
|
|
637
|
+
#### [Attach a contact to group conversation](https://developers.intercom.com/intercom-api-reference/reference/adding-to-group-conversations-as-admin)
|
|
381
638
|
|
|
382
|
-
|
|
639
|
+
##### As admin, using intercomUserid
|
|
383
640
|
|
|
384
|
-
|
|
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
|
-
|
|
651
|
+
##### As contact, using intercomUserid
|
|
388
652
|
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
|
|
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
|
-
|
|
395
|
-
|
|
396
|
-
|
|
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
|
-
|
|
401
|
-
|
|
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
|
-
|
|
739
|
+
#### [Redact a conversation](https://developers.intercom.com/intercom-api-reference/reference/redact-a-conversation-part)
|
|
405
740
|
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
|
|
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
|
-
|
|
412
|
-
|
|
413
|
-
|
|
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
|
-
|
|
417
|
-
|
|
418
|
-
|
|
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
|
-
|
|
422
|
-
|
|
423
|
-
|
|
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
|
-
|
|
427
|
-
|
|
428
|
-
|
|
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
|
-
|
|
432
|
-
|
|
433
|
-
|
|
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
|
-
|
|
818
|
+
### Help Center - Collections
|
|
437
819
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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
|
-
|
|
444
|
-
|
|
445
|
-
|
|
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
|
-
|
|
841
|
+
#### [Update a collection](https://developers.intercom.com/intercom-api-reference/reference/update-a-collection)
|
|
449
842
|
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
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
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
874
|
+
## Help Center - Sections
|
|
485
875
|
|
|
486
|
-
|
|
876
|
+
#### [Create a section](https://developers.intercom.com/intercom-api-reference/reference/create-a-section)
|
|
487
877
|
|
|
488
|
-
```
|
|
489
|
-
client.
|
|
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
|
-
```
|
|
494
|
-
|
|
495
|
-
client.conversations.find({ id: '1062682196' }, callback);
|
|
893
|
+
```typescript
|
|
894
|
+
const response = await client.helpCenter.sections.find({ id: '123' });
|
|
496
895
|
```
|
|
497
896
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
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
|
-
|
|
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
|
-
|
|
915
|
+
```typescript
|
|
916
|
+
await client.helpCenter.sections.delete({
|
|
917
|
+
id: '123',
|
|
918
|
+
});
|
|
919
|
+
```
|
|
534
920
|
|
|
535
|
-
|
|
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
|
-
|
|
923
|
+
```typescript
|
|
924
|
+
const response = client.helpCenter.sections.list({
|
|
925
|
+
page: 3,
|
|
926
|
+
perPage: 12,
|
|
927
|
+
});
|
|
545
928
|
```
|
|
546
929
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
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
|
-
|
|
951
|
+
### Segments
|
|
553
952
|
|
|
554
|
-
|
|
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
|
-
|
|
955
|
+
```typescript
|
|
956
|
+
const response = await client.segments.find({
|
|
957
|
+
id: '123',
|
|
958
|
+
includeCount: true,
|
|
959
|
+
});
|
|
565
960
|
```
|
|
566
961
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
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
|
-
|
|
573
|
-
|
|
574
|
-
|
|
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
|
-
|
|
980
|
+
##### Update
|
|
578
981
|
|
|
579
|
-
|
|
982
|
+
```typescript
|
|
983
|
+
const response = await client.tags.update({ id: '123', name: 'haven' });
|
|
984
|
+
```
|
|
580
985
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
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
|
-
|
|
992
|
+
#### [Attach a contact](https://developers.intercom.com/intercom-api-reference/reference/tag-contact)
|
|
590
993
|
|
|
591
|
-
```
|
|
592
|
-
client.
|
|
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
|
-
|
|
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
|
-
```
|
|
1074
|
+
```node
|
|
600
1075
|
import { IdentityVerification } from 'intercom-client';
|
|
601
1076
|
|
|
602
|
-
IdentityVerification.userHash({
|
|
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
|
-
-
|
|
1089
|
+
- **Add tests!** Your patch won't be accepted if it doesn't have tests.
|
|
613
1090
|
|
|
614
|
-
-
|
|
615
|
-
|
|
1091
|
+
- **Document any change in behaviour**. Make sure the README and any other
|
|
1092
|
+
relevant documentation are kept up-to-date.
|
|
616
1093
|
|
|
617
|
-
-
|
|
1094
|
+
- **Create topic branches**. Don't ask us to pull from your master branch.
|
|
618
1095
|
|
|
619
|
-
-
|
|
620
|
-
|
|
1096
|
+
- **One pull request per feature**. If you want to do more than one thing, send
|
|
1097
|
+
multiple pull requests.
|
|
621
1098
|
|
|
622
|
-
-
|
|
623
|
-
|
|
624
|
-
|
|
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.
|