@mccaskie-labs/workbench-nudges 0.1.1 → 0.3.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/CHANGELOG.md +13 -1
- package/README.md +0 -1
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/nudges.d.ts +0 -17
- package/dist/nudges.js +0 -22
- package/dist/starters.d.ts +2 -11
- package/dist/starters.js +6 -14
- package/dist/types.d.ts +1 -1
- package/dist/words.d.ts +2 -0
- package/dist/words.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
# @mccaskie-labs/workbench-nudges
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Tools' words in the project's catalogue. `npx workbench-strings add --base en-AU --from @mccaskie-labs/workbench-links` copies a tool's English words (its new `CATALOGUE_WORDS`) into the base catalogue, keeping any the project already has, so they are translated and approved in Control with the site's own words. workbench-links, workbench-nudges and workbench-plans export `CATALOGUE_WORDS`.
|
|
8
|
+
|
|
9
|
+
## 0.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 33d9dde: The general building blocks stand on their own. workbench-config's component list no longer has availability, onboarding or outreach: a tool like those now comes as an add-on (docs/addons.md), and `workbench/addons.json` may say where each add-on comes from (`"from": { "<name>": "<organisation>/<repo>" }`), so Control's daily update copies it into `addons/<name>/`. workbench-nudges' starter has one rule, quotes with no reply, and its time zone starts as Australia/Sydney (set it from the country pack); `outreachRefresh` and `OutreachLike` are gone, so a project that follows up its own first messages writes its own rule, guide and refresh, as the nudges.what question's "First messages with no reply" answer says. Examples and samples use neutral names.
|
|
14
|
+
|
|
3
15
|
## 0.1.1
|
|
4
16
|
|
|
5
17
|
- Fix: the digest and due emails never went. Their Idempotency-Key held the owner's email address, which workbench-email refuses (`[A-Za-z0-9._:-]`) before calling the Gateway, so each tick claimed the day's digest, failed and released it. The key is now `nudges:` and a SHA-256 of the digest's key and the address, the same for every retry. Found by wb-probe's nudges.digest on staging.
|
|
6
18
|
|
|
7
19
|
## 0.1.0
|
|
8
20
|
|
|
9
|
-
- First version (`docs/capabilities/09-follow-up-nudges.md`): `createNudges` over the app's own database with `nudgesMigration` (service role only). `start()` sets a rule going for a subject (refused with `not_allowed`, writing nothing, when the account's plan lacks `nudges`); `touch()` stops it on the rule's `stops_on` events, starts it over on `restarts_on`, and moves it on when the owner sent the follow-up (`we_replied`); `snooze()`, `dismiss()`, `due()` with each draft, and a daily `cleanup()` (ended nudges after 90 days, drafts after 30 at most). `tick()`, from the app's cron every 15 minutes, claims due rows with a lease under `skip locked` so overlapping runs draft each once, loads the latest facts through the app's `refresh`, ends a nudge whose date has passed, drafts with the reply drafter (alternatives when the date was taken), and sends one digest email a day per account with a count and no names. Quiet hours move a step to their end; days are local days. `workbench/nudges.json` is checked by `checkNudgeConfig` and `npx workbench-nudges generate` (at most three steps a rule), with `init` and `migration` commands, the `quote-follow-up` starter guide,
|
|
21
|
+
- First version (`docs/capabilities/09-follow-up-nudges.md`): `createNudges` over the app's own database with `nudgesMigration` (service role only). `start()` sets a rule going for a subject (refused with `not_allowed`, writing nothing, when the account's plan lacks `nudges`); `touch()` stops it on the rule's `stops_on` events, starts it over on `restarts_on`, and moves it on when the owner sent the follow-up (`we_replied`); `snooze()`, `dismiss()`, `due()` with each draft, and a daily `cleanup()` (ended nudges after 90 days, drafts after 30 at most). `tick()`, from the app's cron every 15 minutes, claims due rows with a lease under `skip locked` so overlapping runs draft each once, loads the latest facts through the app's `refresh`, ends a nudge whose date has passed, drafts with the reply drafter (alternatives when the date was taken), and sends one digest email a day per account with a count and no names. Quiet hours move a step to their end; days are local days. `workbench/nudges.json` is checked by `checkNudgeConfig` and `npx workbench-nudges generate` (at most three steps a rule), with `init` and `migration` commands, the `quote-follow-up` starter guide, and the Waiting for you list (`renderNudgeList`, `nudgeAction`; plain HTML; `wb-nudge-*`, `NUDGE_STYLES`; words in English, Tagalog and Taglish).
|
package/README.md
CHANGED
|
@@ -42,7 +42,6 @@ ctx.waitUntil(nudges.tick())
|
|
|
42
42
|
- After the last step, a nudge left alone ends `ends_after` (7 days) later. A rule never has more than three steps.
|
|
43
43
|
- The digest: one email a day per account with something due, from `digest_at` (the end of the quiet hours, or 08:00), with a count and a link, never a customer's name. `email_owner: "each"` emails as each comes due; `"none"` uses only the list.
|
|
44
44
|
- `cleanup()` once a day: ended nudges after 90 days, drafts after 30 at most (and as soon as their nudge moves on or ends).
|
|
45
|
-
- Outreach contacts (workbench-social): start `supplier-no-reply` with subject `{ type: 'outreach_contact', id }` when an opener is logged, and use `outreachRefresh(outreach)` as the refresh for that subject type: a contact that replied ends its nudge.
|
|
46
45
|
|
|
47
46
|
## The Waiting for you list
|
|
48
47
|
|
package/dist/cli.js
CHANGED
|
@@ -64,7 +64,7 @@ export function readNudges(dir) {
|
|
|
64
64
|
const missing = guidesOf(config).filter((g) => !existsSync(join(dir, "workbench/replies", `${g}.json`)));
|
|
65
65
|
if (missing.length) {
|
|
66
66
|
throw new Error(missing
|
|
67
|
-
.map((g) => `${NUDGES_FILE}: the reply guide ${g} isn't in workbench/replies/${g === "
|
|
67
|
+
.map((g) => `${NUDGES_FILE}: the reply guide ${g} isn't in workbench/replies/${g === "quote-follow-up" ? " (npx workbench-nudges init writes it)" : ""}`)
|
|
68
68
|
.join("\n"));
|
|
69
69
|
}
|
|
70
70
|
return config;
|
|
@@ -95,7 +95,7 @@ export function run(argv, log = console.log, err = console.error) {
|
|
|
95
95
|
writeFileSync(at, text);
|
|
96
96
|
log(`wrote ${path}`);
|
|
97
97
|
}
|
|
98
|
-
log("Now set time_zone in workbench/nudges.json to the country pack's, keep the rules the client wants, and run `npx workbench-ai replies generate` and `npx workbench-nudges generate`.
|
|
98
|
+
log("Now set time_zone in workbench/nudges.json to the country pack's, keep the rules the client wants, and run `npx workbench-ai replies generate` and `npx workbench-nudges generate`.");
|
|
99
99
|
return 0;
|
|
100
100
|
}
|
|
101
101
|
if (command === "migration") {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { createNudges,
|
|
1
|
+
export { createNudges, type NudgeContext, type NudgeLink, type NudgeOwner, type NudgeRefresh, type Nudges, type NudgesAi, type NudgesClient, type NudgesMailer, type NudgesOptions, type NudgesPlans, type StartRequest, type TouchKind } from "./nudges.ts";
|
|
2
2
|
export { checkNudgeConfig, MAX_STEPS, nudgeProblems } from "./config.ts";
|
|
3
3
|
export { nudgesMigration } from "./migration.ts";
|
|
4
4
|
export { QUOTE_FOLLOW_UP_GUIDE, STARTER_NUDGES } from "./starters.ts";
|
|
5
5
|
export { nudgeAction, renderNudge, renderNudgeList, type ActionResult, type ListOptions, type Words } from "./ui.ts";
|
|
6
|
-
export { NUDGE_WORDS, NUDGE_WORD_KEYS, type NudgeWordKey } from "./words.ts";
|
|
6
|
+
export { CATALOGUE_WORDS, NUDGE_WORDS, NUDGE_WORD_KEYS, type NudgeWordKey } from "./words.ts";
|
|
7
7
|
export { NUDGE_STYLES } from "./styles.ts";
|
|
8
8
|
export { NudgesError, type NudgesErrorCode } from "./errors.ts";
|
|
9
9
|
export { NUDGE_STATUSES } from "./types.ts";
|
package/dist/index.js
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
// drafter (capability 4) when it comes due. A store in the app's own database
|
|
5
5
|
// (nudgesMigration), a rules file (workbench/nudges.json), and tick() from the
|
|
6
6
|
// app's cron every 15 minutes. Nudges never message the business's customer.
|
|
7
|
-
export { createNudges
|
|
7
|
+
export { createNudges } from "./nudges.js";
|
|
8
8
|
export { checkNudgeConfig, MAX_STEPS, nudgeProblems } from "./config.js";
|
|
9
9
|
export { nudgesMigration } from "./migration.js";
|
|
10
10
|
export { QUOTE_FOLLOW_UP_GUIDE, STARTER_NUDGES } from "./starters.js";
|
|
11
11
|
export { nudgeAction, renderNudge, renderNudgeList } from "./ui.js";
|
|
12
|
-
export { NUDGE_WORDS, NUDGE_WORD_KEYS } from "./words.js";
|
|
12
|
+
export { CATALOGUE_WORDS, NUDGE_WORDS, NUDGE_WORD_KEYS } from "./words.js";
|
|
13
13
|
export { NUDGE_STYLES } from "./styles.js";
|
|
14
14
|
export { NudgesError } from "./errors.js";
|
|
15
15
|
export { NUDGE_STATUSES } from "./types.js";
|
package/dist/nudges.d.ts
CHANGED
|
@@ -159,21 +159,4 @@ export interface Nudges {
|
|
|
159
159
|
*/
|
|
160
160
|
export declare function mailKey(key: string, email: string): Promise<string>;
|
|
161
161
|
export declare function createNudges(opts: NudgesOptions): Nudges;
|
|
162
|
-
/** What workbench-social's createOutreach(...) gives nudges: one contact. */
|
|
163
|
-
export interface OutreachLike {
|
|
164
|
-
get(contactId: string): Promise<{
|
|
165
|
-
status: string;
|
|
166
|
-
business: string | null;
|
|
167
|
-
detail: string | null;
|
|
168
|
-
contact_name: string | null;
|
|
169
|
-
} | null>;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* The refresh for outreach contacts (subject type `outreach_contact`, rule
|
|
173
|
-
* supplier-no-reply with workbench-social's outreach-follow-up guide): a
|
|
174
|
-
* contact still waiting on a reply (contacted) gets its business and detail
|
|
175
|
-
* as facts; one that replied, said no or said stop ends the nudge with its
|
|
176
|
-
* status. Compose it with the app's own refresh for other subjects.
|
|
177
|
-
*/
|
|
178
|
-
export declare function outreachRefresh(outreach: OutreachLike): (n: NudgeContext) => Promise<NudgeRefresh | null>;
|
|
179
162
|
export {};
|
package/dist/nudges.js
CHANGED
|
@@ -357,25 +357,3 @@ export function createNudges(opts) {
|
|
|
357
357
|
},
|
|
358
358
|
};
|
|
359
359
|
}
|
|
360
|
-
/**
|
|
361
|
-
* The refresh for outreach contacts (subject type `outreach_contact`, rule
|
|
362
|
-
* supplier-no-reply with workbench-social's outreach-follow-up guide): a
|
|
363
|
-
* contact still waiting on a reply (contacted) gets its business and detail
|
|
364
|
-
* as facts; one that replied, said no or said stop ends the nudge with its
|
|
365
|
-
* status. Compose it with the app's own refresh for other subjects.
|
|
366
|
-
*/
|
|
367
|
-
export function outreachRefresh(outreach) {
|
|
368
|
-
return async (n) => {
|
|
369
|
-
const c = await outreach.get(n.subject.id);
|
|
370
|
-
if (!c)
|
|
371
|
-
return null;
|
|
372
|
-
if (c.status !== "contacted")
|
|
373
|
-
return { stop: c.status === "do_not_contact" ? "do_not_contact" : c.status === "new" ? "subject_gone" : "they_replied" };
|
|
374
|
-
const facts = { business: c.business };
|
|
375
|
-
if (c.detail)
|
|
376
|
-
facts.detail = c.detail;
|
|
377
|
-
if (c.contact_name)
|
|
378
|
-
facts.contact_name = c.contact_name;
|
|
379
|
-
return { facts };
|
|
380
|
-
};
|
|
381
|
-
}
|
package/dist/starters.d.ts
CHANGED
|
@@ -38,10 +38,10 @@ export declare const QUOTE_FOLLOW_UP_GUIDE: {
|
|
|
38
38
|
readonly guide: readonly ["Write one short, warm follow-up to the quote we sent, which the customer hasn't answered.", "Greet them by customer_first_name if we have it.", "If available is yes, say the date is still free and ask if they have any questions about the quote.", "If available is no, say sorry that the date has just been taken and offer the alternatives.", "Put the link at the end if there is one."];
|
|
39
39
|
readonly never: readonly ["promise a discount", "confirm a booking", "ask for payment details", "pressure them or say the offer is about to expire"];
|
|
40
40
|
};
|
|
41
|
-
/** workbench/nudges.json
|
|
41
|
+
/** A starting workbench/nudges.json: quotes with no reply. */
|
|
42
42
|
export declare const STARTER_NUDGES: {
|
|
43
43
|
readonly format: 1;
|
|
44
|
-
readonly time_zone: "
|
|
44
|
+
readonly time_zone: "Australia/Sydney";
|
|
45
45
|
readonly quiet_hours: {
|
|
46
46
|
readonly from: "21:00";
|
|
47
47
|
readonly to: "08:00";
|
|
@@ -67,14 +67,5 @@ export declare const STARTER_NUDGES: {
|
|
|
67
67
|
};
|
|
68
68
|
readonly email_owner: "daily_digest";
|
|
69
69
|
};
|
|
70
|
-
readonly "supplier-no-reply": {
|
|
71
|
-
readonly starts_on: "opener_sent";
|
|
72
|
-
readonly stops_on: readonly ["they_replied", "do_not_contact"];
|
|
73
|
-
readonly steps: readonly [{
|
|
74
|
-
readonly after: "4d";
|
|
75
|
-
readonly guide: "outreach-follow-up";
|
|
76
|
-
}];
|
|
77
|
-
readonly email_owner: "none";
|
|
78
|
-
};
|
|
79
70
|
};
|
|
80
71
|
};
|
package/dist/starters.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// The starting files `npx workbench-nudges init` copies into a project:
|
|
2
|
-
// workbench/nudges.json with
|
|
3
|
-
// reply guide (workbench/replies/)
|
|
4
|
-
//
|
|
5
|
-
// workbench-
|
|
6
|
-
// own; `npx workbench-nudges generate` and `npx workbench-ai replies
|
|
7
|
-
// generate` check them.
|
|
2
|
+
// workbench/nudges.json with one rule (a quote with no reply), and the
|
|
3
|
+
// quote-follow-up reply guide (workbench/replies/) it drafts with. The project
|
|
4
|
+
// edits them like its own; `npx workbench-nudges generate` and `npx
|
|
5
|
+
// workbench-ai replies generate` check them.
|
|
8
6
|
/** A gentle follow-up to a quote that got no reply. The facts come from the app's refresh (capability 5's latest answer). */
|
|
9
7
|
export const QUOTE_FOLLOW_UP_GUIDE = {
|
|
10
8
|
format: 1,
|
|
@@ -33,10 +31,10 @@ export const QUOTE_FOLLOW_UP_GUIDE = {
|
|
|
33
31
|
],
|
|
34
32
|
never: ["promise a discount", "confirm a booking", "ask for payment details", "pressure them or say the offer is about to expire"],
|
|
35
33
|
};
|
|
36
|
-
/** workbench/nudges.json
|
|
34
|
+
/** A starting workbench/nudges.json: quotes with no reply. */
|
|
37
35
|
export const STARTER_NUDGES = {
|
|
38
36
|
format: 1,
|
|
39
|
-
time_zone: "
|
|
37
|
+
time_zone: "Australia/Sydney",
|
|
40
38
|
quiet_hours: { from: "21:00", to: "08:00" },
|
|
41
39
|
language: "en",
|
|
42
40
|
max_steps: 3,
|
|
@@ -51,11 +49,5 @@ export const STARTER_NUDGES = {
|
|
|
51
49
|
skip_if: { date_passed: true, date_unavailable: "offer_alternatives" },
|
|
52
50
|
email_owner: "daily_digest",
|
|
53
51
|
},
|
|
54
|
-
"supplier-no-reply": {
|
|
55
|
-
starts_on: "opener_sent",
|
|
56
|
-
stops_on: ["they_replied", "do_not_contact"],
|
|
57
|
-
steps: [{ after: "4d", guide: "outreach-follow-up" }],
|
|
58
|
-
email_owner: "none",
|
|
59
|
-
},
|
|
60
52
|
},
|
|
61
53
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type Lang = "en" | "tl" | "taglish";
|
|
2
|
-
/** What a nudge is about: a row in the app's own tables (an enquiry,
|
|
2
|
+
/** What a nudge is about: a row in the app's own tables (an enquiry, a lead). Never a person's words. */
|
|
3
3
|
export interface Subject {
|
|
4
4
|
type: string;
|
|
5
5
|
id: string;
|
package/dist/words.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export declare const NUDGE_WORD_KEYS: readonly ["list.title", "list.empty", "ste
|
|
|
2
2
|
export type NudgeWordKey = (typeof NUDGE_WORD_KEYS)[number];
|
|
3
3
|
/** The words by language, as `ui.wbnudge.<key>` would hold them. */
|
|
4
4
|
export declare const NUDGE_WORDS: Readonly<Record<"en" | "tl" | "taglish", Readonly<Record<NudgeWordKey, string>>>>;
|
|
5
|
+
/** The English, as the project's base catalogue holds it: `npx workbench-strings add --from @mccaskie-labs/workbench-nudges`. */
|
|
6
|
+
export declare const CATALOGUE_WORDS: Readonly<Record<string, string>>;
|
package/dist/words.js
CHANGED
|
@@ -119,3 +119,5 @@ const taglish = {
|
|
|
119
119
|
};
|
|
120
120
|
/** The words by language, as `ui.wbnudge.<key>` would hold them. */
|
|
121
121
|
export const NUDGE_WORDS = { en, tl, taglish };
|
|
122
|
+
/** The English, as the project's base catalogue holds it: `npx workbench-strings add --from @mccaskie-labs/workbench-nudges`. */
|
|
123
|
+
export const CATALOGUE_WORDS = Object.freeze(Object.fromEntries(Object.entries(en).map(([k, v]) => [`ui.wbnudge.${k}`, v])));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mccaskie-labs/workbench-nudges",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Follow-up nudges for Workbench apps: remind the business to follow up when a conversation goes quiet (\"no reply in 3 days\"), with the follow-up already drafted by the reply drafter when it comes due. One scan from the app's cron, quiet hours, at most three steps, and a daily email digest to the owner. Never messages the business's customer.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|