@vatio-ai/cli 0.111.0 → 0.113.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 +0 -9
- package/lib/commands/channels.mjs +9 -40
- package/lib/commands/team.mjs +5 -5
- package/lib/help.mjs +0 -4
- package/package.json +1 -1
package/lib/api-client.mjs
CHANGED
|
@@ -34,15 +34,6 @@ export class ApiClient extends HttpClient {
|
|
|
34
34
|
return this.get("/test_phones");
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
// "Your numbers", which need no number connected.
|
|
38
|
-
ownerNumbers() {
|
|
39
|
-
return this.get("/whatsapp/owner_numbers");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
updateOwnerNumbers(numbers) {
|
|
43
|
-
return this.patch("/whatsapp/owner_numbers", { owner_numbers: numbers });
|
|
44
|
-
}
|
|
45
|
-
|
|
46
37
|
deployedManifest({ environment = "live" } = {}) {
|
|
47
38
|
return this.get("/manifest", { environment });
|
|
48
39
|
}
|
|
@@ -2,23 +2,25 @@
|
|
|
2
2
|
// number or account needs Meta's consent screen, and test phones and accounts
|
|
3
3
|
// are a form with a code. The CLI only says where, and that depends on whether
|
|
4
4
|
// the workspace has published: before, "Try the agent", where test phones and
|
|
5
|
-
// accounts are verified; after, the channel's own page
|
|
5
|
+
// accounts are verified; after, the channel's own page (WhatsApp, Instagram).
|
|
6
6
|
// vatio.ai/workspaces is only for a server too old to send the link, and
|
|
7
7
|
// redirects to the inbox.
|
|
8
|
-
//
|
|
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.
|
|
11
8
|
|
|
12
9
|
import { deployClient } from "./deploy.mjs";
|
|
13
10
|
import { fail, paint, takeFlag } from "../support.mjs";
|
|
14
11
|
|
|
15
12
|
const WHATSAPP_USAGE =
|
|
16
|
-
"Usage: vatio whatsapp [test-phones [--json]
|
|
13
|
+
"Usage: vatio whatsapp [test-phones [--json]]";
|
|
17
14
|
// The list of who the agent answered on your own number is gone: it answers
|
|
18
15
|
// everyone, and Live off in the inbox is how it answers nobody.
|
|
19
16
|
const AGENT_NUMBERS_REMOVED =
|
|
20
17
|
"`vatio whatsapp only` and `everyone` were removed: the agent answers everyone who writes to your number. " +
|
|
21
18
|
"To have it answer nobody, turn Live off in the inbox, on the WhatsApp page.";
|
|
19
|
+
// "Your numbers" were a list typed by hand; the team's numbers took its place.
|
|
20
|
+
const MINE_REMOVED =
|
|
21
|
+
"`vatio whatsapp mine` was removed: the team's numbers are the ones each member verified on their account " +
|
|
22
|
+
"(Account in the inbox), so there is no list to set. A tool declares which role may use it with " +
|
|
23
|
+
"`access: supervisor`, `developer` or `owner`.";
|
|
22
24
|
|
|
23
25
|
export async function whatsapp(config, args = []) {
|
|
24
26
|
const sub = args.shift();
|
|
@@ -28,11 +30,7 @@ export async function whatsapp(config, args = []) {
|
|
|
28
30
|
await printTestPhones(config).catch((error) => {
|
|
29
31
|
if (error?.status !== 404 && error?.body?.error?.code !== "not_found") throw error;
|
|
30
32
|
});
|
|
31
|
-
|
|
32
|
-
// A server that predates the route answers 404; nothing more to show.
|
|
33
|
-
return printOwnerNumbers(config).catch((error) => {
|
|
34
|
-
if (error?.status !== 404 && error?.body?.error?.code !== "not_found") throw error;
|
|
35
|
-
});
|
|
33
|
+
return printNumber(config);
|
|
36
34
|
}
|
|
37
35
|
if (sub === "test-phones") {
|
|
38
36
|
const json = takeFlag(args, "--json");
|
|
@@ -40,12 +38,7 @@ export async function whatsapp(config, args = []) {
|
|
|
40
38
|
return printTestPhones(config, { json });
|
|
41
39
|
}
|
|
42
40
|
if (sub === "only" || sub === "everyone") fail(AGENT_NUMBERS_REMOVED);
|
|
43
|
-
if (sub === "mine")
|
|
44
|
-
const clear = takeFlag(args, "--clear");
|
|
45
|
-
if (clear && args.length > 0) fail(WHATSAPP_USAGE);
|
|
46
|
-
if (!clear && args.length === 0) return printOwnerNumbers(config);
|
|
47
|
-
return setOwnerNumbers(config, clear ? [] : args.splice(0));
|
|
48
|
-
}
|
|
41
|
+
if (sub === "mine") fail(MINE_REMOVED);
|
|
49
42
|
fail(WHATSAPP_USAGE);
|
|
50
43
|
}
|
|
51
44
|
|
|
@@ -91,30 +84,6 @@ async function printNumber(config) {
|
|
|
91
84
|
}
|
|
92
85
|
}
|
|
93
86
|
|
|
94
|
-
async function setOwnerNumbers(config, numbers) {
|
|
95
|
-
const client = deployClient(config, config.resolveWorkspaceRequired());
|
|
96
|
-
printOwners(await client.updateOwnerNumbers(numbers));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async function printOwnerNumbers(config) {
|
|
100
|
-
const client = deployClient(config, config.resolveWorkspaceRequired());
|
|
101
|
-
printOwners(await client.ownerNumbers());
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function printOwners(body) {
|
|
105
|
-
const list = Array.isArray(body.owner_numbers) ? body.owner_numbers : [];
|
|
106
|
-
if (list.length === 0) {
|
|
107
|
-
console.log("\nYour numbers: none yet.");
|
|
108
|
-
console.log(" On the preview number every verified test phone counts as one until you list some.");
|
|
109
|
-
console.log(" List the business's own: vatio whatsapp mine +56912345678");
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
console.log(`\nYour numbers: ${list.join(", ")}`);
|
|
113
|
-
console.log(" In these conversations the agent works for the business: `access: owner` tools are");
|
|
114
|
-
console.log(" there, and what you send from the WhatsApp Business app is a message to the agent.");
|
|
115
|
-
console.log(" Change them: vatio whatsapp mine NUMBER... Empty the list: vatio whatsapp mine --clear");
|
|
116
|
-
}
|
|
117
|
-
|
|
118
87
|
function printLive(number) {
|
|
119
88
|
const live = number.live
|
|
120
89
|
? paint("green", "live: the agent answers everyone who writes")
|
package/lib/commands/team.mjs
CHANGED
|
@@ -19,7 +19,7 @@ const ROLES = ["viewer", "supervisor", "developer"];
|
|
|
19
19
|
const USAGE = `Usage: vatio team [list] [--json]\n` +
|
|
20
20
|
` vatio team invite EMAIL --role ${ROLES.join("|")} [--code CODE | --recovery-code CODE] [--json]\n` +
|
|
21
21
|
" With a second factor on your account, --code is the 6-digit code from your authenticator app.\n" +
|
|
22
|
-
" vatio team questions [--to EMAIL...|--
|
|
22
|
+
" vatio team questions [--to EMAIL...|--none] [--template NAME [--language CODE]|--no-template] [--json]";
|
|
23
23
|
|
|
24
24
|
export async function team(config, args) {
|
|
25
25
|
const json = takeFlag(args, "--json");
|
|
@@ -86,16 +86,16 @@ async function questions(client, workspace, args, json) {
|
|
|
86
86
|
const template = takeValue(args, "--template");
|
|
87
87
|
const language = takeValue(args, "--language");
|
|
88
88
|
const noTemplate = takeFlag(args, "--no-template");
|
|
89
|
-
const
|
|
89
|
+
const none = takeFlag(args, "--none");
|
|
90
90
|
const to = [];
|
|
91
91
|
for (let index = args.indexOf("--to"); index !== -1; index = args.indexOf("--to")) {
|
|
92
92
|
args.splice(index, 1);
|
|
93
93
|
while (args.length > index && !args[index].startsWith("--")) to.push(args.splice(index, 1)[0]);
|
|
94
94
|
}
|
|
95
|
-
if (args.length > 0 || (to.length > 0 &&
|
|
95
|
+
if (args.length > 0 || (to.length > 0 && none) || (template && noTemplate)) fail(USAGE);
|
|
96
96
|
|
|
97
97
|
const change = {};
|
|
98
|
-
if (
|
|
98
|
+
if (none) change.emails = [];
|
|
99
99
|
if (to.length > 0) change.emails = to;
|
|
100
100
|
if (template) change.template = { name: template, language: language ?? "es" };
|
|
101
101
|
if (noTemplate) change.template = null;
|
|
@@ -106,7 +106,7 @@ async function questions(client, workspace, args, json) {
|
|
|
106
106
|
if (json) return console.log(JSON.stringify(answer, null, 2));
|
|
107
107
|
if (Object.keys(change).length > 0) console.log(`${paint("green", "✓")} Saved.\n`);
|
|
108
108
|
|
|
109
|
-
console.log(`Who the agent asks on workspace ${workspace}${answer.
|
|
109
|
+
console.log(`Who the agent asks on workspace ${workspace}${answer.recipients.some((row) => row.selected) ? "" : " (nobody: it says it does not know)"}:`);
|
|
110
110
|
for (const row of answer.recipients) {
|
|
111
111
|
const flags = [row.selected ? "asked" : "", row.whatsapp_verified ? "" : "no WhatsApp verified"].filter(Boolean).join(", ");
|
|
112
112
|
console.log(` ${(row.role ?? "").padEnd(11)} ${row.email}${flags ? ` (${flags})` : ""}`);
|
package/lib/help.mjs
CHANGED
|
@@ -203,10 +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 mine [NUMBER...|--clear]
|
|
207
|
-
Your numbers: the business's own conversations,
|
|
208
|
-
the only ones with access: owner tools. Needs
|
|
209
|
-
no number connected; prints them without args
|
|
210
206
|
instagram The same, for Instagram
|
|
211
207
|
|
|
212
208
|
Everything else:
|