@vatio-ai/cli 0.110.0 → 0.112.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 +8 -0
- package/lib/commands/team.mjs +40 -1
- package/package.json +1 -1
package/lib/api-client.mjs
CHANGED
|
@@ -215,6 +215,14 @@ export class ApiClient extends HttpClient {
|
|
|
215
215
|
|
|
216
216
|
// --- team -----------------------------------------------------------
|
|
217
217
|
|
|
218
|
+
questionSettings() {
|
|
219
|
+
return this.get("/supervisor_questions");
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
setQuestionSettings(body) {
|
|
223
|
+
return this.patch("/supervisor_questions", body);
|
|
224
|
+
}
|
|
225
|
+
|
|
218
226
|
members() {
|
|
219
227
|
return this.get("/members");
|
|
220
228
|
}
|
package/lib/commands/team.mjs
CHANGED
|
@@ -18,7 +18,8 @@ function explain(error) {
|
|
|
18
18
|
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
|
-
" With a second factor on your account, --code is the 6-digit code from your authenticator app
|
|
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...|--none] [--template NAME [--language CODE]|--no-template] [--json]";
|
|
22
23
|
|
|
23
24
|
export async function team(config, args) {
|
|
24
25
|
const json = takeFlag(args, "--json");
|
|
@@ -31,6 +32,8 @@ export async function team(config, args) {
|
|
|
31
32
|
return print(await client.members().catch(explain), workspace, json);
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
if (sub === "questions") return await questions(client, workspace, args, json);
|
|
36
|
+
|
|
34
37
|
if (sub === "invite") {
|
|
35
38
|
const role = takeValue(args, "--role");
|
|
36
39
|
const code = takeValue(args, "--code");
|
|
@@ -76,3 +79,39 @@ async function invite(client, body) {
|
|
|
76
79
|
return await client.inviteMember({ ...confirmed, code });
|
|
77
80
|
}
|
|
78
81
|
}
|
|
82
|
+
|
|
83
|
+
// Who the agent asks when it cannot answer a customer, and the template that
|
|
84
|
+
// opens the conversation with them (the Team page's "Questions from the agent").
|
|
85
|
+
async function questions(client, workspace, args, json) {
|
|
86
|
+
const template = takeValue(args, "--template");
|
|
87
|
+
const language = takeValue(args, "--language");
|
|
88
|
+
const noTemplate = takeFlag(args, "--no-template");
|
|
89
|
+
const none = takeFlag(args, "--none");
|
|
90
|
+
const to = [];
|
|
91
|
+
for (let index = args.indexOf("--to"); index !== -1; index = args.indexOf("--to")) {
|
|
92
|
+
args.splice(index, 1);
|
|
93
|
+
while (args.length > index && !args[index].startsWith("--")) to.push(args.splice(index, 1)[0]);
|
|
94
|
+
}
|
|
95
|
+
if (args.length > 0 || (to.length > 0 && none) || (template && noTemplate)) fail(USAGE);
|
|
96
|
+
|
|
97
|
+
const change = {};
|
|
98
|
+
if (none) change.emails = [];
|
|
99
|
+
if (to.length > 0) change.emails = to;
|
|
100
|
+
if (template) change.template = { name: template, language: language ?? "es" };
|
|
101
|
+
if (noTemplate) change.template = null;
|
|
102
|
+
|
|
103
|
+
const answer = Object.keys(change).length === 0
|
|
104
|
+
? await client.questionSettings().catch(explain)
|
|
105
|
+
: await client.setQuestionSettings(change).catch(explain);
|
|
106
|
+
if (json) return console.log(JSON.stringify(answer, null, 2));
|
|
107
|
+
if (Object.keys(change).length > 0) console.log(`${paint("green", "✓")} Saved.\n`);
|
|
108
|
+
|
|
109
|
+
console.log(`Who the agent asks on workspace ${workspace}${answer.recipients.some((row) => row.selected) ? "" : " (nobody: it says it does not know)"}:`);
|
|
110
|
+
for (const row of answer.recipients) {
|
|
111
|
+
const flags = [row.selected ? "asked" : "", row.whatsapp_verified ? "" : "no WhatsApp verified"].filter(Boolean).join(", ");
|
|
112
|
+
console.log(` ${(row.role ?? "").padEnd(11)} ${row.email}${flags ? ` (${flags})` : ""}`);
|
|
113
|
+
}
|
|
114
|
+
console.log(answer.template
|
|
115
|
+
? `Template to start the conversation: ${answer.template.name} (${answer.template.language}), body: {{1}} customer, {{2}} question.`
|
|
116
|
+
: "Template to start the conversation: none, so it only reaches who wrote to the agent in the last 24 hours.");
|
|
117
|
+
}
|