reply-cli 0.11.0 → 0.14.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 +80 -7
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/operations/accounts.d.ts +6 -0
- package/dist/operations/accounts.js +73 -0
- package/dist/operations/accounts.js.map +1 -0
- package/dist/operations/commands.d.ts +2 -1
- package/dist/operations/commands.js +217 -18
- package/dist/operations/commands.js.map +1 -1
- package/dist/operations/contact-input.d.ts +7 -3
- package/dist/operations/contact-input.js +51 -12
- package/dist/operations/contact-input.js.map +1 -1
- package/dist/operations/contact-record.d.ts +11 -0
- package/dist/operations/contact-record.js +176 -0
- package/dist/operations/contact-record.js.map +1 -0
- package/dist/operations/contact.js +8 -4
- package/dist/operations/contact.js.map +1 -1
- package/dist/operations/contacts.d.ts +7 -3
- package/dist/operations/contacts.js +94 -29
- package/dist/operations/contacts.js.map +1 -1
- package/dist/operations/direct-send.d.ts +12 -0
- package/dist/operations/direct-send.js +185 -0
- package/dist/operations/direct-send.js.map +1 -0
- package/dist/operations/inbox-reply.d.ts +11 -0
- package/dist/operations/inbox-reply.js +160 -0
- package/dist/operations/inbox-reply.js.map +1 -0
- package/dist/operations/inbox.d.ts +19 -1
- package/dist/operations/inbox.js +105 -1
- package/dist/operations/inbox.js.map +1 -1
- package/dist/operations/options.d.ts +3 -2
- package/dist/operations/options.js +8 -4
- package/dist/operations/options.js.map +1 -1
- package/dist/operations/sequence-by-name.d.ts +9 -0
- package/dist/operations/sequence-by-name.js +96 -0
- package/dist/operations/sequence-by-name.js.map +1 -0
- package/dist/operations/stdin-input.d.ts +10 -0
- package/dist/operations/stdin-input.js +34 -0
- package/dist/operations/stdin-input.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -183,6 +183,8 @@ prints JSON (indented; compact with `--json`) and says what happened in a stable
|
|
|
183
183
|
|
|
184
184
|
| Command | Does |
|
|
185
185
|
|---|---|
|
|
186
|
+
| `reply sequence list --name -` | every sequence of a name, ignoring case, archived ones included |
|
|
187
|
+
| `reply sequence create --name -` | make a draft of a name, holding nobody, with one task step → its id |
|
|
186
188
|
| `reply sequence get <id>` | the sequence as Reply holds it |
|
|
187
189
|
| `reply sequence contacts <id> [--limit] [--offset]` | one page of its contacts, plus the total |
|
|
188
190
|
| `reply sequence stats <id> (--preset … \| --from … --to …)` | its email and LinkedIn counts over a window |
|
|
@@ -191,22 +193,93 @@ prints JSON (indented; compact with `--json`) and says what happened in a stable
|
|
|
191
193
|
| `reply sequence pause <id>` | → `paused` |
|
|
192
194
|
| `reply sequence start <id> [--expect-contacts N]` | → `started` / `already_active` |
|
|
193
195
|
| `reply contact-list add-contact <list-id> <contact> [--refuse-opted-out]` | → `added` |
|
|
196
|
+
| `reply contact find --contact -` | the id of the contact under an email or a LinkedIn URL, or null; never creates one |
|
|
197
|
+
| `reply contact get <id>` | the contact as Reply holds it |
|
|
198
|
+
| `reply contact update <id> --fields -` | change some fields and custom fields; null clears one → `updated` |
|
|
199
|
+
| `reply contact delete <id>` | → `deleted` |
|
|
194
200
|
| `reply contact opt-out <contact>` | → `opted_out` |
|
|
195
|
-
| `reply
|
|
201
|
+
| `reply contact send-email --contact-id N --email-account-id N --message -` | one email now, outside any sequence → `sent` |
|
|
202
|
+
| `reply contact linkedin-connect --contact-id N --linkedin-account-id N [--message -]` | a LinkedIn invitation, with or without a note → `sent` / `already_connected` |
|
|
203
|
+
| `reply contact linkedin-message …` · `linkedin-inmail …` · `linkedin-voice …` | a LinkedIn message, an InMail, or an AI voice message spoken from a script → `sent` |
|
|
204
|
+
| `reply inbox list (--contact-id \| --sequence-id) [--source] [--channel] [--category-id] [--since]` | one page of threads |
|
|
196
205
|
| `reply inbox get <thread-id>` | a thread with its subject, and one page of its messages |
|
|
206
|
+
| `reply inbox reply <thread-id> --message -` | reply in the thread, on its own channel → `sent` |
|
|
207
|
+
| `reply inbox categories` | the categories a thread can be filed under |
|
|
208
|
+
| `reply inbox categorize <thread-id> (--category-id N \| --clear)` | → `categorized` / `cleared` |
|
|
209
|
+
| `reply inbox mark-read <thread-id>` · `reply inbox mark-unread <thread-id>` | → `read` / `unread` |
|
|
210
|
+
| `reply account list [--channel email\|linkedin]` | the email and LinkedIn accounts a send can go from, whose each is, and the state of each |
|
|
197
211
|
|
|
198
212
|
`<contact>` is exactly one of `--contact <json>|@file|-`, `--email <address>` (with `--first-name`,
|
|
199
213
|
`--last-name`, `--company`, `--title`), or `--contact-id <id>`. The JSON takes the same fields
|
|
200
|
-
(`email`, `first_name`, …)
|
|
201
|
-
argument list:
|
|
214
|
+
(`email`, `first_name`, …) plus `linkedin_url`, with an email, a LinkedIn URL or both, and `-` reads
|
|
215
|
+
it from stdin, which keeps personal data out of the argument list:
|
|
202
216
|
|
|
203
217
|
```sh
|
|
204
218
|
echo '{"email":"ann@example.com","first_name":"Ann"}' | reply sequence add-contact 123 --contact -
|
|
219
|
+
echo '{"linkedin_url":"https://www.linkedin.com/in/ann-example","first_name":"Ann"}' | reply contact opt-out --contact -
|
|
205
220
|
```
|
|
206
221
|
|
|
207
222
|
The two `add-contact` commands always import a contact given by email, and Reply refuses an import
|
|
208
|
-
without a first name, even for a contact it already holds
|
|
209
|
-
Reply
|
|
223
|
+
without a first name, even for a contact it already holds; a contact given only by LinkedIn URL is
|
|
224
|
+
looked up first and imported only when Reply holds nobody under it. `contact opt-out` imports only
|
|
225
|
+
someone Reply doesn't hold yet; `sequence remove-contact` never imports. A contact is looked up, and
|
|
226
|
+
an import matched, by its email; one with only a LinkedIn URL, by that. The lookup is Reply's exact
|
|
227
|
+
one: an email matches ignoring case, and a LinkedIn URL is matched by its lowercased slug — on
|
|
228
|
+
linkedin.com the path's case does not count, nor the scheme's or host's, a default port, one trailing
|
|
229
|
+
slash or a fragment, while `www` and the query do. Reply is asked for a LinkedIn URL in that form
|
|
230
|
+
first, then as given, and the CLI stores a LinkedIn URL by its lowercased slug when it imports a
|
|
231
|
+
contact or runs `contact update`.
|
|
232
|
+
|
|
233
|
+
The commands that carry a person's or a sequence's text in a field of their own read it from stdin
|
|
234
|
+
only, and refuse it on the argument list: `contact find --contact -` (`{email}` or
|
|
235
|
+
`{linkedin_url}`), `contact update --fields -` (`{first_name, last_name, company, title,
|
|
236
|
+
linkedin_url, custom_fields: [{name, value}]}`, where a field left out stays as it is and `null`
|
|
237
|
+
clears one), and `sequence list|create --name -` (`{name}`):
|
|
238
|
+
|
|
239
|
+
```sh
|
|
240
|
+
echo '{"title":"CTO","custom_fields":[{"name":"leadSource","value":"Event"}]}' | reply contact update 456 --fields -
|
|
241
|
+
echo '{"name":"Q4 outreach"}' | reply sequence list --name -
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
`contact update` refuses a custom field the account has none of, `contact.field_not_found`, before
|
|
245
|
+
it changes anything.
|
|
246
|
+
|
|
247
|
+
`inbox reply` takes its message, `{body, reply_to_message_id}`, from stdin only, and refuses it on
|
|
248
|
+
the argument list. The reply goes to the thread's contact from the account that owns the thread;
|
|
249
|
+
`reply_to_message_id` (email threads only) names the message it answers:
|
|
250
|
+
|
|
251
|
+
```sh
|
|
252
|
+
echo '{"body":"Thanks, Tuesday works."}' | reply inbox reply 9876 --message -
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
The direct sends reach a contact outside any sequence, from an account you name: `contact
|
|
256
|
+
send-email` (`{subject, body}`, the body HTML), `contact linkedin-connect` (`{note}`, or no
|
|
257
|
+
`--message` for an invitation without one), `contact linkedin-message` (`{body}`), `contact
|
|
258
|
+
linkedin-inmail` (`{subject, body}`) and `contact linkedin-voice` (`{script}`, which Reply speaks in
|
|
259
|
+
the LinkedIn account's voice). Each reads its text from stdin only and refuses it on the argument
|
|
260
|
+
list. `reply account list` gives the ids to send from, each account's status (`active`, `inactive`,
|
|
261
|
+
`disconnected` or `other`) and Reply's own word for it. In a team that shares its accounts the list
|
|
262
|
+
holds teammates' accounts too, and `owner_user_id` says whose each one is. Without `--channel` both
|
|
263
|
+
lists are read, and one the plan or role does not include fails the whole command; `--channel email`
|
|
264
|
+
or `--channel linkedin` reads one alone:
|
|
265
|
+
|
|
266
|
+
```sh
|
|
267
|
+
echo '{"subject":"Quick question","body":"<p>Hi Ann, does Tuesday work?</p>"}' | reply contact send-email --contact-id 456 --email-account-id 12 --message -
|
|
268
|
+
echo '{"body":"Thanks for connecting, Ann."}' | reply contact linkedin-message --contact-id 456 --linkedin-account-id 34 --message -
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
A LinkedIn send answers Reply's activity id and its `sentAtUtc` as Reply gives it; a direct email
|
|
272
|
+
answers no time, so its `sent_at` is null, and the CLI never puts its own clock in either. The
|
|
273
|
+
lengths Reply publishes (a LinkedIn message's 8000 characters, an InMail's 200 and 1900, a script's
|
|
274
|
+
1000) are refused before anything is sent. Reply reads `{{…}}` in a LinkedIn text as its template
|
|
275
|
+
variables, and refuses one it cannot fill with `linkedin.missing_variables`.
|
|
276
|
+
|
|
277
|
+
`inbox reply`, `sequence create` and the five direct sends are the work commands that are not safe to
|
|
278
|
+
re-run. On exit 3 (outcome unknown) a reply or a send may already have gone, and running it again may
|
|
279
|
+
send it twice; for `inbox reply`, read the thread with `reply inbox get` before trying again. For
|
|
280
|
+
`sequence create`, Reply allows two sequences of one name, so after exit 3 look the name up with
|
|
281
|
+
`sequence list --name -` first. Every other work command can simply be run again; a `contact delete`
|
|
282
|
+
repeated after its first one took effect answers `contact.not_found`.
|
|
210
283
|
|
|
211
284
|
**Errors.** With `--json`, a failure is one line on stderr:
|
|
212
285
|
`{"error":{"code":"contact.opted_out","title":…,"status":…,"reply_code":…,"ids":{…}}}`. `ids` is
|
|
@@ -216,8 +289,8 @@ Reply refused the add. `reply.invalid_request` means Reply didn't accept a field
|
|
|
216
289
|
|
|
217
290
|
**Exit codes.** `0` done · `1` failed, and the main effect did not happen · `2` usage error, nothing
|
|
218
291
|
sent · `3` **outcome unknown**: a write may have happened and no answer came back. Re-running the
|
|
219
|
-
same command is safe
|
|
220
|
-
blindly.
|
|
292
|
+
same command is safe, except `inbox reply`, `sequence create` and the direct sends (above): each of
|
|
293
|
+
the others checks or relies on Reply's own state rather than repeating an effect blindly.
|
|
221
294
|
|
|
222
295
|
**Retries.** Reads are retried on errors. A write is retried only when it can't have reached Reply:
|
|
223
296
|
the connection was never made, or a `429` asked to wait 3 seconds or less. A longer `429` comes back
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,7 @@ const build_program = () => {
|
|
|
44
44
|
program.hook('preAction', () => { (0, output_1.set_quiet)(program.opts().quiet === true); });
|
|
45
45
|
const WORK = 'Work with your Reply account:';
|
|
46
46
|
const SETUP = 'Setup:';
|
|
47
|
-
for (const c of [commands_1.sequence_command, commands_1.contact_list_command, commands_1.contact_command, commands_1.inbox_command, api_1.api_command]) {
|
|
47
|
+
for (const c of [commands_1.sequence_command, commands_1.contact_list_command, commands_1.contact_command, commands_1.inbox_command, commands_1.account_command, api_1.api_command]) {
|
|
48
48
|
program.addCommand(c.helpGroup(WORK));
|
|
49
49
|
}
|
|
50
50
|
for (const c of [auth_1.auth_command, profile_1.profile_command, team_1.team_command, skills_1.skills_command, install_1.install_command]) {
|
|
@@ -85,6 +85,7 @@ Work commands (JSON out; exit 0 done, 1 failed, 2 usage, 3 outcome unknown):
|
|
|
85
85
|
${config_1.PROGRAM_NAME} sequence start 123 --expect-contacts 40
|
|
86
86
|
${config_1.PROGRAM_NAME} contact opt-out --contact-id 456
|
|
87
87
|
${config_1.PROGRAM_NAME} inbox list --contact-id 456
|
|
88
|
+
${config_1.PROGRAM_NAME} account list --channel linkedin
|
|
88
89
|
Each command's --help lists its flags, its result and its error codes.
|
|
89
90
|
|
|
90
91
|
Raw API (agent/CI escape hatch) — docs: https://docs.reply.io/api-reference/introduction
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,yCAA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Property(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handle_account_list = void 0;
|
|
4
|
+
const errors_1 = require("../utils/errors");
|
|
5
|
+
const call_1 = require("./call");
|
|
6
|
+
const options_1 = require("./options");
|
|
7
|
+
const result_1 = require("./result");
|
|
8
|
+
const ACCOUNT_CHANNELS = ['email', 'linkedin'];
|
|
9
|
+
// Reply's words for an account's state, and the CLI's. A word not here is `other`; Reply's own word
|
|
10
|
+
// always goes beside it. A LinkedIn account at its daily limit is on and connected, so it is
|
|
11
|
+
// active: a send that meets the limit answers linkedin.limit_reached.
|
|
12
|
+
const EMAIL_STATUSES = { connected: 'active', disconnected: 'disconnected', unknown: 'other' };
|
|
13
|
+
const LINKEDIN_STATUSES = {
|
|
14
|
+
enabled: 'active', disabled: 'inactive', cookieInvalid: 'disconnected', dailyLimitReached: 'active',
|
|
15
|
+
};
|
|
16
|
+
const PAGE = 1000; // the most Reply gives in one page of email accounts
|
|
17
|
+
const MAX_PAGES = 20;
|
|
18
|
+
const text_or_null = (v) => (typeof v === 'string' && v.trim() !== '' ? v : null);
|
|
19
|
+
const positive_integer = (v) => (typeof v === 'number' && Number.isSafeInteger(v) && v > 0 ? v : null);
|
|
20
|
+
const account_of = (entry, channel, words, fields) => {
|
|
21
|
+
// Email account ids are 64-bit at Reply; any whole number a JSON number carries exactly is one.
|
|
22
|
+
if (!(0, call_1.is_object)(entry) || typeof entry.id !== 'number' || !Number.isSafeInteger(entry.id) || entry.id <= 0) {
|
|
23
|
+
throw new errors_1.Operation_error('reply.unavailable', 'Reply listed an account without a usable id.', { status: 200 });
|
|
24
|
+
}
|
|
25
|
+
const word = entry[fields.status];
|
|
26
|
+
return {
|
|
27
|
+
id: entry.id, channel,
|
|
28
|
+
name: text_or_null(entry[fields.name]),
|
|
29
|
+
address: text_or_null(entry[fields.address]),
|
|
30
|
+
// In a team that shares its accounts, Reply lists teammates' accounts too; this says whose each one is.
|
|
31
|
+
owner_user_id: positive_integer(entry.ownerUserId),
|
|
32
|
+
status: typeof word === 'string' && Object.prototype.hasOwnProperty.call(words, word) ? words[word] : 'other',
|
|
33
|
+
reply_status: typeof word === 'string' ? word : null,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
// Every page, to the end: a list cut short would leave out an account a send could go from.
|
|
37
|
+
const email_accounts = async (s) => {
|
|
38
|
+
const accounts = [];
|
|
39
|
+
for (let n = 0; n < MAX_PAGES; n++) {
|
|
40
|
+
const a = await (0, call_1.call_reply)(s, 'GET', `/v3/email-accounts?top=${PAGE}&skip=${n * PAGE}`, 'read');
|
|
41
|
+
if (a.status !== 200) {
|
|
42
|
+
throw (0, call_1.refusal)(a, 'read');
|
|
43
|
+
}
|
|
44
|
+
const page = (0, call_1.read_page)(a);
|
|
45
|
+
accounts.push(...page.items.map(e => account_of(e, 'email', EMAIL_STATUSES, { name: 'senderName', address: 'email', status: 'connectionStatus' })));
|
|
46
|
+
if (!page.has_more) {
|
|
47
|
+
return accounts;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
throw new errors_1.Operation_error('account.list_incomplete', `Reply's list of email accounts did not end within ${MAX_PAGES * PAGE}.`, { status: 200 });
|
|
51
|
+
};
|
|
52
|
+
// Reply gives every LinkedIn account in one answer, with no paging.
|
|
53
|
+
const linkedin_accounts = async (s) => {
|
|
54
|
+
const a = await (0, call_1.call_reply)(s, 'GET', '/v3/linkedin-accounts', 'read');
|
|
55
|
+
if (a.status !== 200) {
|
|
56
|
+
throw (0, call_1.refusal)(a, 'read');
|
|
57
|
+
}
|
|
58
|
+
if (!Array.isArray(a.data)) {
|
|
59
|
+
throw (0, call_1.unreadable)(a, 'read');
|
|
60
|
+
}
|
|
61
|
+
return a.data.map(e => account_of(e, 'linkedin', LINKEDIN_STATUSES, { name: 'name', address: 'profileUrl', status: 'status' }));
|
|
62
|
+
};
|
|
63
|
+
const handle_account_list = async (opts, ctx, g) => {
|
|
64
|
+
const channel = (0, options_1.parse_choice)(opts.channel, '--channel', ACCOUNT_CHANNELS);
|
|
65
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
66
|
+
const items = [
|
|
67
|
+
...(channel === 'linkedin' ? [] : await email_accounts(s)),
|
|
68
|
+
...(channel === 'email' ? [] : await linkedin_accounts(s)),
|
|
69
|
+
];
|
|
70
|
+
(0, result_1.print_result)({ items }, g);
|
|
71
|
+
};
|
|
72
|
+
exports.handle_account_list = handle_account_list;
|
|
73
|
+
//# sourceMappingURL=accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/operations/accounts.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAChD,iCAA4G;AAC5G,uCAAwD;AACxD,qCAAsC;AAGtC,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,UAAU,CAAU,CAAC;AAQxD,oGAAoG;AACpG,6FAA6F;AAC7F,sEAAsE;AACtE,MAAM,cAAc,GAAmC,EAAC,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAC,CAAC;AAC7H,MAAM,iBAAiB,GAAmC;IACtD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,QAAQ;CACtG,CAAC;AAEF,MAAM,IAAI,GAAG,IAAI,CAAC,CAAU,qDAAqD;AACjF,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,MAAM,YAAY,GAAG,CAAC,CAAU,EAAgB,EAAE,CAAA,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAExG,MAAM,gBAAgB,GAAG,CAAC,CAAU,EAAgB,EAAE,CAAA,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CA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C;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,EAC1B,CAAC;QACG,MAAM,IAAA,iBAAU,EAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA,EAAE,CAAA,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;AAChI,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,KAAK,EAAC,IAAwB,EAAE,GAAgB,EAAE,CAAa,EAAgB,EAAE;IACzG,MAAM,OAAO,GAAG,IAAA,sBAAY,EAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAAC;IAC1E,MAAM,CAAC,GAAG,MAAM,IAAA,mBAAY,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG;QACV,GAAG,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,cAAc,CAAC,CAAC,CAAC,CAAC;QAC1D,GAAG,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,iBAAiB,CAAC,CAAC,CAAC,CAAC;KAC7D,CAAC;IACF,IAAA,qBAAY,EAAC,EAAC,KAAK,EAAC,EAAE,CAAC,CAAC,CAAC;AAC7B,CAAC,CAAC;AAEM,kDAAmB"}
|
|
@@ -3,4 +3,5 @@ declare const sequence_command: Command;
|
|
|
3
3
|
declare const contact_list_command: Command;
|
|
4
4
|
declare const contact_command: Command;
|
|
5
5
|
declare const inbox_command: Command;
|
|
6
|
-
|
|
6
|
+
declare const account_command: Command;
|
|
7
|
+
export { sequence_command, contact_list_command, contact_command, inbox_command, account_command };
|
|
@@ -1,30 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inbox_command = exports.contact_command = exports.contact_list_command = exports.sequence_command = void 0;
|
|
3
|
+
exports.account_command = exports.inbox_command = exports.contact_command = exports.contact_list_command = exports.sequence_command = void 0;
|
|
4
4
|
const commander_1 = require("commander");
|
|
5
5
|
const config_1 = require("../config");
|
|
6
6
|
const context_1 = require("../context");
|
|
7
7
|
const options_1 = require("./options");
|
|
8
8
|
const contact_input_1 = require("./contact-input");
|
|
9
9
|
const sequence_read_1 = require("./sequence-read");
|
|
10
|
+
const sequence_by_name_1 = require("./sequence-by-name");
|
|
10
11
|
const sequence_membership_1 = require("./sequence-membership");
|
|
11
12
|
const sequence_state_1 = require("./sequence-state");
|
|
12
13
|
const inbox_1 = require("./inbox");
|
|
14
|
+
const inbox_reply_1 = require("./inbox-reply");
|
|
13
15
|
const contact_list_1 = require("./contact-list");
|
|
14
16
|
const contact_1 = require("./contact");
|
|
17
|
+
const contact_record_1 = require("./contact-record");
|
|
18
|
+
const direct_send_1 = require("./direct-send");
|
|
19
|
+
const accounts_1 = require("./accounts");
|
|
15
20
|
const P = config_1.PROGRAM_NAME;
|
|
16
21
|
const COMMON_ERRORS = [
|
|
17
22
|
'access.denied', 'access.feature_unavailable', 'rate_limited', 'reply.unavailable', 'reply.refused', 'reply.invalid_request',
|
|
18
23
|
];
|
|
19
|
-
const
|
|
24
|
+
const SAFE_TO_REPEAT = 'a write may have happened; re-running is safe';
|
|
25
|
+
const errors_help = (codes, write, unknown_outcome) => '\nErrors (with --json, one line on stderr: {"error":{"code":…,"ids":…}}):\n'
|
|
20
26
|
+ [...codes, ...COMMON_ERRORS, ...(write ? ['outcome.unknown'] : [])].map(c => ` ${c}`).join('\n')
|
|
21
27
|
+ '\nExit codes: 0 done · 1 failed, main effect not done (partial effects are in "ids") · 2 usage, nothing sent'
|
|
22
|
-
+
|
|
23
|
-
const help = (examples, codes, write, extra = '') => `\nExamples:\n${examples.map(e => ` ${e}`).join('\n')}\n${extra ? `\n${extra}` : ''}${errors_help(codes, write)}`;
|
|
28
|
+
+ ` · 3 outcome unknown (${unknown_outcome})`;
|
|
29
|
+
const help = (examples, codes, write, extra = '', unknown_outcome = SAFE_TO_REPEAT) => `\nExamples:\n${examples.map(e => ` ${e}`).join('\n')}\n${extra ? `\n${extra}` : ''}${errors_help(codes, write, unknown_outcome)}`;
|
|
24
30
|
const ex = (command) => `${P} ${command}`;
|
|
25
31
|
// The contact on stdin: the form that keeps personal data off the argument list, so it leads.
|
|
26
32
|
const piped = (command, contact = '{"email":"ann@example.com","first_name":"Ann"}') => `echo '${contact}' | ${P} ${command} --contact -`;
|
|
27
|
-
const ALWAYS_IMPORTED = 'A contact given by email is always imported, so Reply needs a first name, even for one it already holds.\n'
|
|
33
|
+
const ALWAYS_IMPORTED = 'A contact given by email is always imported, so Reply needs a first name, even for one it already holds.\n'
|
|
34
|
+
+ 'One given only by LinkedIn URL is looked up first and imported only when Reply holds nobody under it.\n';
|
|
28
35
|
const run = (fn) => async function () {
|
|
29
36
|
await fn(this);
|
|
30
37
|
};
|
|
@@ -32,8 +39,31 @@ const ctx_of = (cmd) => {
|
|
|
32
39
|
const g = (0, options_1.read_op_globals)(cmd);
|
|
33
40
|
return { g, ctx: (0, context_1.build_context)({ profile: g.profile }) };
|
|
34
41
|
};
|
|
35
|
-
const sequence_command = new commander_1.Command('sequence')
|
|
42
|
+
const sequence_command = new commander_1.Command('sequence')
|
|
43
|
+
.description('Find or create a sequence by name, read it, put contacts in or take them out, pause or start it');
|
|
36
44
|
exports.sequence_command = sequence_command;
|
|
45
|
+
sequence_command.command('list')
|
|
46
|
+
.option('--name <stdin>', 'Only -: {name} as JSON on stdin')
|
|
47
|
+
.description('Every sequence whose name is this one, ignoring case, archived ones included')
|
|
48
|
+
.addHelpText('after', help([`echo '{"name":"Q4 outreach"}' | ${P} sequence list --name -`], ['sequence.list_incomplete'], false, 'Result: {"items":[{"id","name","status","is_archived","created_at"}]}, oldest first: Reply\'s status (new, active,\n'
|
|
49
|
+
+ 'paused), archive flag and creation time, each null when Reply gives none. The name is read from stdin only, so it\n'
|
|
50
|
+
+ 'never sits in the argument list. The list is read to its end; sequence.list_incomplete means it did not end within\n'
|
|
51
|
+
+ '20000 sequences whose names contain this one.\n'))
|
|
52
|
+
.action(run(async (cmd) => {
|
|
53
|
+
const { g, ctx } = ctx_of(cmd);
|
|
54
|
+
await (0, sequence_by_name_1.handle_sequence_list)(cmd.opts(), ctx, g);
|
|
55
|
+
}));
|
|
56
|
+
sequence_command.command('create')
|
|
57
|
+
.option('--name <stdin>', 'Only -: {name} as JSON on stdin')
|
|
58
|
+
.description('Make a draft sequence of this name, holding nobody, with one task step to replace before it is started')
|
|
59
|
+
.addHelpText('after', help([`echo '{"name":"Q4 outreach"}' | ${P} sequence create --name -`], [], true, 'Result: {"sequence_id","steps_added","status","is_archived"}: status and is_archived are Reply\'s for the new sequence.\n'
|
|
60
|
+
+ 'The name is read from stdin only, so it never sits in the argument list. Reply allows two sequences of one name and\n'
|
|
61
|
+
+ 'this command does not look first: run `sequence list --name -` before it. The one step is a task for the owner, which\n'
|
|
62
|
+
+ 'reaches nobody; Reply gives the draft the account\'s default schedule and mailbox. The draft is never started here.\n', 'the sequence may have been made; running the command again may make a second one, so look it up by name first'))
|
|
63
|
+
.action(run(async (cmd) => {
|
|
64
|
+
const { g, ctx } = ctx_of(cmd);
|
|
65
|
+
await (0, sequence_by_name_1.handle_sequence_create)(cmd.opts(), ctx, g);
|
|
66
|
+
}));
|
|
37
67
|
sequence_command.command('get')
|
|
38
68
|
.argument('<sequence-id>', 'Sequence id')
|
|
39
69
|
.description('The sequence as Reply holds it: settings, steps, state')
|
|
@@ -67,10 +97,11 @@ sequence_command.command('stats')
|
|
|
67
97
|
.argument('<sequence-id>', 'Sequence id'))
|
|
68
98
|
.option('--start-step <n>', 'Start at this step of the sequence (1 = first; the steps must form one chain)')
|
|
69
99
|
.option('--ignore-step-delay', 'Skip the delay of the step the contact starts at (Reply still sends within the sequence\'s schedule)')
|
|
70
|
-
.description('Put a contact into the sequence, creating the contact if Reply has nobody under the
|
|
100
|
+
.description('Put a contact into the sequence, creating the contact if Reply has nobody under the address')
|
|
71
101
|
.addHelpText('after', help([piped('sequence add-contact 123'), ex('sequence add-contact 123 --email ann@example.com --first-name Ann'),
|
|
72
102
|
ex('sequence add-contact 123 --contact-id 456 --start-step 2')], ['sequence.not_found', 'sequence.archived', 'sequence.has_no_steps', 'sequence.step_not_found', 'contact.not_found',
|
|
73
|
-
'contact.
|
|
103
|
+
'contact.not_unique', 'contact.opted_out', 'contact.invalid_email', 'contact.invalid_linkedin_url',
|
|
104
|
+
'account.contact_limit_reached'], true, 'Result: {"status":"added"|"already_in_sequence","sequence_id","contact_id","contact_created","sequence_active"}\n'
|
|
74
105
|
+ contact_input_1.CONTACT_HELP + ALWAYS_IMPORTED))
|
|
75
106
|
.action(run(async (cmd) => {
|
|
76
107
|
const { g, ctx } = ctx_of(cmd);
|
|
@@ -79,8 +110,8 @@ sequence_command.command('stats')
|
|
|
79
110
|
(0, contact_input_1.add_contact_options)(sequence_command.command('remove-contact')
|
|
80
111
|
.argument('<sequence-id>', 'Sequence id'))
|
|
81
112
|
.description('Take a contact out of the sequence; their history stays. Never creates a contact')
|
|
82
|
-
.addHelpText('after', help([piped('sequence remove-contact 123', '{"email":"ann@example.com"}'), ex('sequence remove-contact 123 --contact-id 456')], ['sequence.not_found', 'contact.not_unique'
|
|
83
|
-
+ contact_input_1.CONTACT_HELP + 'A contact given by email is only looked up, never imported, so no first name is needed.\n'))
|
|
113
|
+
.addHelpText('after', help([piped('sequence remove-contact 123', '{"email":"ann@example.com"}'), ex('sequence remove-contact 123 --contact-id 456')], ['sequence.not_found', 'contact.not_unique'], true, 'Result: {"status":"removed"|"not_in_sequence","sequence_id","contact_id"}\n'
|
|
114
|
+
+ contact_input_1.CONTACT_HELP + 'A contact given by email or LinkedIn URL is only looked up, never imported, so no first name is needed.\n'))
|
|
84
115
|
.action(run(async (cmd) => {
|
|
85
116
|
const { g, ctx } = ctx_of(cmd);
|
|
86
117
|
await (0, sequence_membership_1.handle_sequence_remove_contact)(cmd.args[0], cmd.opts(), ctx, g);
|
|
@@ -108,33 +139,136 @@ exports.contact_list_command = contact_list_command;
|
|
|
108
139
|
(0, contact_input_1.add_contact_options)(contact_list_command.command('add-contact')
|
|
109
140
|
.argument('<list-id>', 'Contact list id'))
|
|
110
141
|
.option('--refuse-opted-out', 'Refuse a contact Reply holds as opted out (a list may otherwise hold them)')
|
|
111
|
-
.description('Put a contact on the list, creating the contact if Reply has nobody under the
|
|
112
|
-
.addHelpText('after', help([piped('contact-list add-contact 77'), ex('contact-list add-contact 77 --contact-id 456 --refuse-opted-out')], ['contact-list.not_found', 'contact.not_found', 'contact.
|
|
142
|
+
.description('Put a contact on the list, creating the contact if Reply has nobody under the address')
|
|
143
|
+
.addHelpText('after', help([piped('contact-list add-contact 77'), ex('contact-list add-contact 77 --contact-id 456 --refuse-opted-out')], ['contact-list.not_found', 'contact.not_found', 'contact.not_unique', 'contact.opted_out', 'contact.invalid_email',
|
|
144
|
+
'contact.invalid_linkedin_url', 'account.contact_limit_reached'], true, 'Result: {"status":"added","list_id","contact_id","contact_created"}\n' + contact_input_1.CONTACT_HELP + ALWAYS_IMPORTED))
|
|
113
145
|
.action(run(async (cmd) => {
|
|
114
146
|
const { g, ctx } = ctx_of(cmd);
|
|
115
147
|
await (0, contact_list_1.handle_contact_list_add_contact)(cmd.args[0], cmd.opts(), ctx, g);
|
|
116
148
|
}));
|
|
117
|
-
const contact_command = new commander_1.Command('contact').description('
|
|
149
|
+
const contact_command = new commander_1.Command('contact').description('Find a contact, read it, change or delete it, opt it out, or send to it outside a sequence');
|
|
118
150
|
exports.contact_command = contact_command;
|
|
151
|
+
contact_command.command('find')
|
|
152
|
+
.option('--contact <stdin>', 'Only -: {email} or {linkedin_url} as JSON on stdin')
|
|
153
|
+
.description('The id of the contact Reply holds under an email or a LinkedIn URL. Never creates a contact')
|
|
154
|
+
.addHelpText('after', help([`echo '{"email":"ann@example.com"}' | ${P} contact find --contact -`,
|
|
155
|
+
`echo '{"linkedin_url":"https://www.linkedin.com/in/ann-example"}' | ${P} contact find --contact -`], ['contact.not_unique'], false, 'Result: {"contact_id"}: null when Reply holds nobody under the address.\n'
|
|
156
|
+
+ 'The address is read from stdin only, so it never sits in the argument list. An email matches ignoring case. A\n'
|
|
157
|
+
+ 'LinkedIn URL is matched by its lowercased slug: on linkedin.com the path\'s case does not count, nor the scheme\'s or\n'
|
|
158
|
+
+ 'host\'s, a default port, one trailing slash or a fragment, while www and the query do; Reply is asked for it in that\n'
|
|
159
|
+
+ 'form first, then as given. contact.not_unique means Reply holds more than one contact under the address.\n'))
|
|
160
|
+
.action(run(async (cmd) => {
|
|
161
|
+
const { g, ctx } = ctx_of(cmd);
|
|
162
|
+
await (0, contact_record_1.handle_contact_find)(cmd.opts(), ctx, g);
|
|
163
|
+
}));
|
|
164
|
+
contact_command.command('get')
|
|
165
|
+
.argument('<contact-id>', 'Contact id')
|
|
166
|
+
.description('The contact as Reply holds it: fields, owner, opt-out, custom fields')
|
|
167
|
+
.addHelpText('after', help([ex('contact get 456')], ['contact.not_found'], false))
|
|
168
|
+
.action(run(async (cmd) => {
|
|
169
|
+
const { g, ctx } = ctx_of(cmd);
|
|
170
|
+
await (0, contact_record_1.handle_contact_get)(cmd.args[0], ctx, g);
|
|
171
|
+
}));
|
|
172
|
+
contact_command.command('update')
|
|
173
|
+
.argument('<contact-id>', 'Contact id')
|
|
174
|
+
.option('--fields <stdin>', 'Only -: the fields to change as JSON on stdin')
|
|
175
|
+
.description('Change some of a contact\'s fields and custom fields; the rest stay as they are')
|
|
176
|
+
.addHelpText('after', help([`echo '{"title":"CTO","company":"Acme"}' | ${P} contact update 456 --fields -`,
|
|
177
|
+
`echo '{"last_name":null,"custom_fields":[{"name":"leadSource","value":"Event"}]}' | ${P} contact update 456 --fields -`], ['contact.not_found', 'contact.field_not_found'], true, 'Result: {"status":"updated","contact_id"}\n'
|
|
178
|
+
+ 'Fields: {first_name, last_name, company, title, linkedin_url, custom_fields: [{name, value}]}; a field left out stays as\n'
|
|
179
|
+
+ 'it is, and null clears one. They are read from stdin only, so no value ever sits in the argument list. The CLI stores\n'
|
|
180
|
+
+ 'a LinkedIn URL by its lowercased slug, the form contacts are looked up by. A custom field is named as the account\n'
|
|
181
|
+
+ 'names it (ignoring case); a name the account has none of is contact.field_not_found, and then nothing is changed.\n'))
|
|
182
|
+
.action(run(async (cmd) => {
|
|
183
|
+
const { g, ctx } = ctx_of(cmd);
|
|
184
|
+
await (0, contact_record_1.handle_contact_update)(cmd.args[0], cmd.opts(), ctx, g);
|
|
185
|
+
}));
|
|
186
|
+
contact_command.command('delete')
|
|
187
|
+
.argument('<contact-id>', 'Contact id')
|
|
188
|
+
.description('Delete a contact from the account, with its history at Reply')
|
|
189
|
+
.addHelpText('after', help([ex('contact delete 456')], ['contact.not_found'], true, 'Result: {"status":"deleted","contact_id"}\n'
|
|
190
|
+
+ 'After exit 3 the contact may already be gone: running the command again is safe, and then answers contact.not_found.\n'))
|
|
191
|
+
.action(run(async (cmd) => {
|
|
192
|
+
const { g, ctx } = ctx_of(cmd);
|
|
193
|
+
await (0, contact_record_1.handle_contact_delete)(cmd.args[0], ctx, g);
|
|
194
|
+
}));
|
|
119
195
|
(0, contact_input_1.add_contact_options)(contact_command.command('opt-out'))
|
|
120
|
-
.description('Mark the contact as opted out at Reply, creating them only if Reply has nobody under the
|
|
121
|
-
.addHelpText('after', help([piped('contact opt-out'), ex('contact opt-out --contact-id 456')], ['contact.not_found', 'contact.not_unique', 'contact.
|
|
122
|
-
+ 'A contact given by email is imported only when Reply holds nobody under the address; only then does
|
|
196
|
+
.description('Mark the contact as opted out at Reply, creating them only if Reply has nobody under the address')
|
|
197
|
+
.addHelpText('after', help([piped('contact opt-out'), ex('contact opt-out --contact-id 456')], ['contact.not_found', 'contact.not_unique', 'contact.invalid_email', 'contact.invalid_linkedin_url', 'account.contact_limit_reached'], true, 'Result: {"status":"opted_out","contact_id","contact_created"}\n' + contact_input_1.CONTACT_HELP
|
|
198
|
+
+ 'A contact given by email or LinkedIn URL is imported only when Reply holds nobody under the address; only then does\n'
|
|
199
|
+
+ 'Reply need a first name.\n'))
|
|
123
200
|
.action(run(async (cmd) => {
|
|
124
201
|
const { g, ctx } = ctx_of(cmd);
|
|
125
202
|
await (0, contact_1.handle_contact_opt_out)(cmd.opts(), ctx, g);
|
|
126
203
|
}));
|
|
127
|
-
const
|
|
204
|
+
const SEND_TWICE = (what) => `the ${what} may have been sent; running the command again may send it twice`;
|
|
205
|
+
contact_command.command('send-email')
|
|
206
|
+
.option('--contact-id <id>', 'The contact by its Reply id')
|
|
207
|
+
.option('--email-account-id <id>', 'The mailbox to send from (see `account list`)')
|
|
208
|
+
.option('--message <stdin>', 'Only -: the email {subject, body} as JSON on stdin')
|
|
209
|
+
.description('Send one email to a contact now, outside any sequence, from the mailbox you name')
|
|
210
|
+
.addHelpText('after', help([`echo '{"subject":"Quick question","body":"<p>Hi Ann, does Tuesday work?</p>"}' | ${P} contact send-email --contact-id 456 --email-account-id 12 --message -`], ['contact.not_found', 'email_account.not_found', 'contact.blacklisted'], true, 'Result: {"status":"sent","contact_id","message_id","sent_at","reply_status"}: sent means Reply accepted the email, and\n'
|
|
211
|
+
+ 'reply_status is Reply\'s own word for it (new or sent). message_id is Reply\'s messageId, null when it gives none.\n'
|
|
212
|
+
+ 'Reply\'s answer carries no time, so sent_at is always null; the CLI adds none of its own.\n'
|
|
213
|
+
+ 'The email is read from stdin only, so its text never sits in the argument list. The body is HTML. Reply sends a\n'
|
|
214
|
+
+ 'direct email at once, outside the mailbox\'s daily limit and sending delay.\n', SEND_TWICE('email')))
|
|
215
|
+
.action(run(async (cmd) => {
|
|
216
|
+
const { g, ctx } = ctx_of(cmd);
|
|
217
|
+
await (0, direct_send_1.handle_direct_send)('send-email', cmd.opts(), ctx, g);
|
|
218
|
+
}));
|
|
219
|
+
// The four LinkedIn sends share their flags, their first codes and the shape of their result.
|
|
220
|
+
const LINKEDIN_SEND_CODES = [
|
|
221
|
+
'contact.not_found', 'contact.no_linkedin_profile', 'linkedin.account_not_found', 'linkedin.feature_disabled',
|
|
222
|
+
'linkedin.account_inactive', 'linkedin.invalid_cookie',
|
|
223
|
+
];
|
|
224
|
+
const LINKEDIN_SENT = '"contact_id","activity_id","sent_at"}:\n'
|
|
225
|
+
+ 'activity_id and sent_at are Reply\'s linkedInActivityId and sentAtUtc as Reply gives them, each null when it gives\n'
|
|
226
|
+
+ 'none; the CLI adds no time of its own.\n';
|
|
227
|
+
const VARIABLES = (where) => `Reply reads {{…}} in the ${where} as its template variables; one it cannot fill is linkedin.missing_variables.\n`;
|
|
228
|
+
const LINKEDIN_EXAMPLE = '--contact-id 456 --linkedin-account-id 34';
|
|
229
|
+
const linkedin_send = (name, description, message, examples, codes, extra, what) => {
|
|
230
|
+
contact_command.command(name)
|
|
231
|
+
.option('--contact-id <id>', 'The contact by its Reply id')
|
|
232
|
+
.option('--linkedin-account-id <id>', 'The LinkedIn account to send from (see `account list`)')
|
|
233
|
+
.option('--message <stdin>', `Only -: the ${message} as JSON on stdin`)
|
|
234
|
+
.description(description)
|
|
235
|
+
.addHelpText('after', help(examples, [...LINKEDIN_SEND_CODES, ...codes], true, extra, SEND_TWICE(what)))
|
|
236
|
+
.action(run(async (cmd) => {
|
|
237
|
+
const { g, ctx } = ctx_of(cmd);
|
|
238
|
+
await (0, direct_send_1.handle_direct_send)(name, cmd.opts(), ctx, g);
|
|
239
|
+
}));
|
|
240
|
+
};
|
|
241
|
+
linkedin_send('linkedin-connect', 'Invite a contact to connect on LinkedIn, with or without a note', 'note {note}', [`echo '{"note":"Hi Ann, we met at the meetup."}' | ${P} contact linkedin-connect ${LINKEDIN_EXAMPLE} --message -`,
|
|
242
|
+
ex(`contact linkedin-connect ${LINKEDIN_EXAMPLE}`)], ['linkedin.not_connected', 'linkedin.limit_reached', 'linkedin.message_too_long', 'linkedin.missing_variables'], 'Result: {"status":"sent"|"already_connected",' + LINKEDIN_SENT
|
|
243
|
+
+ 'already_connected means the contact is already a connection: nothing is sent, and activity_id and sent_at are null.\n'
|
|
244
|
+
+ 'The note is read from stdin only, so its text never sits in the argument list; without --message the invitation\n'
|
|
245
|
+
+ 'carries no note. Reply publishes no limit for a note, and one it finds too long is linkedin.message_too_long.\n'
|
|
246
|
+
+ VARIABLES('note'), 'invitation');
|
|
247
|
+
linkedin_send('linkedin-message', 'Send a LinkedIn message to a contact the account is connected with', 'message {body}', [`echo '{"body":"Thanks for connecting, Ann."}' | ${P} contact linkedin-message ${LINKEDIN_EXAMPLE} --message -`], ['linkedin.not_connected', 'linkedin.limit_reached', 'linkedin.message_too_long', 'linkedin.missing_variables'], 'Result: {"status":"sent",' + LINKEDIN_SENT
|
|
248
|
+
+ 'The message is read from stdin only, so its text never sits in the argument list. Reply takes a body of at most\n'
|
|
249
|
+
+ '8000 characters.\n' + VARIABLES('body'), 'message');
|
|
250
|
+
linkedin_send('linkedin-inmail', 'Send a LinkedIn InMail, which reaches a contact the account is not connected with (needs Sales Navigator and InMail credits)', 'InMail {subject, body}', [`echo '{"subject":"Quick question","body":"Hi Ann, does Tuesday work?"}' | ${P} contact linkedin-inmail ${LINKEDIN_EXAMPLE} --message -`], ['linkedin.limit_reached', 'linkedin.message_too_long', 'linkedin.missing_variables', 'linkedin.sales_navigator_required',
|
|
251
|
+
'linkedin.sales_navigator_disconnected', 'linkedin.no_inmail_credits'], 'Result: {"status":"sent",' + LINKEDIN_SENT
|
|
252
|
+
+ 'The InMail is read from stdin only, so its text never sits in the argument list. Reply takes a subject of at most\n'
|
|
253
|
+
+ '200 characters and a body of at most 1900.\n' + VARIABLES('text'), 'InMail');
|
|
254
|
+
linkedin_send('linkedin-voice', 'Send a LinkedIn voice message that Reply speaks from a script in the account\'s voice', 'script {script}', [`echo '{"script":"Hi Ann, a quick hello about Tuesday."}' | ${P} contact linkedin-voice ${LINKEDIN_EXAMPLE} --message -`], ['linkedin.not_connected', 'linkedin.limit_reached', 'linkedin.missing_variables', 'linkedin.voice_profile_missing',
|
|
255
|
+
'linkedin.voice_too_long'], 'Result: {"status":"sent",' + LINKEDIN_SENT
|
|
256
|
+
+ 'The script is read from stdin only, so its text never sits in the argument list. Reply takes at most 1000 characters\n'
|
|
257
|
+
+ 'and speaks them with the LinkedIn account\'s voice profile; a recorded message cannot be sent here.\n' + VARIABLES('script'), 'voice message');
|
|
258
|
+
const inbox_command = new commander_1.Command('inbox').description('Read inbox threads, reply in them, file them under a category, mark them read or unread');
|
|
128
259
|
exports.inbox_command = inbox_command;
|
|
129
260
|
inbox_command.command('list')
|
|
130
261
|
.option('--contact-id <id>', 'Threads with this contact')
|
|
131
262
|
.option('--sequence-id <id>', 'Threads of this sequence')
|
|
132
263
|
.option('--source <source>', 'inbox | sent | unread | ai-draft (Reply\'s default: inbox)')
|
|
264
|
+
.option('--channel <channel>', 'email | linkedin: only threads on this channel')
|
|
265
|
+
.option('--category-id <id>', 'Only threads filed under this inbox category (see `inbox categories`)')
|
|
133
266
|
.option('--since <iso>', 'Only threads that moved at or after this moment')
|
|
134
267
|
.option('--limit <n>', 'Threads per page, 1-100 (default 20)')
|
|
135
268
|
.option('--offset <n>', 'Threads to skip (default 0)')
|
|
136
269
|
.description('One page of inbox threads, by contact or by sequence')
|
|
137
|
-
.addHelpText('after', help([ex('inbox list --contact-id 456'), ex('inbox list --sequence-id 123 --source unread --since 2026-10-01T00:00:00Z')
|
|
270
|
+
.addHelpText('after', help([ex('inbox list --contact-id 456'), ex('inbox list --sequence-id 123 --source unread --since 2026-10-01T00:00:00Z'),
|
|
271
|
+
ex('inbox list --sequence-id 123 --channel linkedin --category-id 7')], [], false))
|
|
138
272
|
.action(run(async (cmd) => {
|
|
139
273
|
const { g, ctx } = ctx_of(cmd);
|
|
140
274
|
await (0, inbox_1.handle_inbox_list)(cmd.opts(), ctx, g);
|
|
@@ -150,4 +284,69 @@ inbox_command.command('get')
|
|
|
150
284
|
const { g, ctx } = ctx_of(cmd);
|
|
151
285
|
await (0, inbox_1.handle_inbox_get)(cmd.args[0], cmd.opts(), ctx, g);
|
|
152
286
|
}));
|
|
287
|
+
inbox_command.command('reply')
|
|
288
|
+
.argument('<thread-id>', 'Inbox thread id')
|
|
289
|
+
.option('--message <stdin>', 'Only -: the message {body, reply_to_message_id} as JSON on stdin')
|
|
290
|
+
.description('Reply to the contact in an existing thread, on the thread\'s own channel')
|
|
291
|
+
.addHelpText('after', help([`echo '{"body":"Thanks, Tuesday works."}' | ${P} inbox reply 9876 --message -`,
|
|
292
|
+
`echo '{"body":"Thanks!","reply_to_message_id":"<abc@example.com>"}' | ${P} inbox reply 9876 --message -`], ['inbox.thread_not_found', 'inbox.channel_mismatch', 'contact.opted_out', 'inbox.send_failed'], true, 'Result: {"status":"sent","thread_id","channel":"email"|"linkedin","message_id","sent_at"}: Reply\'s messageId and date,\n'
|
|
293
|
+
+ 'each null when Reply gives none.\n'
|
|
294
|
+
+ 'The message is read from stdin only, so its text never sits in the argument list. The reply goes to the thread\'s\n'
|
|
295
|
+
+ 'contact from the account that owns the thread; no other recipient can be named. reply_to_message_id (email only)\n'
|
|
296
|
+
+ 'answers one message of the thread; without it Reply answers the latest. inbox.send_failed means Reply could not\n'
|
|
297
|
+
+ 'deliver it: "details.status_code" is Reply\'s reason (e.g. linkedInSendingLimitExceeded), null when it gave none.\n', 'the reply may have been sent; running the command again may send it twice, so read the thread first'))
|
|
298
|
+
.action(run(async (cmd) => {
|
|
299
|
+
const { g, ctx } = ctx_of(cmd);
|
|
300
|
+
await (0, inbox_reply_1.handle_inbox_reply)(cmd.args[0], cmd.opts(), ctx, g);
|
|
301
|
+
}));
|
|
302
|
+
inbox_command.command('categories')
|
|
303
|
+
.description('The inbox categories a thread can be filed under, Reply\'s reserved ones included')
|
|
304
|
+
.addHelpText('after', help([ex('inbox categories')], [], false, 'Result: {"items"}: Reply\'s categories as it gives them (id, name, color, isReserved, unreadThreadsCount).\n'))
|
|
305
|
+
.action(run(async (cmd) => {
|
|
306
|
+
const { g, ctx } = ctx_of(cmd);
|
|
307
|
+
await (0, inbox_1.handle_inbox_categories)(ctx, g);
|
|
308
|
+
}));
|
|
309
|
+
inbox_command.command('categorize')
|
|
310
|
+
.argument('<thread-id>', 'Inbox thread id')
|
|
311
|
+
.option('--category-id <id>', 'File the thread under this category (see `inbox categories`)')
|
|
312
|
+
.option('--clear', 'Take the thread out of its category')
|
|
313
|
+
.description('File a thread under one inbox category, or clear its category (a thread is in at most one)')
|
|
314
|
+
.addHelpText('after', help([ex('inbox categorize 9876 --category-id 7'), ex('inbox categorize 9876 --clear')], ['inbox.thread_not_found', 'inbox.category_not_found'], true, 'Result: {"status":"categorized"|"cleared","thread_id","category_id"}; category_id is null after --clear.\n'))
|
|
315
|
+
.action(run(async (cmd) => {
|
|
316
|
+
const { g, ctx } = ctx_of(cmd);
|
|
317
|
+
await (0, inbox_1.handle_inbox_categorize)(cmd.args[0], cmd.opts(), ctx, g);
|
|
318
|
+
}));
|
|
319
|
+
inbox_command.command('mark-read')
|
|
320
|
+
.argument('<thread-id>', 'Inbox thread id')
|
|
321
|
+
.description('Mark a thread as read (one that is already read stays read)')
|
|
322
|
+
.addHelpText('after', help([ex('inbox mark-read 9876')], ['inbox.thread_not_found'], true, 'Result: {"status":"read","thread_id"}\n'))
|
|
323
|
+
.action(run(async (cmd) => {
|
|
324
|
+
const { g, ctx } = ctx_of(cmd);
|
|
325
|
+
await (0, inbox_1.handle_inbox_mark_read)(cmd.args[0], ctx, g);
|
|
326
|
+
}));
|
|
327
|
+
inbox_command.command('mark-unread')
|
|
328
|
+
.argument('<thread-id>', 'Inbox thread id')
|
|
329
|
+
.description('Mark a thread as unread, so it needs attention again')
|
|
330
|
+
.addHelpText('after', help([ex('inbox mark-unread 9876')], ['inbox.thread_not_found'], true, 'Result: {"status":"unread","thread_id"}\n'))
|
|
331
|
+
.action(run(async (cmd) => {
|
|
332
|
+
const { g, ctx } = ctx_of(cmd);
|
|
333
|
+
await (0, inbox_1.handle_inbox_mark_unread)(cmd.args[0], ctx, g);
|
|
334
|
+
}));
|
|
335
|
+
const account_command = new commander_1.Command('account').description('List the email and LinkedIn accounts a send can go from');
|
|
336
|
+
exports.account_command = account_command;
|
|
337
|
+
account_command.command('list')
|
|
338
|
+
.option('--channel <channel>', 'email | linkedin: only the accounts of this channel')
|
|
339
|
+
.description('The email and LinkedIn accounts a send can go from, and the state of each')
|
|
340
|
+
.addHelpText('after', help([ex('account list'), ex('account list --channel linkedin')], ['account.list_incomplete'], false, 'Result: {"items":[{"id","channel","name","address","owner_user_id","status","reply_status"}]}, the email accounts\n'
|
|
341
|
+
+ 'first: status is active, inactive, disconnected or other, and reply_status is Reply\'s own word for it. name is the\n'
|
|
342
|
+
+ 'sender name or the LinkedIn name, and address the mailbox\'s email or the LinkedIn profile URL. In a team that shares\n'
|
|
343
|
+
+ 'its accounts the list holds teammates\' accounts too, and owner_user_id is the Reply user whose each one is. Each is\n'
|
|
344
|
+
+ 'null when Reply gives none. A LinkedIn account at its daily limit is active: a send that meets the limit answers\n'
|
|
345
|
+
+ 'linkedin.limit_reached. Every page is read; account.list_incomplete means the email accounts did not end within 20000.\n'
|
|
346
|
+
+ 'Without --channel both lists are read, and one the account\'s plan or role does not include fails the whole command\n'
|
|
347
|
+
+ '(its reply_code says which); --channel reads one channel alone.\n'))
|
|
348
|
+
.action(run(async (cmd) => {
|
|
349
|
+
const { g, ctx } = ctx_of(cmd);
|
|
350
|
+
await (0, accounts_1.handle_account_list)(cmd.opts(), ctx, g);
|
|
351
|
+
}));
|
|
153
352
|
//# sourceMappingURL=commands.js.map
|