intercom-client 2.11.2 → 3.0.1
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 +863 -404
- 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 -44
- package/dist/admin.js.map +1 -0
- package/dist/article/article.types.d.ts +87 -0
- package/dist/article/article.types.d.ts.map +1 -0
- package/dist/article/article.types.js +45 -0
- package/dist/article/article.types.js.map +1 -0
- package/dist/article.d.ts +37 -0
- package/dist/article.d.ts.map +1 -0
- package/dist/article.js +69 -0
- package/dist/article.js.map +1 -0
- package/dist/client.d.ts +71 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +235 -237
- package/dist/client.js.map +1 -0
- package/dist/common/common.types.d.ts +64 -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 +63 -0
- package/dist/company.d.ts.map +1 -0
- package/dist/company.js +110 -81
- 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 +126 -0
- package/dist/contact.d.ts.map +1 -0
- package/dist/contact.js +155 -79
- 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 -46
- 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 -43
- package/dist/event.js.map +1 -0
- package/dist/helpCenter/helpCenter.types.d.ts +23 -0
- package/dist/helpCenter/helpCenter.types.d.ts.map +1 -0
- package/dist/helpCenter/helpCenter.types.js +3 -0
- package/dist/helpCenter/helpCenter.types.js.map +1 -0
- package/dist/helpCenter.d.ts +61 -0
- package/dist/helpCenter.d.ts.map +1 -0
- package/dist/helpCenter.js +121 -0
- package/dist/helpCenter.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -74
- 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 -29
- package/dist/message.js.map +1 -0
- package/dist/package.json +59 -0
- package/dist/scroll.d.ts +24 -0
- package/dist/scroll.d.ts.map +1 -0
- package/dist/scroll.js +67 -77
- 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 -34
- 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 -55
- 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 -49
- package/dist/bulk.js +0 -53
- package/dist/counts.js +0 -86
- package/dist/customer.js +0 -31
- package/dist/note.js +0 -41
- package/dist/snippet.js +0 -119
- package/dist/user-data.js +0 -103
- package/dist/user.js +0 -118
- package/dist/visitor.js +0 -52
package/README.md
CHANGED
|
@@ -2,19 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://circleci.com/gh/intercom/intercom-node)
|
|
4
4
|
[](https://www.npmjs.com/package/intercom-client)
|
|
5
|
-

|
|
6
|
+

|
|
6
7
|
|
|
7
8
|
> Official Node bindings to the [Intercom API](https://api.intercom.io/docs)
|
|
8
9
|
|
|
9
10
|
## Project Updates
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
## Breaking changes
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
In the meantime, we'll be operating on limited capacity, meaning all pull requests will be evaluated on a best effort basis and will be limited to critical issues.
|
|
16
|
-
|
|
17
|
-
We'll communicate all relevant updates as we build this new team and support strategy in the coming months.
|
|
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).
|
|
18
15
|
|
|
19
16
|
## Installation
|
|
20
17
|
|
|
@@ -22,7 +19,7 @@ We'll communicate all relevant updates as we build this new team and support str
|
|
|
22
19
|
yarn add intercom-client
|
|
23
20
|
```
|
|
24
21
|
|
|
25
|
-
**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.**
|
|
26
23
|
|
|
27
24
|
## Testing
|
|
28
25
|
|
|
@@ -35,590 +32,1052 @@ yarn test
|
|
|
35
32
|
Compile using babel:
|
|
36
33
|
|
|
37
34
|
```bash
|
|
38
|
-
yarn
|
|
35
|
+
yarn prepublish
|
|
39
36
|
```
|
|
40
37
|
|
|
41
|
-
|
|
38
|
+
## Usage
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
Import Intercom:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { Client } from './dist/index';
|
|
45
44
|
```
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
Create a client using access tokens:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
const client = new Client({ tokenAuth: { token: 'my_token' } });
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Request Options
|
|
48
53
|
|
|
49
|
-
|
|
54
|
+
This client library also supports passing in [`request` options](https://github.com/axios/axios#request-config):
|
|
50
55
|
|
|
51
|
-
```
|
|
52
|
-
|
|
56
|
+
```typescript
|
|
57
|
+
const client = new Client({ tokenAuth: { token: 'my_token' } });
|
|
58
|
+
client.useRequestOpts({
|
|
59
|
+
baseURL: 'http://local.test-server.com',
|
|
60
|
+
});
|
|
53
61
|
```
|
|
54
62
|
|
|
55
|
-
|
|
63
|
+
Note that certain request options (such as `json`, and certain `headers` names cannot be overriden).
|
|
56
64
|
|
|
57
|
-
|
|
58
|
-
|
|
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
|
+
});
|
|
59
76
|
```
|
|
60
77
|
|
|
61
|
-
##
|
|
78
|
+
## Examples
|
|
62
79
|
|
|
63
|
-
|
|
80
|
+
### Admins
|
|
64
81
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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,
|
|
68
95
|
});
|
|
69
96
|
```
|
|
70
97
|
|
|
71
|
-
|
|
98
|
+
#### [List all activity logs](https://developers.intercom.com/intercom-api-reference/reference/view-admin-activity-logs)
|
|
72
99
|
|
|
73
|
-
```
|
|
74
|
-
client.
|
|
75
|
-
|
|
76
|
-
|
|
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');,
|
|
77
104
|
});
|
|
78
105
|
```
|
|
79
106
|
|
|
80
|
-
|
|
107
|
+
#### [List all admins](https://developers.intercom.com/intercom-api-reference/reference/list-admins)
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
const admins = await client.admins.list();
|
|
111
|
+
```
|
|
81
112
|
|
|
82
|
-
|
|
113
|
+
### Articles
|
|
83
114
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
+
},
|
|
87
135
|
});
|
|
88
136
|
```
|
|
89
137
|
|
|
90
|
-
|
|
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
|
+
```
|
|
91
167
|
|
|
92
|
-
|
|
168
|
+
#### [Delete an article](https://developers.intercom.com/intercom-api-reference/reference/delete-an-article)
|
|
93
169
|
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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,
|
|
100
180
|
});
|
|
101
181
|
```
|
|
102
182
|
|
|
103
|
-
|
|
183
|
+
### Companies
|
|
104
184
|
|
|
105
|
-
|
|
185
|
+
#### [Create a company](https://developers.intercom.com/intercom-api-reference/reference/create-or-update-company)
|
|
106
186
|
|
|
107
|
-
|
|
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
|
+
```
|
|
108
200
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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: {},
|
|
115
214
|
});
|
|
116
215
|
```
|
|
117
216
|
|
|
118
|
-
|
|
217
|
+
#### [Retrieve a company](https://developers.intercom.com/intercom-api-reference/reference/view-a-company)
|
|
119
218
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
}, callback);
|
|
128
|
-
|
|
129
|
-
// Update a user
|
|
130
|
-
client.users.update({
|
|
131
|
-
email: 'jayne@serenity.io',
|
|
132
|
-
custom_attributes: {
|
|
133
|
-
foo: 'bar'
|
|
134
|
-
}
|
|
135
|
-
}, callback);
|
|
219
|
+
##### By id
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
const company = await client.companies.find({
|
|
223
|
+
companyId: 123,
|
|
224
|
+
});
|
|
136
225
|
```
|
|
137
226
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
227
|
+
##### By name
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
const company = await client.companies.find({
|
|
231
|
+
name: 'bruh moment inc.',
|
|
232
|
+
});
|
|
141
233
|
```
|
|
142
234
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
+
});
|
|
146
241
|
```
|
|
147
242
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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,
|
|
252
|
+
});
|
|
151
253
|
```
|
|
152
254
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
setTimeout(() => {
|
|
160
|
-
console.log(res.body.users.length);
|
|
161
|
-
// Your custom logic
|
|
162
|
-
resolve();
|
|
163
|
-
}, 500)
|
|
164
|
-
})
|
|
255
|
+
##### With TagId and SegmentId
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
const companies = await client.companies.list({
|
|
259
|
+
tagId: '1234',
|
|
260
|
+
segmentId: '4567',
|
|
165
261
|
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
#### [Scroll over companies](https://developers.intercom.com/intercom-api-reference/reference/iterating-over-all-companies)
|
|
265
|
+
|
|
266
|
+
##### Using infinite scroll
|
|
166
267
|
|
|
268
|
+
```typescript
|
|
269
|
+
const companies = await client.companies.scroll.each({});
|
|
167
270
|
```
|
|
168
271
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
272
|
+
##### Using manual scroll
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
const companies = await client.companies.scroll.next({
|
|
276
|
+
scrollParam: '123_soleil',
|
|
277
|
+
});
|
|
278
|
+
```
|
|
172
279
|
|
|
173
|
-
|
|
174
|
-
client.users.find({ user_id: 'foobar' }, callback);
|
|
280
|
+
#### [Attach a contact](https://developers.intercom.com/intercom-api-reference/reference/attach-contact-to-company)
|
|
175
281
|
|
|
176
|
-
|
|
177
|
-
client.
|
|
282
|
+
```typescript
|
|
283
|
+
const response = await client.companies.attachContact({
|
|
284
|
+
contactId: '123',
|
|
285
|
+
companyId: '234',
|
|
286
|
+
});
|
|
178
287
|
```
|
|
179
288
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
+
});
|
|
183
296
|
```
|
|
184
297
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
client.
|
|
298
|
+
#### [List attached contacts](https://developers.intercom.com/intercom-api-reference/reference/list-company-contacts)
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
const response = await client.companies.listAttachedContacts({
|
|
302
|
+
companyId: '123',
|
|
303
|
+
page: 1,
|
|
304
|
+
perPage: 15,
|
|
305
|
+
});
|
|
189
306
|
```
|
|
190
307
|
|
|
191
|
-
|
|
192
|
-
// Permanently delete a user by id in params
|
|
193
|
-
client.users.requestPermanentDeletionByParams({ id: '55b9eaf' }, callback);
|
|
308
|
+
#### [List attached segments](https://developers.intercom.com/intercom-api-reference/reference/list-attached-segments-1)
|
|
194
309
|
|
|
195
|
-
|
|
196
|
-
client.
|
|
310
|
+
```typescript
|
|
311
|
+
const response = await client.companies.listAttachedSegments({
|
|
312
|
+
companyId: '123',
|
|
313
|
+
});
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Contacts
|
|
317
|
+
|
|
318
|
+
#### [Create Contact](https://developers.intercom.com/intercom-api-reference/reference/create-contact)
|
|
197
319
|
|
|
198
|
-
|
|
199
|
-
|
|
320
|
+
##### With User Role
|
|
321
|
+
|
|
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,
|
|
332
|
+
});
|
|
200
333
|
```
|
|
201
334
|
|
|
202
|
-
|
|
335
|
+
##### With Lead Role
|
|
203
336
|
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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,
|
|
208
346
|
});
|
|
347
|
+
```
|
|
209
348
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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' });
|
|
353
|
+
```
|
|
354
|
+
|
|
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
|
+
},
|
|
213
365
|
});
|
|
214
366
|
```
|
|
215
367
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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' });
|
|
219
372
|
```
|
|
220
373
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
374
|
+
#### [Archive a Contact](https://developers.intercom.com/intercom-api-reference/reference/archive-a-contact)
|
|
375
|
+
|
|
376
|
+
```typescript
|
|
377
|
+
const response = await client.contacts.archive({ id: '123' });
|
|
224
378
|
```
|
|
225
379
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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' });
|
|
384
|
+
```
|
|
385
|
+
|
|
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',
|
|
238
392
|
});
|
|
239
393
|
```
|
|
240
394
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
+
});
|
|
244
443
|
```
|
|
245
444
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
+
});
|
|
249
455
|
```
|
|
250
456
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
457
|
+
##### Without a cursor
|
|
458
|
+
|
|
459
|
+
```typescript
|
|
460
|
+
const response = await client.contacts.list();
|
|
254
461
|
```
|
|
255
462
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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
|
+
});
|
|
263
471
|
```
|
|
264
472
|
|
|
265
|
-
|
|
473
|
+
#### [List attached tags](https://developers.intercom.com/intercom-api-reference/reference/list-tags-of-contact)
|
|
266
474
|
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
client.customers.search({
|
|
270
|
-
query: { field: 'name', operator: '=', name: 'Alice'},
|
|
271
|
-
sort: { field: 'name', order: 'ascending'},
|
|
272
|
-
pagination: { per_page: 10 }
|
|
273
|
-
}, callback);
|
|
475
|
+
```typescript
|
|
476
|
+
const response = await client.contacts.listAttachedTags({ id: '123' });
|
|
274
477
|
```
|
|
275
478
|
|
|
276
|
-
|
|
479
|
+
#### [List attached segments](https://developers.intercom.com/intercom-api-reference/reference/list-attached-segments)
|
|
277
480
|
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
client.visitors.update({ id: '5435345', email: 'wash@serenity.io' }, callback);
|
|
481
|
+
```typescript
|
|
482
|
+
const response = await client.contacts.listAttachedSegments({ id: '123' });
|
|
281
483
|
```
|
|
282
484
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
client.
|
|
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
|
+
});
|
|
287
491
|
```
|
|
288
492
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
493
|
+
### Conversations
|
|
494
|
+
|
|
495
|
+
#### [Create a conversation](https://developers.intercom.com/intercom-api-reference/reference/create-a-conversation)
|
|
496
|
+
|
|
497
|
+
```typescript
|
|
498
|
+
const response = await client.conversations.create({
|
|
499
|
+
userId: '123',
|
|
500
|
+
body: 'Hello darkness my old friend',
|
|
501
|
+
});
|
|
292
502
|
```
|
|
293
503
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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
|
+
});
|
|
302
512
|
```
|
|
303
513
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
514
|
+
##### As plain text
|
|
515
|
+
|
|
516
|
+
```typescript
|
|
517
|
+
const response = await client.conversations.find({
|
|
518
|
+
id: '123',
|
|
519
|
+
inPlainText: true,
|
|
520
|
+
});
|
|
311
521
|
```
|
|
312
522
|
|
|
313
|
-
|
|
523
|
+
#### [Update a conversation](https://developers.intercom.com/intercom-api-reference/reference/update-a-conversation)
|
|
314
524
|
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
525
|
+
```typescript
|
|
526
|
+
const response = await client.conversations.update({
|
|
527
|
+
id,
|
|
528
|
+
markRead: true,
|
|
529
|
+
customAttributes: {
|
|
530
|
+
anything: 'you want',
|
|
531
|
+
},
|
|
319
532
|
});
|
|
320
533
|
```
|
|
321
534
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
535
|
+
#### [Reply to a conversation](https://developers.intercom.com/intercom-api-reference/reference/reply-to-a-conversation)
|
|
536
|
+
|
|
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
|
+
});
|
|
325
548
|
```
|
|
326
549
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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
|
+
});
|
|
330
560
|
```
|
|
331
561
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
resolve();
|
|
342
|
-
}, 500)
|
|
343
|
-
})
|
|
562
|
+
##### By last conversation
|
|
563
|
+
|
|
564
|
+
###### As user
|
|
565
|
+
|
|
566
|
+
```typescript
|
|
567
|
+
const response = await client.conversations.replyByLastAsUser({
|
|
568
|
+
body: 'blablbalba',
|
|
569
|
+
intercomUserId: '123',
|
|
570
|
+
attachmentUrls: '345',
|
|
344
571
|
});
|
|
345
572
|
```
|
|
346
573
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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'],
|
|
582
|
+
});
|
|
350
583
|
```
|
|
351
584
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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
|
+
});
|
|
356
597
|
```
|
|
357
598
|
|
|
358
|
-
|
|
599
|
+
##### As team with assignment rules
|
|
359
600
|
|
|
360
|
-
|
|
601
|
+
```typescript
|
|
602
|
+
const response = await client.conversations.assign({
|
|
603
|
+
id: '123',
|
|
604
|
+
withRunningAssignmentRules: true,
|
|
605
|
+
});
|
|
606
|
+
```
|
|
361
607
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}, function (d) {
|
|
370
|
-
console.log(d);
|
|
608
|
+
#### [Snooze a conversation](https://developers.intercom.com/intercom-api-reference/reference/snooze-a-conversation)
|
|
609
|
+
|
|
610
|
+
```typescript
|
|
611
|
+
const response = await client.conversations.snooze({
|
|
612
|
+
id: '123',
|
|
613
|
+
adminId: '234',
|
|
614
|
+
snoozedUntil: '1501512795',
|
|
371
615
|
});
|
|
372
616
|
```
|
|
373
617
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
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
|
+
});
|
|
380
626
|
```
|
|
381
627
|
|
|
382
|
-
|
|
628
|
+
#### [Open a conversation](https://developers.intercom.com/intercom-api-reference/reference/open-a-conversation)
|
|
383
629
|
|
|
384
|
-
```
|
|
385
|
-
client.
|
|
630
|
+
```typescript
|
|
631
|
+
const response = await client.conversations.open({
|
|
632
|
+
id: '123',
|
|
633
|
+
adminId: '234',
|
|
634
|
+
});
|
|
635
|
+
```
|
|
386
636
|
|
|
387
|
-
|
|
637
|
+
#### [Attach a contact to group conversation](https://developers.intercom.com/intercom-api-reference/reference/adding-to-group-conversations-as-admin)
|
|
388
638
|
|
|
389
|
-
|
|
639
|
+
##### As admin, using intercomUserid
|
|
390
640
|
|
|
391
|
-
|
|
641
|
+
```typescript
|
|
642
|
+
const response = await client.conversations.attachContactAsAdmin({
|
|
643
|
+
id: '123',
|
|
644
|
+
adminId: '234',
|
|
645
|
+
customer: {
|
|
646
|
+
intercomUserId: '456',
|
|
647
|
+
},
|
|
648
|
+
});
|
|
649
|
+
```
|
|
392
650
|
|
|
393
|
-
|
|
651
|
+
##### As contact, using intercomUserid
|
|
394
652
|
|
|
395
|
-
|
|
653
|
+
```typescript
|
|
654
|
+
const response = await client.conversations.attachContactAsAdmin({
|
|
655
|
+
id: '123',
|
|
656
|
+
userId: '234',
|
|
657
|
+
customer: {
|
|
658
|
+
intercomUserId: '456',
|
|
659
|
+
},
|
|
660
|
+
});
|
|
661
|
+
```
|
|
396
662
|
|
|
397
|
-
|
|
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
|
+
});
|
|
671
|
+
```
|
|
398
672
|
|
|
399
|
-
|
|
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
|
+
});
|
|
400
724
|
```
|
|
401
725
|
|
|
402
|
-
|
|
726
|
+
#### [List all conversations](https://developers.intercom.com/intercom-api-reference/reference/list-conversations)
|
|
403
727
|
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
|
|
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
|
+
});
|
|
407
737
|
```
|
|
408
738
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
739
|
+
#### [Redact a conversation](https://developers.intercom.com/intercom-api-reference/reference/redact-a-conversation-part)
|
|
740
|
+
|
|
741
|
+
```typescript
|
|
742
|
+
const response = await client.conversations.redactConversationPart({
|
|
743
|
+
type: RedactConversationPartType.CONVERSATION_PART,
|
|
744
|
+
conversationId: '123',
|
|
745
|
+
conversationPartId: '456',
|
|
746
|
+
});
|
|
412
747
|
```
|
|
413
748
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
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
|
+
});
|
|
417
761
|
```
|
|
418
762
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
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
|
+
});
|
|
422
772
|
```
|
|
423
773
|
|
|
424
|
-
|
|
774
|
+
#### [List all Data Attributes](https://developers.intercom.com/intercom-api-reference/reference/list-data-attributes)
|
|
425
775
|
|
|
426
|
-
```
|
|
427
|
-
|
|
428
|
-
|
|
776
|
+
```typescript
|
|
777
|
+
const response = await client.dataAttributes.list({
|
|
778
|
+
model: ModelType.CONTACT,
|
|
779
|
+
includeArchived: true,
|
|
780
|
+
});
|
|
429
781
|
```
|
|
430
782
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
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
|
+
});
|
|
434
805
|
```
|
|
435
806
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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
|
+
});
|
|
439
816
|
```
|
|
440
817
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
818
|
+
### Help Center - Collections
|
|
819
|
+
|
|
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
|
+
});
|
|
444
833
|
```
|
|
445
834
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
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' });
|
|
449
839
|
```
|
|
450
840
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
841
|
+
#### [Update a collection](https://developers.intercom.com/intercom-api-reference/reference/update-a-collection)
|
|
842
|
+
|
|
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
|
+
});
|
|
454
855
|
```
|
|
455
856
|
|
|
456
|
-
|
|
857
|
+
#### [Delete a collection](https://developers.intercom.com/intercom-api-reference/reference/delete-a-collection)
|
|
457
858
|
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
|
|
859
|
+
```typescript
|
|
860
|
+
await client.helpCenter.collections.delete({
|
|
861
|
+
id: '123',
|
|
862
|
+
});
|
|
461
863
|
```
|
|
462
864
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
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
|
+
});
|
|
466
872
|
```
|
|
467
873
|
|
|
468
|
-
##
|
|
874
|
+
## Help Center - Sections
|
|
469
875
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
type: "user",
|
|
484
|
-
id: "55c1ce1def857c31f80001af"
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
client.messages.create(message, callback);
|
|
876
|
+
#### [Create a section](https://developers.intercom.com/intercom-api-reference/reference/create-a-section)
|
|
877
|
+
|
|
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
|
+
});
|
|
489
889
|
```
|
|
490
890
|
|
|
491
|
-
|
|
492
|
-
// Creating a user-initiated message:
|
|
493
|
-
var message = {
|
|
494
|
-
from: {
|
|
495
|
-
type: "user",
|
|
496
|
-
id: "55c1ce1def857c31f80001af"
|
|
497
|
-
},
|
|
498
|
-
body: "Howdy"
|
|
499
|
-
}
|
|
891
|
+
#### [Retrieve a section](https://developers.intercom.com/intercom-api-reference/reference/retrieve-a-section)
|
|
500
892
|
|
|
501
|
-
|
|
893
|
+
```typescript
|
|
894
|
+
const response = await client.helpCenter.sections.find({ id: '123' });
|
|
502
895
|
```
|
|
503
896
|
|
|
504
|
-
|
|
897
|
+
#### [Update a section](https://developers.intercom.com/intercom-api-reference/reference/update-a-section)
|
|
505
898
|
|
|
506
|
-
|
|
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
|
+
});
|
|
911
|
+
```
|
|
507
912
|
|
|
508
|
-
|
|
509
|
-
|
|
913
|
+
#### [Delete a section](https://developers.intercom.com/intercom-api-reference/reference/delete-a-section)
|
|
914
|
+
|
|
915
|
+
```typescript
|
|
916
|
+
await client.helpCenter.sections.delete({
|
|
917
|
+
id: '123',
|
|
918
|
+
});
|
|
510
919
|
```
|
|
511
920
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
921
|
+
#### [List all sections](https://developers.intercom.com/intercom-api-reference/reference/list-all-sections)
|
|
922
|
+
|
|
923
|
+
```typescript
|
|
924
|
+
const response = client.helpCenter.sections.list({
|
|
925
|
+
page: 3,
|
|
926
|
+
perPage: 12,
|
|
927
|
+
});
|
|
515
928
|
```
|
|
516
929
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
attachment_urls: ['http://www.example.com/myattachment.jpg']
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
client.conversations.reply(reply, 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
|
+
});
|
|
540
949
|
```
|
|
541
950
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
id: '13879167940',
|
|
546
|
-
type: 'admin',
|
|
547
|
-
admin_id: '1309092',
|
|
548
|
-
assignee_id: '1723471',
|
|
549
|
-
message_type: 'assignment'
|
|
550
|
-
};
|
|
951
|
+
### Segments
|
|
952
|
+
|
|
953
|
+
#### [Retrieve a segment](https://developers.intercom.com/intercom-api-reference/reference/view-a-segment)
|
|
551
954
|
|
|
552
|
-
|
|
955
|
+
```typescript
|
|
956
|
+
const response = await client.segments.find({
|
|
957
|
+
id: '123',
|
|
958
|
+
includeCount: true,
|
|
959
|
+
});
|
|
960
|
+
```
|
|
553
961
|
|
|
554
|
-
|
|
555
|
-
var assignment = {
|
|
556
|
-
id: '13879167940',
|
|
557
|
-
type: 'admin',
|
|
558
|
-
admin_id: '1309092',
|
|
559
|
-
assignee_id: '0',
|
|
560
|
-
message_type: 'assignment'
|
|
561
|
-
}
|
|
962
|
+
#### [List all segments](https://developers.intercom.com/intercom-api-reference/reference/list-segments)
|
|
562
963
|
|
|
563
|
-
|
|
964
|
+
```typescript
|
|
965
|
+
const response = await client.segments.list({
|
|
966
|
+
includeCount: true,
|
|
967
|
+
});
|
|
564
968
|
```
|
|
565
969
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
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' });
|
|
569
978
|
```
|
|
570
979
|
|
|
571
|
-
|
|
980
|
+
##### Update
|
|
572
981
|
|
|
573
|
-
```
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
user: {
|
|
579
|
-
id: '55b26822ce97179e52001334'
|
|
580
|
-
}
|
|
581
|
-
};
|
|
982
|
+
```typescript
|
|
983
|
+
const response = await client.tags.update({ id: '123', name: 'haven' });
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
#### [Delete a tag](https://developers.intercom.com/intercom-api-reference/reference/delete-a-tag)
|
|
582
987
|
|
|
583
|
-
|
|
988
|
+
```typescript
|
|
989
|
+
const response = await client.tags.delete({ id: 'baz' });
|
|
584
990
|
```
|
|
585
991
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
992
|
+
#### [Attach a contact](https://developers.intercom.com/intercom-api-reference/reference/tag-contact)
|
|
993
|
+
|
|
994
|
+
```typescript
|
|
995
|
+
const response = await client.tags.tagContact({
|
|
996
|
+
contactId: '123',
|
|
997
|
+
tagId: '234',
|
|
998
|
+
});
|
|
589
999
|
```
|
|
590
1000
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
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
|
+
});
|
|
594
1009
|
```
|
|
595
1010
|
|
|
596
|
-
|
|
1011
|
+
#### [Tag companies](https://developers.intercom.com/intercom-api-reference/reference/tag-companies)
|
|
597
1012
|
|
|
598
|
-
|
|
1013
|
+
```typescript
|
|
1014
|
+
const response = await client.tags.tagCompanies({
|
|
1015
|
+
tagName: 'gutenTag',
|
|
1016
|
+
companiesIds: ['123', '234', '456'],
|
|
1017
|
+
});
|
|
1018
|
+
```
|
|
599
1019
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
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
|
+
});
|
|
606
1027
|
```
|
|
607
1028
|
|
|
608
|
-
|
|
1029
|
+
#### [Untag conversation](https://developers.intercom.com/intercom-api-reference/reference/detach-a-tag-from-a-conversation)
|
|
609
1030
|
|
|
610
|
-
```
|
|
611
|
-
client.
|
|
1031
|
+
```typescript
|
|
1032
|
+
const response = await client.tags.untagConversation({
|
|
1033
|
+
conversationId: '123',
|
|
1034
|
+
tagId: '345',
|
|
1035
|
+
adminId: '678',
|
|
1036
|
+
});
|
|
612
1037
|
```
|
|
613
1038
|
|
|
614
|
-
|
|
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
|
|
615
1071
|
|
|
616
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):
|
|
617
1073
|
|
|
618
|
-
```
|
|
1074
|
+
```node
|
|
619
1075
|
import { IdentityVerification } from 'intercom-client';
|
|
620
1076
|
|
|
621
|
-
IdentityVerification.userHash({
|
|
1077
|
+
IdentityVerification.userHash({
|
|
1078
|
+
secretKey: 's3cre7',
|
|
1079
|
+
identifier: 'jayne@serenity.io',
|
|
1080
|
+
});
|
|
622
1081
|
```
|
|
623
1082
|
|
|
624
1083
|
## License
|
|
@@ -627,16 +1086,16 @@ Apache-2.0
|
|
|
627
1086
|
|
|
628
1087
|
## Pull Requests
|
|
629
1088
|
|
|
630
|
-
-
|
|
1089
|
+
- **Add tests!** Your patch won't be accepted if it doesn't have tests.
|
|
631
1090
|
|
|
632
|
-
-
|
|
633
|
-
|
|
1091
|
+
- **Document any change in behaviour**. Make sure the README and any other
|
|
1092
|
+
relevant documentation are kept up-to-date.
|
|
634
1093
|
|
|
635
|
-
-
|
|
1094
|
+
- **Create topic branches**. Don't ask us to pull from your master branch.
|
|
636
1095
|
|
|
637
|
-
-
|
|
638
|
-
|
|
1096
|
+
- **One pull request per feature**. If you want to do more than one thing, send
|
|
1097
|
+
multiple pull requests.
|
|
639
1098
|
|
|
640
|
-
-
|
|
641
|
-
|
|
642
|
-
|
|
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.
|