@vatio-ai/cli 0.106.0 → 0.108.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/lib/api-client.mjs +1 -5
- package/lib/commands/business.mjs +1 -1
- package/lib/commands/channels.mjs +16 -31
- package/lib/commands/misc.mjs +2 -2
- package/lib/help.mjs +1 -4
- package/package.json +1 -1
package/lib/api-client.mjs
CHANGED
|
@@ -34,10 +34,6 @@ export class ApiClient extends HttpClient {
|
|
|
34
34
|
return this.get("/test_phones");
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
updateWhatsapp(body) {
|
|
38
|
-
return this.patch("/whatsapp", body);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
37
|
// "Your numbers", which need no number connected.
|
|
42
38
|
ownerNumbers() {
|
|
43
39
|
return this.get("/whatsapp/owner_numbers");
|
|
@@ -207,7 +203,7 @@ export class ApiClient extends HttpClient {
|
|
|
207
203
|
// --- business -------------------------------------------------------
|
|
208
204
|
|
|
209
205
|
// Name and brand: one row for every environment, the same one the inbox
|
|
210
|
-
// edits
|
|
206
|
+
// edits on the Web chat page.
|
|
211
207
|
business() {
|
|
212
208
|
return this.get("/business");
|
|
213
209
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// business — the business the agent works for: its name and brand (logo,
|
|
2
|
-
// color, about), the same row the inbox edits
|
|
2
|
+
// color, about), the same row the inbox edits on the Web chat page.
|
|
3
3
|
// Not part of vatio.yml: one value for every environment, live on save.
|
|
4
4
|
//
|
|
5
5
|
// It also held a description of the business, which moved into the agent's
|
|
@@ -6,16 +6,19 @@
|
|
|
6
6
|
// vatio.ai/workspaces is only for a server too old to send the link, and
|
|
7
7
|
// redirects to the inbox.
|
|
8
8
|
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// still reach the inbox), and your numbers (`vatio whatsapp mine`), the
|
|
12
|
-
// business's own conversations, which need no number connected.
|
|
9
|
+
// One thing about WhatsApp is set here too: your numbers (`vatio whatsapp
|
|
10
|
+
// mine`), the business's own conversations, which need no number connected.
|
|
13
11
|
|
|
14
12
|
import { deployClient } from "./deploy.mjs";
|
|
15
13
|
import { fail, paint, takeFlag } from "../support.mjs";
|
|
16
14
|
|
|
17
15
|
const WHATSAPP_USAGE =
|
|
18
|
-
"Usage: vatio whatsapp [test-phones [--json] |
|
|
16
|
+
"Usage: vatio whatsapp [test-phones [--json] | mine [NUMBER... | --clear]]";
|
|
17
|
+
// The list of who the agent answered on your own number is gone: it answers
|
|
18
|
+
// everyone, and Live off in the inbox is how it answers nobody.
|
|
19
|
+
const AGENT_NUMBERS_REMOVED =
|
|
20
|
+
"`vatio whatsapp only` and `everyone` were removed: the agent answers everyone who writes to your number. " +
|
|
21
|
+
"To have it answer nobody, turn Live off in the inbox, on the WhatsApp page.";
|
|
19
22
|
|
|
20
23
|
export async function whatsapp(config, args = []) {
|
|
21
24
|
const sub = args.shift();
|
|
@@ -25,7 +28,7 @@ export async function whatsapp(config, args = []) {
|
|
|
25
28
|
await printTestPhones(config).catch((error) => {
|
|
26
29
|
if (error?.status !== 404 && error?.body?.error?.code !== "not_found") throw error;
|
|
27
30
|
});
|
|
28
|
-
await
|
|
31
|
+
await printNumber(config);
|
|
29
32
|
// A server that predates the route answers 404; nothing more to show.
|
|
30
33
|
return printOwnerNumbers(config).catch((error) => {
|
|
31
34
|
if (error?.status !== 404 && error?.body?.error?.code !== "not_found") throw error;
|
|
@@ -36,14 +39,7 @@ export async function whatsapp(config, args = []) {
|
|
|
36
39
|
if (args.length > 0) fail(WHATSAPP_USAGE);
|
|
37
40
|
return printTestPhones(config, { json });
|
|
38
41
|
}
|
|
39
|
-
if (sub === "only")
|
|
40
|
-
if (args.length === 0) fail(WHATSAPP_USAGE);
|
|
41
|
-
return setAgentNumbers(config, args.splice(0));
|
|
42
|
-
}
|
|
43
|
-
if (sub === "everyone") {
|
|
44
|
-
if (args.length > 0) fail(WHATSAPP_USAGE);
|
|
45
|
-
return setAgentNumbers(config, []);
|
|
46
|
-
}
|
|
42
|
+
if (sub === "only" || sub === "everyone") fail(AGENT_NUMBERS_REMOVED);
|
|
47
43
|
if (sub === "mine") {
|
|
48
44
|
const clear = takeFlag(args, "--clear");
|
|
49
45
|
if (clear && args.length > 0) fail(WHATSAPP_USAGE);
|
|
@@ -83,17 +79,12 @@ async function printTestPhones(config, { json = false } = {}) {
|
|
|
83
79
|
for (const phone of data) console.log(` ${phone.phone_number}`);
|
|
84
80
|
}
|
|
85
81
|
|
|
86
|
-
async function setAgentNumbers(config, numbers) {
|
|
87
|
-
const client = deployClient(config, config.resolveWorkspaceRequired());
|
|
88
|
-
printAnswers(await client.updateWhatsapp({ agent_numbers: numbers }));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
82
|
// After the inbox link: a workspace with no number of its own has nothing
|
|
92
83
|
// more to show, and the link already says what to do.
|
|
93
|
-
async function
|
|
84
|
+
async function printNumber(config) {
|
|
94
85
|
const client = deployClient(config, config.resolveWorkspaceRequired());
|
|
95
86
|
try {
|
|
96
|
-
|
|
87
|
+
printLive(await client.getWhatsapp());
|
|
97
88
|
} catch (error) {
|
|
98
89
|
if (error?.body?.error?.code === "whatsapp_not_connected") return;
|
|
99
90
|
throw error;
|
|
@@ -124,15 +115,9 @@ function printOwners(body) {
|
|
|
124
115
|
console.log(" Change them: vatio whatsapp mine NUMBER... Empty the list: vatio whatsapp mine --clear");
|
|
125
116
|
}
|
|
126
117
|
|
|
127
|
-
function
|
|
128
|
-
const
|
|
129
|
-
|
|
118
|
+
function printLive(number) {
|
|
119
|
+
const live = number.live
|
|
120
|
+
? paint("green", "live: the agent answers everyone who writes")
|
|
121
|
+
: paint("cyan", "paused: Live is off in the inbox, on the WhatsApp page");
|
|
130
122
|
console.log(`\n${number.display_phone_number ?? "Your number"}: ${live}`);
|
|
131
|
-
if (list.length === 0) {
|
|
132
|
-
console.log(" The agent answers everyone. To answer only some numbers: vatio whatsapp only +56912345678");
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
console.log(` The agent answers only: ${list.join(", ")}`);
|
|
136
|
-
console.log(" Everyone else's messages reach the inbox unanswered.");
|
|
137
|
-
console.log(" Back to everyone: vatio whatsapp everyone");
|
|
138
123
|
}
|
package/lib/commands/misc.mjs
CHANGED
|
@@ -157,7 +157,7 @@ export async function init(config, args) {
|
|
|
157
157
|
if (agentsNote) console.log(agentsNote);
|
|
158
158
|
if (!authorized) console.log(`Local only for now — \`vatio push\` is what creates ${slug} on the platform.`);
|
|
159
159
|
if (!authorized && String(name ?? "").trim() !== "") {
|
|
160
|
-
console.log("Set the display name once it exists: `vatio business set --name NAME`, or in the inbox
|
|
160
|
+
console.log("Set the display name once it exists: `vatio business set --name NAME`, or in the inbox on the Web chat page.");
|
|
161
161
|
}
|
|
162
162
|
console.log("");
|
|
163
163
|
console.log("Next:");
|
|
@@ -204,7 +204,7 @@ function writeAgentsNote(target) {
|
|
|
204
204
|
// The smallest file that deploys: which workspace, and what the agent does.
|
|
205
205
|
// The slug is already validated as a slug, so it needs no quoting. The display
|
|
206
206
|
// name is not here: it is the business name, set with `vatio business set --name`
|
|
207
|
-
// or in the inbox
|
|
207
|
+
// or in the inbox on the Web chat page.
|
|
208
208
|
function starterManifest(slug) {
|
|
209
209
|
const lines = ["# Which Vatio workspace this directory deploys to.", `workspace: ${slug}`, ""];
|
|
210
210
|
lines.push("agent:");
|
package/lib/help.mjs
CHANGED
|
@@ -130,7 +130,7 @@ the two you are in. Commands default as listed.
|
|
|
130
130
|
(entry commands take --env; --env live writes live)
|
|
131
131
|
|
|
132
132
|
Business (one value for every environment, live on save; also in the inbox,
|
|
133
|
-
|
|
133
|
+
on the Web chat page):
|
|
134
134
|
business [show] Name and brand, and the old business description
|
|
135
135
|
if there is one
|
|
136
136
|
business set [--name NAME] [--about TEXT] [--color #RRGGBB|default]
|
|
@@ -203,9 +203,6 @@ the two you are in. Commands default as listed.
|
|
|
203
203
|
whatsapp test-phones [--json]
|
|
204
204
|
The phones verified in Try the agent, to send a
|
|
205
205
|
preview message to
|
|
206
|
-
whatsapp only NUMBER...|everyone
|
|
207
|
-
Who the agent answers on your own number; the
|
|
208
|
-
rest still reach the inbox
|
|
209
206
|
whatsapp mine [NUMBER...|--clear]
|
|
210
207
|
Your numbers: the business's own conversations,
|
|
211
208
|
the only ones with access: owner tools. Needs
|