@vatio-ai/cli 0.137.0 → 0.139.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.
@@ -399,11 +399,12 @@ export class ApiClient extends HttpClient {
399
399
  return this.get(`/chats/${encode(chatId)}/turn`, { after, wait });
400
400
  }
401
401
 
402
- exportChats({ from, to = null, environment = null, channel = null, after = null }) {
402
+ exportChats({ from, to = null, environment = null, channel = null, campaign = null, after = null }) {
403
403
  const params = { from };
404
404
  if (to) params.to = to;
405
405
  if (environment) params.environment = environment;
406
406
  if (channel) params.channel = channel;
407
+ if (campaign) params.utm_campaign = campaign;
407
408
  if (after) params.after = after;
408
409
  return this.get("/chats/export", params);
409
410
  }
@@ -168,10 +168,12 @@ for reading them in bulk -- with a coding agent, say. Vatio redacts it before
168
168
  it leaves: names, emails, phone numbers and RUTs it knows are [FILTERED], and
169
169
  \`person\` stands for whoever it was without naming them. Anyone on the
170
170
  workspace's team can run it, a viewer too, and every call is in the
171
- workspace's activity. Dates are whole days; --to defaults to now.`;
171
+ workspace's activity. Dates are whole days; --to defaults to now. A web
172
+ conversation carries \`attribution\`, where the visit came from (landing page,
173
+ referrer, utm_* and ad click ids); --campaign NAME exports only that campaign's.`;
172
174
  }
173
175
 
174
- const EXPORT_USAGE = "vatio chat export --from DATE [--to DATE] [--team] [--channel NAME] [--out FILE]";
176
+ const EXPORT_USAGE = "vatio chat export --from DATE [--to DATE] [--team] [--channel NAME] [--campaign NAME] [--out FILE]";
175
177
 
176
178
  // One page at a time, written as it arrives: a month of a busy WhatsApp number
177
179
  // does not have to fit in memory to be read.
