@mccaskie-labs/workbench-nudges 0.1.1 → 0.2.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 CHANGED
@@ -1,9 +1,15 @@
1
1
  # @mccaskie-labs/workbench-nudges
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 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.
8
+
3
9
  ## 0.1.1
4
10
 
5
11
  - 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
12
 
7
13
  ## 0.1.0
8
14
 
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, `outreachRefresh` for workbench-social's contacts, and the Waiting for you list (`renderNudgeList`, `nudgeAction`; plain HTML; `wb-nudge-*`, `NUDGE_STYLES`; words in English, Tagalog and Taglish).
15
+ - 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 === "outreach-follow-up" ? " (npx workbench-social outreach init writes it)" : g === "quote-follow-up" ? " (npx workbench-nudges init writes it)" : ""}`)
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`. The supplier-no-reply rule needs `npx workbench-social outreach init` (its outreach-follow-up guide).");
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,4 +1,4 @@
1
- export { createNudges, outreachRefresh, type NudgeContext, type NudgeLink, type NudgeOwner, type NudgeRefresh, type Nudges, type NudgesAi, type NudgesClient, type NudgesMailer, type NudgesOptions, type NudgesPlans, type OutreachLike, type StartRequest, type TouchKind } from "./nudges.ts";
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";
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@
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, outreachRefresh } from "./nudges.js";
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";
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
- }
@@ -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 as the spec's example has it: quotes with no reply, and businesses that haven't answered our first message. */
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: "Asia/Manila";
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 the spec's two rules, and the quote-follow-up
3
- // reply guide (workbench/replies/) the first rule drafts with. The second
4
- // rule drafts with workbench-social's outreach-follow-up guide (`npx
5
- // workbench-social outreach init` writes it). The project edits them like its
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 as the spec's example has it: quotes with no reply, and businesses that haven't answered our first message. */
34
+ /** A starting workbench/nudges.json: quotes with no reply. */
37
35
  export const STARTER_NUDGES = {
38
36
  format: 1,
39
- time_zone: "Asia/Manila",
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, an outreach contact). Never a person's words. */
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mccaskie-labs/workbench-nudges",
3
- "version": "0.1.1",
3
+ "version": "0.2.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",