@@ -180,6 +182,7 @@ async function exportChats(config, args) {
180
182
  const from = takeValue(args, "--from");
181
183
  const to = takeValue(args, "--to");
182
184
  const channel = takeValue(args, "--channel");
185
+ const campaign = takeValue(args, "--campaign");
183
186
  const out = takeValue(args, "--out");
184
187
  const apiUrl = takeValue(args, "--api-url");
185
188
  const token = takeValue(args, "--token");
@@ -193,7 +196,7 @@ async function exportChats(config, args) {
193
196
  let chats = 0;
194
197
  let messages = 0;
195
198
  for (;;) {
196
- const page = await api.exportChats({ from, to, environment, channel, after });
199
+ const page = await api.exportChats({ from, to, environment, channel, campaign, after });
197
200
  const rows = Array.isArray(page.data) ? page.data : [];
198
201
  if (rows.length > 0) {
199
202
  const lines = `${rows.map((row) => JSON.stringify(row)).join("\n")}\n`;
@@ -53,17 +53,43 @@ function showWidget(answer, json) {
53
53
  export async function analytics(config, args) {
54
54
  const json = takeFlag(args, "--json");
55
55
  const days = takeValue(args, "--days");
56
- if (args.length) fail("Usage: vatio analytics [--days N] [--json]");
57
- const answer = await deployClient(config, config.resolveWorkspaceRequired()).get("/analytics", { days });
56
+ const campaign = takeValue(args, "--campaign");
57
+ if (args.length) fail("Usage: vatio analytics [--days N] [--campaign NAME] [--json]");
58
+ const answer = await deployClient(config, config.resolveWorkspaceRequired()).get("/analytics", { days, utm_campaign: campaign });
58
59
  if (json) return print(answer);
59
60
  const change = (block) => (block?.previous_total ? ` (${block.previous_total} the ${answer.days} days before)` : "");
60
- console.log(`Last ${answer.days} days, your customers:`);
61
+ console.log(`Last ${answer.days} days, your customers${campaign ? ` from the campaign ${campaign}` : ""}:`);
61
62
  console.log(` conversations ${answer.conversations?.total ?? 0}${change(answer.conversations)}`);
62
63
  console.log(` messages ${answer.messages?.total ?? 0}${change(answer.messages)}`);
63
64
  if (answer.saved_replies) console.log(` replies Vatio saved ${answer.saved_replies.total ?? 0}`);
64
65
  if (answer.after_hours) console.log(` conversations after hours ${answer.after_hours.after_hours ?? 0}`);
65
66
  if (answer.asked_team) console.log(` questions to the team ${answer.asked_team.questions ?? 0} (${answer.asked_team.answered ?? 0} answered)`);
66
67
  if (answer.flags) console.log(` reports ${answer.flags.opened ?? 0} opened, ${answer.flags.resolved ?? 0} resolved`);
68
+ printOrigins(answer.origins, answer.days);
69
+ }
70
+
71
+ const ORIGIN_LABELS = { utm_campaign: "campaign", utm_source: "source", utm_medium: "medium", landing_page: "landing page", referrer: "referrer" };
72
+
73
+ // Where the period's conversations came from: the biggest of each, against
74
+ // the period before, with how they went. `--json` has every row.
75
+ function printOrigins(origins, days) {
76
+ if (!origins?.attributed) return;
77
+ console.log(`\nWhere they came from (${origins.attributed} of ${origins.conversations} with a page, a referrer or a campaign):`);
78
+ for (const [key, label] of Object.entries(ORIGIN_LABELS)) {
79
+ const rows = (origins.dimensions?.[key]?.rows ?? []).filter((row) => row.value !== null).slice(0, 5);
80
+ if (!rows.length) continue;
81
+ console.log(` ${label}`);
82
+ for (const row of rows) {
83
+ const ratings = row.ratings ?? {};
84
+ const outcome = [
85
+ `${row.previous_conversations} the ${days} days before`,
86
+ ratings.good || ratings.neutral || ratings.bad ? `rated 👍 ${ratings.good} 😐 ${ratings.neutral} 👎 ${ratings.bad}` : null,
87
+ row.reported ? `${row.reported} reported` : null,
88
+ row.handed_off ? `${row.handed_off} answered by a person` : null
89
+ ].filter(Boolean).join(", ");
90
+ console.log(` ${String(row.conversations).padStart(5)} ${row.value} (${outcome})`);
91
+ }
92
+ }
67
93
  }
68
94
 
69
95
  const TESTERS_USAGE = "Usage: vatio testers [web|whatsapp|instagram] [--json]\n" +
@@ -16,7 +16,9 @@ function explain(error) {
16
16
  throw error;
17
17
  }
18
18
 
19
- const ROLES = ["viewer", "supervisor", "developer"];
19
+ // supervisor: the business's team; business: the business itself; developer: the
20
+ // agency. viewer is no longer offered (WorkspaceMembership::INVITABLE_ROLES).
21
+ const ROLES = ["supervisor", "business", "developer"];
20
22
  const USAGE = `Usage: vatio team [list] [--json]\n` +
21
23
  ` vatio team invite EMAIL --role ${ROLES.join("|")} [--code CODE | --recovery-code CODE] [--json]\n` +
22
24
  ` vatio team role EMAIL ${ROLES.join("|")} [--code CODE | --recovery-code CODE] [--json]\n` +
package/lib/help.mjs CHANGED
@@ -91,7 +91,7 @@ it made obsolete, moves it on. \`vatio rollback\` undoes the last change.
91
91
  The chat you are in, or any chat in the workspace
92
92
  (web, WhatsApp, ...): messages, tool calls, channel,
93
93
  and what was read of each file (truncated, unreadable)
94
- chat export --from DATE [--to DATE] [--team] [--channel NAME] [--out FILE]
94
+ chat export --from DATE [--to DATE] [--team] [--channel NAME] [--campaign NAME] [--out FILE]
95
95
  What people said and were answered between two
96
96
  dates, redacted by Vatio, one conversation per
97
97
  line as JSON: your customers', or your team's own
@@ -100,8 +100,10 @@ it made obsolete, moves it on. \`vatio rollback\` undoes the last change.
100
100
  chat reply CHAT_ID "TEXT" Write in a customer's conversation as a person on the
101
101
  team: the agent stays out of it until
102
102
  chat release CHAT_ID hands it back to the agent
103
- analytics [--days N] The inbox's Analytics: conversations, messages, replies
104
- Vatio saved, after hours, questions to the team
103
+ analytics [--days N] [--campaign NAME]
104
+ The inbox's Analytics: conversations, messages, replies
105
+ Vatio saved, after hours, questions to the team, and
106
+ the campaigns and pages they came from
105
107
  testers [web|whatsapp|instagram] | rm whatsapp|instagram ID
106
108
  Who reaches your team's version on Vatio's shared
107
109
  number and account
@@ -170,10 +172,10 @@ it made obsolete, moves it on. \`vatio rollback\` undoes the last change.
170
172
 
171
173
  Team (the owner's; the same roles as the inbox's Team page):
172
174
  team [list] [--json] The owner and everyone invited, and who has not signed in yet
173
- team invite EMAIL --role viewer|supervisor|developer [--code CODE]
175
+ team invite EMAIL --role supervisor|business|developer [--code CODE]
174
176
  Invite them and email them. Needs a second factor on your
175
177
  account: --code is your authenticator app's code
176
- team role EMAIL viewer|supervisor|developer [--code CODE]
178
+ team role EMAIL supervisor|business|developer [--code CODE]
177
179
  Change what they reach; the same second factor
178
180
  team rm EMAIL Take their access away
179
181
  team resend EMAIL Email the invitation again
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vatio-ai/cli",
3
- "version": "0.137.0",
3
+ "version": "0.139.0",
4
4
  "description": "Vatio CLI — deploy and manage Vatio agent workspaces",
5
5
  "keywords": [
6
6
  "vatio",